Removed Flare

This commit is contained in:
Jonas Strandstedt
2014-10-23 15:35:55 +02:00
parent 5e410c6816
commit 3ee8f85c14
30 changed files with 1 additions and 5429 deletions
@@ -34,18 +34,7 @@
#include <openspace/interaction/interactionhandler.h>
#include <openspace/rendering/renderengine.h>
#include <openspace/engine/configurationmanager.h>
#include <ghoul/opencl/clcontext.h>
#include <ghoul/opencl/clcommandqueue.h>
#include <ghoul/opencl/clprogram.h>
#include <ghoul/opencl/clkernel.h>
#include <ghoul/cmdparser/commandlineparser.h>
// #define FLARE_ONLY
#include <openspace/flare/flare.h>
// #define OPENSPACE_VIDEO_EXPORT
namespace openspace {
@@ -69,7 +58,6 @@ public:
static bool findConfiguration(std::string& filename);
ConfigurationManager& configurationManager();
ghoul::opencl::CLContext& clContext();
InteractionHandler& interactionHandler();
RenderEngine& renderEngine();
scripting::ScriptEngine& scriptEngine();
@@ -105,14 +93,6 @@ private:
RenderEngine _renderEngine;
scripting::ScriptEngine _scriptEngine;
ghoul::cmdparser::CommandlineParser _commandlineParser;
#ifdef OPENSPACE_VIDEO_EXPORT
bool _doVideoExport;
#endif
#ifdef FLARE_ONLY
Flare* _flare;
#endif
// ScriptEngine* _scriptEngine;
ghoul::opencl::CLContext _context;
SyncBuffer* _syncBuffer;
-63
View File
@@ -1,63 +0,0 @@
#ifndef ANIMATOR_H
#define ANIMATOR_H
/*
* Author: Victor Sand (victor.sand@gmail.com)
* Encapsulates animation logic
*
*/
namespace osp {
class Config;
class Animator {
public:
static Animator * New(Config *_config);
// Signals the animator to update its state if needed
void Update(float _elapsedTime);
// Pauses if unpaused, unpauses if paused
void TogglePause();
// If FPS mode is on, don't wait. Update every timestep.
void ToggleFPSMode();
void SetPaused(bool _paused);
void SetFPSMode(bool _fpsMode);
void ManualTimestep(int _manualTimestep);
unsigned int CurrentTimestep() const { return currentTimestep_; }
unsigned int NextTimestep() const {
return currentTimestep_ < numTimesteps_-1 ? currentTimestep_+1 : 0;
}
void SetCurrentTimestep(unsigned int _timestep);
void SetNumTimesteps(unsigned int _numTimesteps);
void IncTimestep();
void DecTimestep();
bool UpdateConfig();
private:
Animator();
Animator(Config *_config);
Animator(const Animator&) { }
Config *config_;
// Number of timesteps before looping occurs
unsigned int numTimesteps_;
// Current timestep, the output of the Animator
unsigned int currentTimestep_;
bool fpsMode_;
bool paused_;
// Keeps track of elapsed time between timestep updates
float elapsedTime_;
// Time before timestep gets updates
float refreshInterval_;
};
}
#endif
-154
View File
@@ -1,154 +0,0 @@
/*
* Author: Victor Sand (victor.sand@gmail.com)
*
*/
#ifndef BRICKMANAGER_H
#define BRICKMANAGER_H
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <fstream>
//#include <boost/timer/timer.hpp>
#include <stdio.h>
#include <ghoul/opengl/texture.h>
// Make sure we get 64 bits for offset
#define _FILE_OFFSET_BITS 64
// For easy switching between offset types
#define off off64_t
namespace osp {
class Config;
class BrickManager {
public:
static BrickManager * New(Config *_config);
~BrickManager();
Config *config_;
enum BUFFER_INDEX { EVEN = 0, ODD };
// Read header data from file, should normally only be called once
// unless header data changes
bool ReadHeader();
bool InitAtlas();
// Build brick list from request list
// Resets values in _brickRequest to 0
bool BuildBrickList(BUFFER_INDEX _bufIdx, std::vector<int> &_brickRequest);
// Upload bricks from memory buffer to PBO using the brick list
bool DiskToPBO(BUFFER_INDEX _pboIndex);
// Init transfer from PBO to texture atlas
bool PBOToAtlas(BUFFER_INDEX _pboIndex);
std::vector<int> BrickList(BUFFER_INDEX _bufIdx) {
return brickLists_[_bufIdx];
}
ghoul::opengl::Texture * TextureAtlas() { return textureAtlas_; }
// Header accessors
unsigned int GridType() const { return gridType_; }
unsigned int NumOrigTimesteps() const { return numOrigTimesteps_; }
unsigned int NumTimesteps() const { return numTimesteps_; }
unsigned int XBrickDim() const { return xBrickDim_; }
unsigned int YBrickDim() const { return yBrickDim_; }
unsigned int ZBrickDim() const { return zBrickDim_; }
unsigned int XNumBricks() const { return xNumBricks_; }
unsigned int YNumBricks() const { return yNumBricks_; }
unsigned int ZNumBricks() const { return zNumBricks_; }
unsigned int PaddingWidth() const { return paddingWidth_; }
unsigned int DataSize() const { return dataSize_; }
private:
BrickManager();
BrickManager(Config *_config);
BrickManager(const BrickManager&);
// Header data
unsigned int gridType_;
unsigned int numOrigTimesteps_;
unsigned int numTimesteps_;
unsigned int xBrickDim_;
unsigned int yBrickDim_;
unsigned int zBrickDim_;
unsigned int xNumBricks_;
unsigned int yNumBricks_;
unsigned int zNumBricks_;
unsigned int dataSize_;
unsigned int numBricks_;
unsigned int brickDim_;
unsigned int paddedBrickDim_;
unsigned int atlasDim_;
const unsigned int paddingWidth_ = 1;
unsigned int numBrickVals_;
unsigned int numBricksFrame_;
unsigned int numBricksTree_;
unsigned int brickSize_;
unsigned int volumeSize_;
unsigned int numValsTot_;
// Texture coordinates to be assigned
int xCoord_;
int yCoord_;
int zCoord_;
// Texture where the actual atlas is kept
ghoul::opengl::Texture *textureAtlas_;
std::vector<std::vector<int> > brickLists_;
// C-style I/O
std::FILE *file_;
#ifdef WIN32
long long dataPos_;
#else
off_t dataPos_;
#endif
bool hasReadHeader_;
bool atlasInitialized_;
// PBOs
unsigned int pboHandle_[2];
// Caching, one for each PBO
std::vector<std::vector<int> > bricksInPBO_;
std::vector<std::vector<bool> > usedCoords_;
// Increment the coordinate to be assigned (handle looping)
void IncCoord();
// Linear version of the current x, y, z coordinate to be assigned
unsigned int LinearCoord(int _x, int _y, int _z);
// 3D coordinates from linear index
void CoordsFromLin(int _idx, int &_x, int &_y, int &_z);
// Fill a brick in the volume using a pointer to flattened brick data
bool FillVolume(float *_in,
float *_out,
unsigned int _x,
unsigned int _y,
unsigned int _z);
// Timer and timer constants
//boost::timer::cpu_timer timer_;
const double BYTES_PER_GB = 1073741824.0;
};
}
#endif
-139
View File
@@ -1,139 +0,0 @@
/*
* Author: Victor Sand (victor.sand@gmail.com)
*
*/
#ifndef CL_MANAGER_H_
#define CL_MANAGER_H_
#include <ghoul/opencl/ghoul_cl.h>
#include <ghoul/opencl/clcontext.h>
#include <ghoul/opencl/clcommandqueue.h>
#include <ghoul/opencl/clprogram.h>
#include <ghoul/opencl/clkernel.h>
#include <ghoul/opencl/clutil.h>
#include <ghoul/opencl/clworksize.h>
#include <map>
#include <string>
#include <openspace/flare/KernelConstants.h>
namespace osp {
class TransferFunction;
class CLProgram;
class TSP;
class CLManager {
public:
static CLManager * New();
~CLManager();
// Different queue indices for working with asynchronous uploads/executions
enum QueueIndex { EXECUTE, TRANSFER, NUM_QUEUE_INDICES };
enum TextureType { TEXTURE_1D, TEXTURE_2D, TEXTURE_3D };
enum Permissions { READ_ONLY, WRITE_ONLY, READ_WRITE };
enum AllocMode { USE_HOST_PTR, ALLOC_HOST_PTR, COPY_HOST_PTR };
// These four functions should be run in this order
bool InitPlatform();
bool InitDevices();
bool CreateContext();
bool CreateCommandQueue();
// Name a program and create it from source text file
bool CreateProgram(std::string _programName, std::string _fileName);
// Build program after creation
bool BuildProgram(std::string _programName);
// Create kernel after building program
bool CreateKernel(std::string _programName);
// Add an OpenGL texture to a program
bool AddTexture(std::string _programName, unsigned int _argNr,
ghoul::opengl::Texture *_texture, TextureType _textureType,
Permissions _permissions);
bool AddTexture(std::string _programName, unsigned int _argNr,
ghoul::opengl::Texture *_texture, TextureType _textureType,
Permissions _permissions, cl_mem& _clTextureMem);
bool AddTexture(std::string _programName, unsigned int _argNr,
cl_mem _texture, Permissions _permissions);
bool AddBuffer(std::string _programName, unsigned int _argNr,
void *_hostPtr, unsigned int _sizeInBytes,
AllocMode _allocMode, Permissions _permissions);
bool ReadBuffer(std::string _programName, unsigned int _argNr,
void *_hostPtr, unsigned int _sizeInBytes,
bool _blocking);
// Free resources
bool ReleaseBuffer(std::string _programName, unsigned int _argNr);
// Set the value of an integer argument
bool SetInt(std::string _programName, unsigned int _argNr, int _val);
// Aquire any shared textures, set up kernel arguments etc
bool PrepareProgram(std::string _programName);
// Launch program kernel (returns immediately)
bool LaunchProgram(std::string _programName,
unsigned int _gx, unsigned int _gy,
unsigned int _lx, unsigned int _ly);
// Wait for kernel to finish, releaste any shared resources
bool FinishProgram(std::string _programName);
// Finish all commands in a command queue
// Can be used e.g. to sync a DMA transfer operation
bool FinishQueue(QueueIndex _queueIndex);
friend class CLProgram;
private:
CLManager();
CLManager(const CLManager&);
// Read kernel source from file, return char array
// Store number of chars in _numChar argument
char * ReadSource(std::string _fileName, int &_numChars) const;
// Check state in a cl_int, print error if state is not CL_SUCCESS
bool CheckSuccess(cl_int _error, std::string _location) const;
// Translate cl_int enum to readable string
std::string ErrorString(cl_int _error) const;
// Convert CLManager::Permissions to cl_mem_flags
cl_mem_flags ConvertPermissions(Permissions _permissions);
// Conver CLManager::AllocMode to cl_mem_flags
cl_mem_flags ConvertAllocMode(AllocMode _allocMode);
static const unsigned int MAX_PLATFORMS = 32;
static const unsigned int MAX_DEVICES = 32;
static const unsigned int MAX_NAME_LENGTH = 128;
// Used for storing and reading error state during function calls
cl_int error_;
cl_uint numPlatforms_;
cl_platform_id platforms_[MAX_PLATFORMS];
cl_uint numDevices_;
cl_device_id devices_[MAX_DEVICES];
// Maximum allocatable size for each device
cl_ulong maxMemAllocSize_[MAX_DEVICES];
char deviceName_[MAX_NAME_LENGTH];
char driverVersion_[MAX_NAME_LENGTH];
char platformVersion_[MAX_NAME_LENGTH];
//cl_context context_;
ghoul::opencl::CLCommandQueue commandQueues_[NUM_QUEUE_INDICES];
// Programs are mapped using strings
std::map<std::string, CLProgram*> clPrograms_;
ghoul::opencl::CLContext _context;
};
}
#endif
-93
View File
@@ -1,93 +0,0 @@
/*
* Victor Sand (victor.sand@gmail.com)
*
*/
#ifndef CL_PROGRAM_H_
#define CL_PROGRAM_H_
#include <ghoul/opencl/ghoul_cl.h>
#include <map>
#include <string>
#include <openspace/flare/KernelConstants.h>
#include <ghoul/opengl/texture.h>
namespace osp {
class CLManager;
class TransferFunction;
class Texture;
class CLProgram {
public:
static CLProgram * New(const std::string &_programName,
CLManager *_clManager);
~CLProgram();
struct MemArg {
size_t size_;
cl_mem mem_;
};
cl_program Program() { return program_; }
cl_kernel Kernel() { return kernel_; }
cl_int Error() { return error_; }
bool CreateProgram(std::string _fileName);
bool BuildProgram();
bool CreateKernel();
bool AddTexture(unsigned int _argNr, ghoul::opengl::Texture *_texture,
GLuint _textureType,
cl_mem_flags _permissions);
bool AddTexture(unsigned int _argNr, ghoul::opengl::Texture *_texture,
GLuint _textureType,
cl_mem_flags _permissions, cl_mem& _clTextureMem);
bool AddTexture(unsigned int _argNr, cl_mem _texture,
cl_mem_flags _permissions);
bool AddBuffer(unsigned int _argNr,
void *_hostPtr,
unsigned int _sizeInBytes,
cl_mem_flags _allocMode,
cl_mem_flags _permissions);
bool ReadBuffer(unsigned int _argNr,
void *_hostPtr,
unsigned int _sizeInBytes,
cl_bool _blocking);
bool ReleaseBuffer(unsigned int _argNr);
bool SetInt(unsigned int _argNr, int _val);
bool PrepareProgram();
bool LaunchProgram(unsigned int _gx, unsigned int _gy,
unsigned int _lx, unsigned int _ly);
bool FinishProgram();
private:
CLProgram(const std::string &_programName, CLManager *_clManager);
CLProgram();
CLProgram(const CLProgram&);
char * ReadSource(const std::string &_fileName, int &_numChars) const;
std::string programName_;
CLManager *clManager_;
cl_program program_;
cl_kernel kernel_;
cl_int error_;
// Stores device OGL textures together with their kernel arg nummer
std::map<cl_uint, cl_mem> OGLTextures_;
// Stores non-texture memory buffer arguments
std::map<cl_uint, MemArg> memArgs_;
};
}
#endif
-109
View File
@@ -1,109 +0,0 @@
/*
* Author: Victor Sand (victor.sand@gmail.com)
*
* Simple functionality to read, save and access constants.
* Reads the specified file as soon as the object is created.
*
*/
#ifndef CONFIG_H_
#define CONFIG_H_
#include <string>
namespace osp {
class Config {
public:
static Config * New(const std::string &_configFilename);
~Config();
// Reads the config file, can be called by external modules
bool Read();
int WinWidth() const { return winWidth_; }
int WinHeight() const { return winHeight_; }
bool ClearCache() const { return clearCache_; }
int TextureDivisionFactor() const { return textureDivisionFactor_; }
unsigned int LocalWorkSizeX() const { return localWorkSizeX_; }
unsigned int LocalWorkSizeY() const { return localWorkSizeY_; }
std::string TSPFilename() const { return TSPFilename_; }
std::string TFFilename() const { return TFFilename_; }
std::string RaycasterKernelFilename()const{return raycasterKernelFilename_;}
std::string TSPTraversalKernelFilename() const
{ return TSPTraversalKernelFilename_; }
std::string CubeShaderVertFilename() const { return cubeShaderVertFilename_;}
std::string CubeShaderFragFilename() const { return cubeShaderFragFilename_;}
std::string QuadShaderVertFilename() const { return quadShaderVertFilename_;}
std::string QuadShaderFragFilename() const { return quadShaderFragFilename_;}
float SpatialErrorTolerance() const { return spatialErrorTolerance_; }
float TemporalErrorTolerance() const { return temporalErrorTolerance_; }
float TSPTraversalStepsize() const { return TSPTraversalStepsize_; }
float RaycasterStepsize() const { return raycasterStepsize_; }
float RaycasterIntensity() const { return raycasterIntensity_; }
float AnimatorRefreshInterval() const { return animatorRefreshInterval_; }
float MousePitchFactor() const { return mousePitchFactor_; }
float MouseRollFactor() const { return mouseRollFactor_; }
float ZoomFactor() const { return zoomFactor_; }
float StartPitch() const { return startPitch_; }
float StartRoll() const { return startRoll_; }
float StartYaw() const { return startYaw_; }
float TranslateX() const { return translateX_; }
float TranslateY() const { return translateY_; }
float TranslateZ() const { return translateZ_; }
int CalculateError() const { return calculateError_; }
float PitchSpeed() const { return pitchSpeed_; }
float RollSpeed() const { return rollSpeed_; }
float YawSpeed() const { return yawSpeed_; }
bool TakeScreenshot() const { return takeScreenshot_; }
private:
Config();
Config(const std::string &_configFilename);
Config(const Config&);
std::string configFilename_;
int winWidth_;
int winHeight_;
bool clearCache_;
int textureDivisionFactor_;
unsigned int localWorkSizeX_;
unsigned int localWorkSizeY_;
std::string TSPFilename_;
std::string TFFilename_;
std::string raycasterKernelFilename_;
std::string TSPTraversalKernelFilename_;
std::string cubeShaderVertFilename_;
std::string cubeShaderFragFilename_;
std::string quadShaderVertFilename_;
std::string quadShaderFragFilename_;
float spatialErrorTolerance_;
float temporalErrorTolerance_;
float TSPTraversalStepsize_;
float raycasterStepsize_;
float raycasterIntensity_;
float animatorRefreshInterval_;
float mousePitchFactor_;
float mouseRollFactor_;
float zoomFactor_;
float startPitch_;
float startRoll_;
float startYaw_;
float translateX_;
float translateY_;
float translateZ_;
int calculateError_;
float pitchSpeed_;
float rollSpeed_;
float yawSpeed_;
bool takeScreenshot_;
};
}
#endif
-37
View File
@@ -1,37 +0,0 @@
#ifndef KERNELCONSTANTS_H_
#define KERNELCONSTANTS_H_
/*
Author: Victor Sand (victor.sand@gmail.com)
Simple structs to gather constants used in kernel
*/
namespace osp {
struct KernelConstants {
int gridType_;
float stepsize_;
float intensity_;
int numTimesteps_;
int numValuesPerNode_;
int numOTNodes_;
int numBoxesPerAxis_;
float temporalTolerance_;
float spatialTolerance_;
int rootLevel_;
int paddedBrickDim_;
};
struct TraversalConstants {
int gridType_;
float stepsize_;
int numTimesteps_;
int numValuesPerNode_;
int numOTNodes_;
float temporalTolerance_;
float spatialTolerance_;
};
}
#endif
-65
View File
@@ -1,65 +0,0 @@
#ifndef MAPPINGKEY_H
#define MAPPINGKEY_H
/*
Author: Victor Sand (victor.sand@gmail.com)
Mapping key used in transfer function. A key includes an intensity
for which the key is active, and RGBA values for that specific intensity.
*/
#include <iostream>
#include <openspace/flare/Utils.h>
namespace osp {
class MappingKey {
public:
MappingKey();
MappingKey(const MappingKey &_mappingKey);
MappingKey(float _intensity, unsigned int _r, unsigned int _g,
unsigned int _b, unsigned int _a);
~MappingKey();
float Intensity() const { return intensity_; }
unsigned int R() const { return r_; }
unsigned int G() const { return g_; }
unsigned int B() const { return b_; }
unsigned int A() const { return a_; }
unsigned int Channel(unsigned int _channel) const {
switch (_channel) {
case 0:
return r_;
case 1:
return g_;
case 2:
return b_;
case 3:
return a_;
default:
ERROR("Invalid channel, returning 0");
return 0;
}
}
void SetValues(float _intensity, unsigned int _r, unsigned int _g,
unsigned int _b, unsigned int _a);
// Comparsion by intensity for sorting purposes
bool operator<(const MappingKey &_mappingKey) const;
MappingKey & operator=(const MappingKey &_mappingKey);
private:
float intensity_;
unsigned int r_;
unsigned int g_;
unsigned int b_;
unsigned int a_;
};
}
std::ostream& operator<<(std::ostream &os,
const osp::MappingKey &_mappingKey);
#endif
-196
View File
@@ -1,196 +0,0 @@
#ifndef RAYCASTER_H_
#define RAYCASTER_H_
/*
Author: Victor Sand (victor.sand@gmail.com)
Mammoth workhorse class that ties all parts of the raycaster application
together. Manages state, render calls and a lot of initializations.
TODO: Iteratively break away parts from it into other classes.
*/
#include <openspace/flare/Renderer.h>
#include <map>
#include <string>
#include <vector>
#include <ghoul/glm.h>
#include <ghoul/opencl/ghoul_cl.h>
#include <openspace/flare/KernelConstants.h>
//#include <boost/timer/timer.hpp>
#include <openspace/flare/TSP.h>
#include <ghoul/opengl/programobject.h>
#include <ghoul/opengl/texture.h>
namespace osp {
class TransferFunction;
class Animator;
class BrickManager;
class CLManager;
class Config;
class Raycaster : public Renderer {
public:
static Raycaster * New(Config *_config);
virtual ~Raycaster();
virtual bool Render(float _timestep);
// Called by the SGCT window manager
bool Reload();
// Init pipeline for double buffered setup
bool InitPipeline();
// Reload GLSL shaders
bool ReloadShaders();
// Reload transfer function file
bool ReloadTransferFunctions();
// Initialize the color cube used for raycasting.
// TODO Make cube class.
bool InitCube();
// Init the quad used for output texture rendering
bool InitQuad();
// Run all of CLHandlers initialization functions
bool InitCL();
// Set up buffers for the different rendering stages
bool InitFramebuffers();
// Set up two pixel buffers for texture streaming
bool InitPixelBuffers();
// Update matrices with current view parameters
bool UpdateMatrices();
// Bind transformation matrices to a ShaderProgram
bool BindTransformationMatrices(ghoul::opengl::ProgramObject *_program);
// Read kernel config from file and voxel data,
// update the constants that get sent to the kernel every frame
bool UpdateKernelConfig();
// For keyboard handling, retrieve the last known state of a key
bool KeyLastState(int _key) const;
// Add a transfer function to the transfer function list
// TODO Actually support and make use of multiple TFs
void AddTransferFunction(TransferFunction *_transferFunction);
ghoul::opengl::Texture * CubeFrontTexture() const { return cubeFrontTex_; }
ghoul::opengl::Texture * CubeBackTexture() const { return cubeBackTex_; }
ghoul::opengl::Texture * QuadTexture() const { return quadTex_; }
void SetKernelConfigFilename(const std::string &_filename);
void SetCubeFrontTexture(ghoul::opengl::Texture *_cubeFrontTexture);
void SetCubeBackTexture(ghoul::opengl::Texture *_cubeBackTexture);
void SetQuadTexture(ghoul::opengl::Texture *_quadTexture);
void SetCubeShaderProgram(ghoul::opengl::ProgramObject *_cubeShaderProgram);
void SetQuadShaderProgram(ghoul::opengl::ProgramObject *_quadShaderProgram);
void SetAnimator(Animator *_animator);
void SetCLManager(CLManager *_clManager);
void SetBrickManager(BrickManager *_brickManager);
void SetTSP(TSP *_tsp);
// SGCT
void SetModelParams(float _pitch, float _yaw, float _roll);
void SetViewParams(float _translateX, float _translateY, float _translateZ);
private:
Raycaster();
Raycaster(Config *_config);
Config *config_;
// VAO handles
unsigned int cubeVAO_;
unsigned int quadVAO_;
// Buffer object handles
unsigned int cubeFrontFBO_;
unsigned int cubeBackFBO_;
unsigned int renderbufferObject_;
unsigned int cubePosbufferObject_;
unsigned int quadPosbufferObject_;
unsigned int cubePositionAttrib_;
unsigned int quadPositionAttrib_;
// Shaders
ghoul::opengl::ProgramObject *cubeShaderProgram_;
ghoul::opengl::ProgramObject *quadShaderProgram_;
// Textures
ghoul::opengl::Texture *cubeFrontTex_;
ghoul::opengl::Texture *cubeBackTex_;
ghoul::opengl::Texture *quadTex_;
ghoul::opengl::Texture *volumeTex_;
// Model params
float pitch_;
float yaw_;
float roll_;
// View
float translateX_;
float translateY_;
float translateZ_;
// Tranformation matrices
glm::mat4 model_;
glm::mat4 view_;
glm::mat4 proj_;
// State
bool cubeInitialized_;
bool quadInitialized_;
bool framebuffersInitialized_;
bool pingPong_; // texture streaming
// Animator to control update rate and looping
Animator * animator_;
// Used to see if it is time to update frames
unsigned int lastTimestep_;
// Used for ping pong memory buffering
unsigned int pingPongIndex_;
// Kernel constants
KernelConstants kernelConstants_;
TraversalConstants traversalConstants_;
std::string kernelConfigFilename_;
// Transfer functions
std::vector<TransferFunction*> transferFunctions_;
// Brick manager with access to brick data
BrickManager *brickManager_;
bool LaunchTSPTraversal(unsigned int _timestep);
// Brick request list
std::vector<int> brickRequest_;
// TSP tree structure (not actual data)
TSP *tsp_;
// Entry point for all things OpenCL
CLManager *clManager_;
// Helper function for updating and binding kernel constants
bool UpdateKernelConstants();
// For the corresponding CL kernel
static const unsigned int cubeFrontArg_ = 0;
static const unsigned int cubeBackArg_ = 1;
static const unsigned int quadArg_ = 2;
static const unsigned int textureAtlasArg_ = 3;
static const unsigned int constantsArg_ = 4;
static const unsigned int transferFunctionArg_ = 5;
static const unsigned int tspArg_ = 6;
static const unsigned int brickListArg_ = 7;
static const unsigned int timestepArg_ = 8;
static const unsigned int tspCubeFrontArg_ = 0;
static const unsigned int tspCubeBackArg_ = 1;
static const unsigned int tspConstantsArg_ = 2;
static const unsigned int tspTSPArg_ = 3;
static const unsigned int tspBrickListArg_ = 4;
static const unsigned int tspTimestepArg_ = 5;
// Timer and timer constants
//boost::timer::cpu_timer timer_;
cl_mem cubeFrontCLmem;
cl_mem cubeBackCLmem;
};
}
#endif
-45
View File
@@ -1,45 +0,0 @@
#ifndef RENDERER_H
#define RENDERER_H
/*
Author: Victor Sand (victor.sand@gmail.com)
Renderer abstract class, Render() functions needs to be
implemented by subclasses.
TODO No real use right now but to handle key and mouse state
TODO Write better and manageable key state functionality
*/
#include <map>
namespace osp {
class Renderer {
public:
virtual bool Render(float _timestep) = 0;
virtual ~Renderer();
void SetKeyPressed(int _key, bool _pressed);
bool KeyPressed(int _key) const;
void SetWinWidth(unsigned int _winWidth);
void SetWinHeight(unsigned int _winHeight);
void SetMousePosition(float _mouseX, float _mouseY);
void SetMousePressed(bool _leftPressed, bool _rightPressed);
float FPS() const;
protected:
Renderer();
// Window
unsigned int winWidth_;
unsigned int winHeight_;
// Mouse
bool leftMouseDown_;
bool rightMouseDown_;
float currentMouseX_;
float currentMouseY_;
float lastMouseX_;
float lastMouseY_;
// Keyboard
std::map<int, bool> keysPressed_; // Is key pressed or not?
};
}
#endif
-154
View File
@@ -1,154 +0,0 @@
/*
* Author: Victor Sand (victor.sand@gmail.com)
*
* Construct a traversable TSP structure with structure and error info
* from a .tsp file
*
*/
#ifndef TSP_H_
#define TSP_H_
// Make sure to use 64 bits for file offset
#define _FILE_OFFSET_BITS 64
// For easy switching between offset types
// (off_t, off64_t etc)
#define off off64_t
#include <vector>
#include <list>
#include <string>
#include <iostream>
namespace osp {
class Config;
class TransferFunction;
class TSP {
public:
enum NodeData {
BRICK_INDEX = 0,
CHILD_INDEX,
SPATIAL_ERR,
TEMPORAL_ERR,
NUM_DATA
};
static TSP * New(Config * _config);
~TSP();
// Struct for convenience
// Note: UNUSED in this implementation
struct Color {
Color() {
r = g = b = a = 0.f;
}
Color(float _r, float _g, float _b, float _a) {
r = _r;
g = _g;
b = _b;
a = _a;
}
float r;
float g;
float b;
float a;
};
// Tries to read cached file
bool ReadCache();
// Write structure to cache
bool WriteCache();
bool ReadHeader();
// Functions to build TSP tree and calculate errors
bool Construct();
bool CalculateSpatialError();
bool CalculateTemporalError();
int * Data() { return &data_[0]; }
size_t Size() { return data_.size(); }
// TODO support dimensions of differens sizes
unsigned int BrickDim() const { return xBrickDim_; }
unsigned int PaddedBrickDim() const { return paddedBrickDim_; }
unsigned int NumBricksPerAxis() const { return xNumBricks_; }
unsigned int NumOrigTimesteps() const { return numOrigTimesteps_; }
unsigned int NumTimesteps() const { return numTimesteps_; }
unsigned int NumTotalNodes() const { return numTotalNodes_; }
unsigned int NumValuesPerNode() const { return NUM_DATA; }
unsigned int NumBSTNodes() const { return numBSTNodes_; }
unsigned int NumOTNodes() const { return numOTNodes_; }
unsigned int NumOTLevels() const { return numOTLevels_; }
private:
TSP();
TSP(Config *_config);
TSP(const TSP&);
Config *config_;
// Holds the actual structure
std::vector<int> data_;
// Data from file
unsigned int gridType_;
unsigned int numOrigTimesteps_;
unsigned int numTimesteps_;
unsigned int xBrickDim_;
unsigned int yBrickDim_;
unsigned int zBrickDim_;
unsigned int xNumBricks_;
unsigned int yNumBricks_;
unsigned int zNumBricks_;
//unsigned int dataSize_;
// Additional metadata
unsigned int paddedBrickDim_;
unsigned int numTotalNodes_;
unsigned int numBSTLevels_;
unsigned int numBSTNodes_;
unsigned int numOTLevels_;
unsigned int numOTNodes_;
const unsigned int paddingWidth_ = 1;
// Error stats
float minSpatialError_;
float maxSpatialError_;
float medianSpatialError_;
float minTemporalError_;
float maxTemporalError_;
float medianTemporalError_;
// Returns a list of the octree leaf nodes that a given input
// brick covers. If the input is already a leaf, the list will
// only contain that one index.
std::list<unsigned int> CoveredLeafBricks(unsigned int _brickIndex);
// Returns a list of the BST leaf nodes that a given input brick
// covers (at the same spatial subdivision level).
std::list<unsigned int> CoveredBSTLeafBricks(unsigned int _brickIndex);
// Return a list of eight children brick incices given a brick index
std::list<unsigned int> ChildBricks(unsigned int _brickIndex);
//std::ios::pos_type dataPos_;
// Position of first data entry (after header)
off_t dataPos_;
// Calculate weighted square distance between two RGBA colors
// c2 should be an averaged or zero color
float SquaredDist(Color _c1, Color _c2);
};
}
#endif
-24
View File
@@ -1,24 +0,0 @@
#ifndef TIMER_H_
#define TIMER_H_
/*
* Author: Victor Sand (victor.sand@gmail.com)
*
*/
namespace osp {
class Timer {
public:
Timer();
void Start();
void Stop();
void Print();
private:
float elapsedTime_;
};
}
#endif;
@@ -1,87 +0,0 @@
#ifndef TRANSFERFUNCTION_H
#define TRANSFERFUNCTION_H
/*
Author: Victor Sand (victor.sand@gmail.com)
Transfer function class that consists of a number of MappingKeys. When
the mapping keys are added, the transfer function can be constructed by
interpolating between the MappingKey values.
TODO Use Texture1D for implementation when OpenCL 1.2 is supported
*/
#include <openspace/flare/MappingKey.h>
#include <set>
#include <string>
#include <iostream>
#include <ghoul/opengl/texture.h>
namespace osp {
class TransferFunction {
public:
static TransferFunction * New();
~TransferFunction();
struct Color {
float r;
float g;
float b;
float a;
};
enum Interpolation {
LINEAR = 0,
};
// Host side sample
bool Sample(float &_r, float &_g, float &_b, float &_a, float _i);
// Take the saved values and construct a texture
bool ConstructTexture();
// Read TF from the in file
bool ReadFile();
std::string ToString() const;
// Mutators
void SetInFilename(const std::string &_inFilename);
// Accessors
unsigned int Width() const { return width_; }
ghoul::opengl::Texture * Texture() { return texture_; }
// TODO temp
float * FloatData() { return floatData_; }
// Operators
TransferFunction& operator=(const TransferFunction &_tf);
private:
TransferFunction();
TransferFunction(const TransferFunction &_tf);
float *floatData_;
ghoul::opengl::Texture *texture_;
unsigned int width_;
float lower_;
float upper_;
bool generatedTexture_;
std::string inFilename_;
std::set<MappingKey> mappingKeys_;
Interpolation interpolation_;
// Linearly interpolate between two values. Distance
// is assumed to be normalized.
inline float Lerp(float _v0, float _v1, float _d) {
return _v0*(1.0 - _d) + _v1*_d;
}
};
}
std::ostream & operator<<(std::ostream &os, const osp::TransferFunction &_tf);
#endif
-25
View File
@@ -1,25 +0,0 @@
/*
Auhtor: Victor Sand (victor.sand@gmail.com)
Global helper functions and utilities
*/
#ifndef UTILS_H_
#define UTILS_H_
#include <iostream>
namespace osp {
#define INFO(x) std::cout << x << std::endl;
#define DEBUG(x) std::cout << "DEBUG: " << x << std::endl
#define ERROR(x) std::cout << "ERROR: " << x << std::endl
#define WARNING(x) std::cout << "WARNING: " << x << std::endl
// Print the last GL error if there is one, function returns the code for
// the error so that it can be compared to GL_NO_ERROR, for example
unsigned int CheckGLError(std::string _location);
}
#endif
-94
View File
@@ -1,94 +0,0 @@
/*****************************************************************************************
* *
* OpenSpace *
* *
* Copyright (c) 2014 *
* *
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
* software and associated documentation files (the "Software"), to deal in the Software *
* without restriction, including without limitation the rights to use, copy, modify, *
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
* permit persons to whom the Software is furnished to do so, subject to the following *
* conditions: *
* *
* The above copyright notice and this permission notice shall be included in all copies *
* or substantial portions of the Software. *
* *
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
****************************************************************************************/
// Source is still in here to cannibalize later (ab)
//#ifndef __FLARE_H__
//#define __FLARE_H__
//
//#include <GL/glew.h>
//#include <ghoul/logging/logmanager.h>
//#define SGCT_WINDOWS_INCLUDE
//#include <sgct.h>
//#include <openspace/flare/Animator.h>
//#include <openspace/flare/Raycaster.h>
//#include <openspace/flare/Config.h>
//#include <openspace/rendering/renderable.h>
//
//namespace openspace {
//
//class Flare: public Renderable {
//public:
// Flare();
// ~Flare();
//
// bool initialize();
// bool deinitialize();
//
// virtual void render(const Camera *camera, const psc& thisPosition, RuntimeData* runtimeData);
// virtual void update();
//
// void render();
// void initNavigation();
//
// void keyboard(int key, int action);
// void mouse(int button, int action);
// void preSync();
// void postSyncPreDraw();
// void postDraw();
// void encode();
// void decode();
//
//private:
// void init();
//
// osp::Config* _config;
// osp::Raycaster* _raycaster;
// osp::Animator* _animator;
//
// sgct::SharedInt _timeStep;
// sgct::SharedBool _animationPaused;
// sgct::SharedBool _fpsMode;
// sgct::SharedFloat _elapsedTime;
// sgct::SharedInt _manualTimestep;
// sgct::SharedFloat _pitch;
// sgct::SharedFloat _yaw;
// sgct::SharedFloat _roll;
// sgct::SharedFloat _translateX;
// sgct::SharedFloat _translateY;
// sgct::SharedFloat _translateZ;
// sgct::SharedBool _reloadFlag;
//
// float _oldTime;
// float _currentTime;
// bool _leftMouseButton;
// double _currentMouseX;
// double _currentMouseY;
// double _lastMouseX;
// double _lastMouseY;
//};
//
//} // namespace openspace
//
//#endif // __FLARE_H__