NTrace
GPU ray tracing framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
App.hpp
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2009-2011, NVIDIA Corporation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of NVIDIA Corporation nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL <COPYRIGHT HOLDER> BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 #pragma once
29 #include "gui/Window.hpp"
30 #include "gui/CommonControls.hpp"
31 #include "3d/CameraControls.hpp"
32 #include "cuda/Renderer.hpp"
33 //#include "cuda/CudaRenderer.hpp"
34 #include "cuda/CPURenderer.hpp"
35 #include "Environment.h"
36 #include "AppEnvironment.h"
37 
38 namespace FW
39 {
40 //------------------------------------------------------------------------
41 
43 {
44 private:
45  enum Action
46  {
47  Action_None,
48 
49  Action_About,
50  Action_LoadMesh,
51 
52  Action_ResetCamera,
53  Action_ExportCameraSignature,
54  Action_ImportCameraSignature,
55  };
56 
57 public:
58  App (void);
59  virtual ~App (void);
60 
61  virtual bool handleEvent (const Window::Event& ev);
62  virtual void readState (StateDump& d);
63  virtual void writeState (StateDump& d) const;
64 
65  void setWindowSize (const Vec2i& size) { m_window.setSize(size); }
66  bool loadState (const String& fileName) { return m_commonCtrl.loadState(fileName); }
67  void loadDefaultState(void) { if (!m_commonCtrl.loadState(m_commonCtrl.getStateFileName(1))) firstTimeInit(); }
68  void flashButtonTitles(void) { m_commonCtrl.flashButtonTitles(); }
69 
70 private:
71  void rebuildGui (void);
72  void waitKey (void);
73  void render (GLContext* gl);
74  void renderGuiHelp (GLContext* gl);
75 
76  bool loadMesh (const String& fileName);
77  void resetCamera (void);
78  void firstTimeInit (void);
79 
80 private:
81  App (const App&); // forbidden
82  App& operator= (const App&); // forbidden
83 
84 private:
85  Window m_window;
86  CommonControls m_commonCtrl;
87  CameraControls m_cameraCtrl;
88  Renderer* m_renderer;
89 
90  Action m_action;
91  String m_meshFileName;
92  MeshBase* m_mesh;
93  Renderer::RayType m_rayType;
94  F32 m_aoRadius;
95  S32 m_numSamples;
96  Array<String> m_kernelNames;
97  S32 m_kernelNameIdx;
98 
99  bool m_showHelp;
100  bool m_showCameraControls;
101  bool m_showKernelSelector;
102  bool m_guiDirty;
103 
104  Environment* m_env;
105 };
106 
107 //------------------------------------------------------------------------
108 
109 void listKernels (Array<String>& kernelNames);
110 void runInteractive (const Vec2i& frameSize, const String& stateFile);
111 
112 void runBenchmark(
113  const Vec2i& frameSize,
114  const String& meshFile,
115  const Array<String>& cameras,
116  const Array<String>& kernels,
117  F32 sbvhAlpha,
118  F32 aoRadius,
119  int numSamples,
120  bool sortSecondary,
121  int warmupRepeats,
122  int measureRepeats);
123 
124 //------------------------------------------------------------------------
125 }
App(void)
Definition: App.cpp:152
void runInteractive(const Vec2i &frameSize, const String &stateFile)
Definition: App.cpp:594
void setWindowSize(const Vec2i &size)
Definition: App.hpp:65
bool loadState(const String &fileName)
virtual void readState(StateDump &d)
Definition: App.cpp:314
void loadDefaultState(void)
Definition: App.hpp:67
float F32
Definition: Defs.hpp:89
void listKernels(Array< String > &kernelNames)
Definition: App.cpp:576
virtual void writeState(StateDump &d) const
Definition: App.cpp:336
signed int S32
Definition: Defs.hpp:88
void setSize(const Vec2i &size)
Definition: Window.cpp:106
String getStateFileName(int idx) const
Environment variables class for this app.
void flashButtonTitles(void)
bool loadState(const String &fileName)
Definition: App.hpp:66
void runBenchmark(const Vec2i &frameSize, const String &meshFile, const Array< String > &cameras, const Array< String > &kernels, F32 sbvhAlpha, F32 aoRadius, int numSamples, bool sortSecondary, int warmupRepeats, int measureRepeats)
Definition: App.cpp:622
void flashButtonTitles(void)
Definition: App.hpp:68
CUdevice int ordinal char int CUdevice dev CUdevprop CUdevice dev CUcontext ctx CUcontext ctx CUcontext pctx CUmodule const void image CUmodule const void fatCubin CUfunction CUmodule const char name void p CUfunction unsigned int bytes CUtexref pTexRef CUtexref CUarray unsigned int Flags CUtexref int CUaddress_mode am CUtexref unsigned int Flags CUaddress_mode CUtexref int dim CUarray_format int CUtexref hTexRef CUfunction unsigned int numbytes CUfunction int float value CUfunction int CUtexref hTexRef CUfunction int int grid_height CUevent unsigned int Flags CUevent hEvent CUevent hEvent CUstream unsigned int Flags CUstream hStream GLuint bufferobj unsigned int CUdevice dev CUdeviceptr unsigned int CUmodule const char name CUdeviceptr unsigned int bytesize CUdeviceptr dptr void unsigned int bytesize void CUdeviceptr unsigned int ByteCount CUarray unsigned int CUdeviceptr unsigned int ByteCount CUarray unsigned int const void unsigned int ByteCount CUarray unsigned int CUarray unsigned int unsigned int ByteCount void CUarray unsigned int unsigned int CUstream hStream const CUDA_MEMCPY2D pCopy CUdeviceptr const void unsigned int CUstream hStream const CUDA_MEMCPY2D CUstream hStream CUdeviceptr unsigned char unsigned int N CUdeviceptr unsigned int unsigned int N CUdeviceptr unsigned int unsigned short unsigned int unsigned int Height CUarray const CUDA_ARRAY_DESCRIPTOR pAllocateArray CUarray const CUDA_ARRAY3D_DESCRIPTOR pAllocateArray unsigned int CUtexref CUdeviceptr unsigned int bytes CUcontext unsigned int CUdevice device GLenum texture GLenum GLuint buffer GLenum GLuint renderbuffer GLenum GLsizeiptr size
Definition: DLLImports.inl:319
virtual ~App(void)
Definition: App.cpp:200
virtual bool handleEvent(const Window::Event &ev)
Definition: App.cpp:207
Definition: App.hpp:42