2013-04-19 02:55:05 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Copyright 2013 Pixar
|
2013-04-19 02:55:05 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Licensed under the Apache License, Version 2.0 (the "Apache License")
|
|
|
|
// with the following modification; you may not use this file except in
|
|
|
|
// compliance with the Apache License and the following modification to it:
|
|
|
|
// Section 6. Trademarks. is deleted and replaced with:
|
2013-04-19 02:55:05 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// 6. Trademarks. This License does not grant permission to use the trade
|
|
|
|
// names, trademarks, service marks, or product names of the Licensor
|
|
|
|
// and its affiliates, except as required to comply with Section 4(c) of
|
|
|
|
// the License and to reproduce the content of the NOTICE file.
|
2013-04-19 02:55:05 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// You may obtain a copy of the Apache License at
|
2013-04-19 02:55:05 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// http://www.apache.org/licenses/LICENSE-2.0
|
2013-07-18 21:19:50 +00:00
|
|
|
//
|
2013-09-26 19:04:57 +00:00
|
|
|
// Unless required by applicable law or agreed to in writing, software
|
|
|
|
// distributed under the Apache License with the above modification is
|
|
|
|
// distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
|
|
// KIND, either express or implied. See the Apache License for the specific
|
|
|
|
// language governing permissions and limitations under the Apache License.
|
2013-04-19 02:55:05 +00:00
|
|
|
//
|
|
|
|
|
2015-05-30 05:33:51 +00:00
|
|
|
#include "../common/glUtils.h"
|
2013-04-19 02:55:05 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
#include <GLFW/glfw3.h>
|
|
|
|
GLFWwindow* g_window=0;
|
|
|
|
GLFWmonitor* g_primary=0;
|
2013-04-19 02:55:05 +00:00
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
#include <osd/cpuEvaluator.h>
|
2013-04-19 02:55:05 +00:00
|
|
|
#include <osd/cpuVertexBuffer.h>
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
#include <osd/cpuPatchTable.h>
|
2013-04-19 02:55:05 +00:00
|
|
|
#include <osd/cpuGLVertexBuffer.h>
|
|
|
|
#include <osd/mesh.h>
|
2015-05-09 00:31:26 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
#ifdef OPENSUBDIV_HAS_TBB
|
|
|
|
#include <osd/tbbEvaluator.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OPENSUBDIV_HAS_OPENMP
|
|
|
|
#include <osd/ompEvaluator.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OPENSUBDIV_HAS_CUDA
|
|
|
|
#include <osd/cudaEvaluator.h>
|
|
|
|
#include <osd/cudaVertexBuffer.h>
|
|
|
|
#include <osd/cudaGLVertexBuffer.h>
|
|
|
|
#include <osd/cudaPatchTable.h>
|
|
|
|
#include "../common/cudaDeviceContext.h"
|
|
|
|
|
|
|
|
CudaDeviceContext g_cudaDeviceContext;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OPENSUBDIV_HAS_OPENCL
|
|
|
|
#include <osd/clVertexBuffer.h>
|
|
|
|
#include <osd/clGLVertexBuffer.h>
|
|
|
|
#include <osd/clEvaluator.h>
|
|
|
|
#include <osd/clPatchTable.h>
|
|
|
|
#include "../common/clDeviceContext.h"
|
|
|
|
CLDeviceContext g_clDeviceContext;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
|
|
|
|
#include <osd/glXFBEvaluator.h>
|
|
|
|
#include <osd/glVertexBuffer.h>
|
|
|
|
#include <osd/glPatchTable.h>
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
|
|
|
|
#include <osd/glComputeEvaluator.h>
|
|
|
|
#include <osd/glVertexBuffer.h>
|
|
|
|
#include <osd/glPatchTable.h>
|
|
|
|
#endif
|
|
|
|
|
2015-04-18 00:36:55 +00:00
|
|
|
#include <far/topologyRefiner.h>
|
2015-05-22 18:50:01 +00:00
|
|
|
#include <far/stencilTableFactory.h>
|
|
|
|
#include <far/patchTableFactory.h>
|
2015-04-18 00:36:55 +00:00
|
|
|
|
2014-12-04 01:19:07 +00:00
|
|
|
#include <far/error.h>
|
2013-04-19 02:55:05 +00:00
|
|
|
|
2015-05-31 05:10:07 +00:00
|
|
|
#include "../../regression/common/far_utils.h"
|
2013-04-19 02:55:05 +00:00
|
|
|
#include "../common/stopwatch.h"
|
|
|
|
#include "../common/simple_math.h"
|
2015-05-19 01:04:38 +00:00
|
|
|
#include "../common/glHud.h"
|
2013-04-19 02:55:05 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
#include "init_shapes.h"
|
2014-10-01 01:53:47 +00:00
|
|
|
#include "particles.h"
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
#include <cfloat>
|
|
|
|
#include <vector>
|
2014-09-05 22:07:46 +00:00
|
|
|
#include <iostream>
|
2013-04-19 02:55:05 +00:00
|
|
|
#include <fstream>
|
|
|
|
#include <sstream>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
using namespace OpenSubdiv;
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
enum KernelType { kCPU = 0,
|
|
|
|
kOPENMP = 1,
|
|
|
|
kTBB = 2,
|
|
|
|
kCUDA = 3,
|
|
|
|
kCL = 4,
|
|
|
|
kGLXFB = 5,
|
|
|
|
kGLCompute = 6 };
|
|
|
|
|
|
|
|
enum EndCap { kEndCapBSplineBasis,
|
|
|
|
kEndCapGregoryBasis };
|
|
|
|
|
|
|
|
enum DrawMode { kUV,
|
|
|
|
kVARYING,
|
|
|
|
kNORMAL,
|
|
|
|
kSHADE,
|
|
|
|
kFACEVARYING };
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
std::vector<float> g_orgPositions,
|
2013-06-05 18:44:30 +00:00
|
|
|
g_positions,
|
|
|
|
g_varyingColors;
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
int g_currentShape = 0,
|
|
|
|
g_level = 3,
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
g_kernel = kCPU,
|
|
|
|
g_endCap = kEndCapBSplineBasis,
|
2013-04-19 02:55:05 +00:00
|
|
|
g_numElements = 3;
|
|
|
|
|
|
|
|
std::vector<int> g_coarseEdges;
|
|
|
|
std::vector<float> g_coarseEdgeSharpness;
|
|
|
|
std::vector<float> g_coarseVertexSharpness;
|
|
|
|
|
|
|
|
int g_running = 1,
|
|
|
|
g_width = 1024,
|
|
|
|
g_height = 1024,
|
|
|
|
g_fullscreen = 0,
|
|
|
|
g_drawCageEdges = 1,
|
2013-06-05 18:44:30 +00:00
|
|
|
g_drawCageVertices = 1,
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
g_drawMode = kUV,
|
2013-04-19 02:55:05 +00:00
|
|
|
g_prev_x = 0,
|
|
|
|
g_prev_y = 0,
|
|
|
|
g_mbutton[3] = {0, 0, 0},
|
|
|
|
g_frame=0,
|
|
|
|
g_freeze=0,
|
|
|
|
g_repeatCount;
|
|
|
|
|
|
|
|
float g_rotate[2] = {0, 0},
|
|
|
|
g_dolly = 5,
|
|
|
|
g_pan[2] = {0, 0},
|
|
|
|
g_center[3] = {0, 0, 0},
|
|
|
|
g_size = 0,
|
|
|
|
g_moveScale = 0.0f;
|
|
|
|
|
|
|
|
GLuint g_transformUB = 0,
|
|
|
|
g_transformBinding = 0;
|
|
|
|
|
|
|
|
struct Transform {
|
|
|
|
float ModelViewMatrix[16];
|
|
|
|
float ProjectionMatrix[16];
|
|
|
|
float ModelViewProjectionMatrix[16];
|
|
|
|
} g_transformData;
|
|
|
|
|
|
|
|
|
|
|
|
// performance
|
|
|
|
float g_evalTime = 0;
|
|
|
|
float g_computeTime = 0;
|
|
|
|
Stopwatch g_fpsTimer;
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
int g_nParticles = 65536;
|
2014-10-23 21:17:49 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
bool g_randomStart = true;//false;
|
2014-09-22 23:01:43 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
GLuint g_cageEdgeVAO = 0,
|
|
|
|
g_cageEdgeVBO = 0,
|
|
|
|
g_cageVertexVAO = 0,
|
|
|
|
g_cageVertexVBO = 0,
|
|
|
|
g_samplesVAO=0;
|
|
|
|
|
|
|
|
GLhud g_hud;
|
|
|
|
|
2015-05-22 00:45:13 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
struct Program {
|
|
|
|
GLuint program;
|
|
|
|
GLuint uniformModelViewMatrix;
|
|
|
|
GLuint uniformProjectionMatrix;
|
|
|
|
GLuint uniformDrawMode;
|
|
|
|
GLuint attrPosition;
|
|
|
|
GLuint attrColor;
|
|
|
|
GLuint attrTangentU;
|
|
|
|
GLuint attrTangentV;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
GLuint attrPatchCoord;
|
2015-05-22 00:45:13 +00:00
|
|
|
} g_defaultProgram;
|
|
|
|
|
2013-06-05 18:44:30 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2014-09-22 23:01:43 +00:00
|
|
|
static void
|
2014-10-01 01:53:47 +00:00
|
|
|
createRandomColors(int nverts, int stride, float * colors) {
|
2013-06-05 18:44:30 +00:00
|
|
|
|
|
|
|
// large Pell prime number
|
|
|
|
srand( static_cast<int>(2147483647) );
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-06-05 18:44:30 +00:00
|
|
|
for (int i=0; i<nverts; ++i) {
|
2014-10-01 01:53:47 +00:00
|
|
|
colors[i*stride+0] = (float)rand()/(float)RAND_MAX;
|
|
|
|
colors[i*stride+1] = (float)rand()/(float)RAND_MAX;
|
|
|
|
colors[i*stride+2] = (float)rand()/(float)RAND_MAX;
|
2013-06-05 18:44:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-05 22:07:46 +00:00
|
|
|
createCoarseMesh(OpenSubdiv::Far::TopologyRefiner const & refiner) {
|
|
|
|
|
2014-12-15 18:23:13 +00:00
|
|
|
typedef OpenSubdiv::Far::ConstIndexArray IndexArray;
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
// save coarse topology (used for coarse mesh drawing)
|
2015-05-22 02:52:25 +00:00
|
|
|
OpenSubdiv::Far::TopologyLevel const & refBaseLevel = refiner.GetLevel(0);
|
|
|
|
|
|
|
|
int nedges = refBaseLevel.GetNumEdges(),
|
|
|
|
nverts = refBaseLevel.GetNumVertices();
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
g_coarseEdges.resize(nedges*2);
|
|
|
|
g_coarseEdgeSharpness.resize(nedges);
|
|
|
|
g_coarseVertexSharpness.resize(nverts);
|
|
|
|
|
|
|
|
for(int i=0; i<nedges; ++i) {
|
2015-05-22 02:52:25 +00:00
|
|
|
IndexArray verts = refBaseLevel.GetEdgeVertices(i);
|
2014-09-05 22:07:46 +00:00
|
|
|
g_coarseEdges[i*2 ]=verts[0];
|
|
|
|
g_coarseEdges[i*2+1]=verts[1];
|
2015-05-22 02:52:25 +00:00
|
|
|
g_coarseEdgeSharpness[i]=refBaseLevel.GetEdgeSharpness(i);
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
for(int i=0; i<nverts; ++i) {
|
2015-05-22 02:52:25 +00:00
|
|
|
g_coarseVertexSharpness[i]=refBaseLevel.GetVertexSharpness(i);
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-06-05 18:44:30 +00:00
|
|
|
// assign a randomly generated color for each vertex ofthe mesh
|
2014-10-01 01:53:47 +00:00
|
|
|
g_varyingColors.resize(nverts*3);
|
|
|
|
createRandomColors(nverts, 3, &g_varyingColors[0]);
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
2015-05-22 18:50:01 +00:00
|
|
|
Far::PatchTable const * g_patchTable = NULL;
|
2013-04-19 02:55:05 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
// input and output vertex data
|
|
|
|
class EvalOutputBase {
|
|
|
|
public:
|
|
|
|
virtual ~EvalOutputBase() {}
|
|
|
|
virtual GLuint BindVertexData() const = 0;
|
|
|
|
virtual GLuint BindDerivatives() const = 0;
|
|
|
|
virtual GLuint BindPatchCoords() const = 0;
|
|
|
|
virtual void UpdateData(const float *src, int startVertex, int numVertices) = 0;
|
|
|
|
virtual void UpdateVaryingData(const float *src, int startVertex, int numVertices) = 0;
|
|
|
|
virtual void Refine() = 0;
|
|
|
|
virtual void EvalPatches() = 0;
|
|
|
|
virtual void EvalPatchesWithDerivatives() = 0;
|
|
|
|
virtual void EvalPatchesVarying() = 0;
|
|
|
|
virtual void UpdatePatchCoords(
|
|
|
|
std::vector<Osd::PatchCoord> const &patchCoords) = 0;
|
|
|
|
};
|
|
|
|
|
|
|
|
// note: Since we don't have a class for device-patchcoord container in osd,
|
|
|
|
// we cheat to use vertexbuffer as a patch-coord (5int) container.
|
|
|
|
//
|
|
|
|
// Please don't follow the pattern in your actual application.
|
|
|
|
//
|
|
|
|
template<typename SRC_VERTEX_BUFFER, typename EVAL_VERTEX_BUFFER,
|
|
|
|
typename STENCIL_TABLE, typename PATCH_TABLE, typename EVALUATOR,
|
|
|
|
typename DEVICE_CONTEXT = void>
|
|
|
|
class EvalOutput : public EvalOutputBase {
|
|
|
|
public:
|
|
|
|
typedef OpenSubdiv::Osd::EvaluatorCacheT<EVALUATOR> EvaluatorCache;
|
|
|
|
|
|
|
|
EvalOutput(Far::StencilTable const *vertexStencils,
|
|
|
|
Far::StencilTable const *varyingStencils,
|
|
|
|
int numCoarseVerts, int numTotalVerts, int numParticles,
|
|
|
|
Far::PatchTable const *patchTable,
|
|
|
|
EvaluatorCache *evaluatorCache = NULL,
|
|
|
|
DEVICE_CONTEXT *deviceContext = NULL)
|
|
|
|
: _srcDesc( /*offset*/ 0, /*length*/ 3, /*stride*/ 3),
|
|
|
|
_srcVaryingDesc(/*offset*/ 0, /*length*/ 3, /*stride*/ 3),
|
|
|
|
_vertexDesc( /*offset*/ 0, /*legnth*/ 3, /*stride*/ 6),
|
|
|
|
_varyingDesc( /*offset*/ 3, /*legnth*/ 3, /*stride*/ 6),
|
|
|
|
_duDesc( /*offset*/ 0, /*legnth*/ 3, /*stride*/ 6),
|
|
|
|
_dvDesc( /*offset*/ 3, /*legnth*/ 3, /*stride*/ 6),
|
|
|
|
_deviceContext(deviceContext) {
|
|
|
|
_srcData = SRC_VERTEX_BUFFER::Create(3, numTotalVerts, _deviceContext);
|
|
|
|
_srcVaryingData = SRC_VERTEX_BUFFER::Create(3, numTotalVerts, _deviceContext);
|
|
|
|
_vertexData = EVAL_VERTEX_BUFFER::Create(6, numParticles, _deviceContext);
|
|
|
|
_derivatives = EVAL_VERTEX_BUFFER::Create(6, numParticles, _deviceContext);
|
|
|
|
_patchTable = PATCH_TABLE::Create(patchTable, _deviceContext);
|
|
|
|
_patchCoords = NULL;
|
|
|
|
_numCoarseVerts = numCoarseVerts;
|
|
|
|
_vertexStencils =
|
|
|
|
Osd::convertToCompatibleStencilTable<STENCIL_TABLE>(vertexStencils, _deviceContext);
|
|
|
|
_varyingStencils =
|
|
|
|
Osd::convertToCompatibleStencilTable<STENCIL_TABLE>(varyingStencils, _deviceContext);
|
|
|
|
_evaluatorCache = evaluatorCache;
|
|
|
|
}
|
|
|
|
~EvalOutput() {
|
|
|
|
delete _srcData;
|
|
|
|
delete _srcVaryingData;
|
|
|
|
delete _vertexData;
|
|
|
|
delete _derivatives;
|
|
|
|
delete _patchTable;
|
|
|
|
delete _patchCoords;
|
2015-05-28 00:23:36 +00:00
|
|
|
delete _vertexStencils;
|
|
|
|
delete _varyingStencils;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
}
|
|
|
|
virtual GLuint BindVertexData() const {
|
|
|
|
return _vertexData->BindVBO();
|
|
|
|
}
|
|
|
|
virtual GLuint BindDerivatives() const {
|
|
|
|
return _derivatives->BindVBO();
|
|
|
|
}
|
|
|
|
virtual GLuint BindPatchCoords() const {
|
|
|
|
return _patchCoords->BindVBO();
|
|
|
|
}
|
|
|
|
virtual void UpdateData(const float *src, int startVertex, int numVertices) {
|
|
|
|
_srcData->UpdateData(src, startVertex, numVertices, _deviceContext);
|
|
|
|
}
|
|
|
|
virtual void UpdateVaryingData(const float *src, int startVertex, int numVertices) {
|
|
|
|
_srcVaryingData->UpdateData(src, startVertex, numVertices, _deviceContext);
|
|
|
|
}
|
|
|
|
virtual void Refine() {
|
2015-05-29 16:21:14 +00:00
|
|
|
Osd::BufferDescriptor dstDesc = _srcDesc;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
dstDesc.offset += _numCoarseVerts * _srcDesc.stride;
|
|
|
|
|
|
|
|
EVALUATOR const *evalInstance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
|
|
|
|
_evaluatorCache, _srcDesc, dstDesc, _deviceContext);
|
|
|
|
|
|
|
|
EVALUATOR::EvalStencils(_srcData, _srcDesc,
|
|
|
|
_srcData, dstDesc,
|
|
|
|
_vertexStencils,
|
|
|
|
evalInstance,
|
|
|
|
_deviceContext);
|
|
|
|
|
|
|
|
dstDesc = _srcVaryingDesc;
|
|
|
|
dstDesc.offset += _numCoarseVerts * _srcVaryingDesc.stride;
|
|
|
|
evalInstance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
|
|
|
|
_evaluatorCache, _srcVaryingDesc, dstDesc, _deviceContext);
|
|
|
|
|
|
|
|
EVALUATOR::EvalStencils(_srcVaryingData, _srcVaryingDesc,
|
|
|
|
_srcVaryingData, dstDesc,
|
|
|
|
_varyingStencils,
|
|
|
|
evalInstance,
|
|
|
|
_deviceContext);
|
|
|
|
}
|
|
|
|
virtual void EvalPatches() {
|
|
|
|
EVALUATOR const *evalInstance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
|
|
|
|
_evaluatorCache, _srcDesc, _vertexDesc, _deviceContext);
|
|
|
|
|
|
|
|
EVALUATOR::EvalPatches(
|
|
|
|
_srcData, _srcDesc,
|
|
|
|
_vertexData, _vertexDesc,
|
|
|
|
_patchCoords->GetNumVertices(),
|
|
|
|
_patchCoords,
|
|
|
|
_patchTable, evalInstance, _deviceContext);
|
|
|
|
}
|
|
|
|
virtual void EvalPatchesWithDerivatives() {
|
|
|
|
EVALUATOR const *evalInstance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
|
2015-05-28 00:23:36 +00:00
|
|
|
_evaluatorCache, _srcDesc, _vertexDesc, _duDesc, _dvDesc, _deviceContext);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
EVALUATOR::EvalPatches(
|
|
|
|
_srcData, _srcDesc,
|
|
|
|
_vertexData, _vertexDesc,
|
|
|
|
_derivatives, _duDesc,
|
|
|
|
_derivatives, _dvDesc,
|
|
|
|
_patchCoords->GetNumVertices(),
|
|
|
|
_patchCoords,
|
|
|
|
_patchTable, evalInstance, _deviceContext);
|
|
|
|
}
|
|
|
|
virtual void EvalPatchesVarying() {
|
|
|
|
EVALUATOR const *evalInstance = OpenSubdiv::Osd::GetEvaluator<EVALUATOR>(
|
|
|
|
_evaluatorCache, _srcVaryingDesc, _varyingDesc, _deviceContext);
|
|
|
|
|
|
|
|
EVALUATOR::EvalPatches(
|
|
|
|
_srcVaryingData, _srcVaryingDesc,
|
|
|
|
// varyingdata is interleved in vertexData.
|
|
|
|
_vertexData, _varyingDesc,
|
|
|
|
_patchCoords->GetNumVertices(),
|
|
|
|
_patchCoords,
|
|
|
|
_patchTable, evalInstance, _deviceContext);
|
|
|
|
}
|
|
|
|
virtual void UpdatePatchCoords(
|
|
|
|
std::vector<Osd::PatchCoord> const &patchCoords) {
|
|
|
|
if (_patchCoords and
|
|
|
|
_patchCoords->GetNumVertices() != (int)patchCoords.size()) {
|
|
|
|
delete _patchCoords;
|
|
|
|
_patchCoords = NULL;
|
|
|
|
}
|
|
|
|
if (not _patchCoords) {
|
|
|
|
_patchCoords = EVAL_VERTEX_BUFFER::Create(5,
|
|
|
|
(int)patchCoords.size(),
|
|
|
|
_deviceContext);
|
|
|
|
}
|
|
|
|
_patchCoords->UpdateData((float*)&patchCoords[0], 0, (int)patchCoords.size(), _deviceContext);
|
|
|
|
}
|
|
|
|
private:
|
|
|
|
SRC_VERTEX_BUFFER *_srcData;
|
|
|
|
SRC_VERTEX_BUFFER *_srcVaryingData;
|
|
|
|
EVAL_VERTEX_BUFFER *_vertexData;
|
|
|
|
EVAL_VERTEX_BUFFER *_derivatives;
|
|
|
|
EVAL_VERTEX_BUFFER *_varyingData;
|
|
|
|
EVAL_VERTEX_BUFFER *_patchCoords;
|
|
|
|
PATCH_TABLE *_patchTable;
|
2015-05-29 16:21:14 +00:00
|
|
|
Osd::BufferDescriptor _srcDesc;
|
|
|
|
Osd::BufferDescriptor _srcVaryingDesc;
|
|
|
|
Osd::BufferDescriptor _vertexDesc;
|
|
|
|
Osd::BufferDescriptor _varyingDesc;
|
|
|
|
Osd::BufferDescriptor _duDesc;
|
|
|
|
Osd::BufferDescriptor _dvDesc;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
int _numCoarseVerts;
|
|
|
|
|
|
|
|
STENCIL_TABLE const *_vertexStencils;
|
|
|
|
STENCIL_TABLE const *_varyingStencils;
|
|
|
|
|
|
|
|
EvaluatorCache *_evaluatorCache;
|
|
|
|
DEVICE_CONTEXT *_deviceContext;
|
|
|
|
};
|
|
|
|
|
|
|
|
EvalOutputBase *g_evalOutput = NULL;
|
2014-09-22 23:01:43 +00:00
|
|
|
|
2014-10-01 01:53:47 +00:00
|
|
|
STParticles * g_particles=0;
|
2014-09-22 23:01:43 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
updateGeom() {
|
|
|
|
int nverts = (int)g_orgPositions.size() / 3;
|
|
|
|
|
|
|
|
const float *p = &g_orgPositions[0];
|
|
|
|
|
|
|
|
float r = sin(g_frame*0.001f) * g_moveScale;
|
|
|
|
|
|
|
|
for (int i = 0; i < nverts; ++i) {
|
|
|
|
//float move = 0.05f*cosf(p[0]*20+g_frame*0.01f);
|
|
|
|
float ct = cos(p[2] * r);
|
|
|
|
float st = sin(p[2] * r);
|
|
|
|
g_positions[i*3+0] = p[0]*ct + p[1]*st;
|
|
|
|
g_positions[i*3+1] = -p[0]*st + p[1]*ct;
|
|
|
|
g_positions[i*3+2] = p[2];
|
|
|
|
p+=3;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Run Compute pass to pose the control vertices ---------------------------
|
|
|
|
Stopwatch s;
|
|
|
|
s.Start();
|
2014-09-05 22:07:46 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
// update coarse vertices
|
|
|
|
g_evalOutput->UpdateData(&g_positions[0], 0, nverts);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
// update coarse varying
|
|
|
|
if (g_drawMode == kVARYING) {
|
|
|
|
g_evalOutput->UpdateVaryingData(&g_varyingColors[0], 0, nverts);
|
2015-05-09 00:31:26 +00:00
|
|
|
|
|
|
|
}
|
2013-04-19 02:55:05 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
// Refine
|
|
|
|
g_evalOutput->Refine();
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
s.Stop();
|
|
|
|
g_computeTime = float(s.GetElapsed() * 1000.0f);
|
|
|
|
|
|
|
|
|
|
|
|
// Run Eval pass to get the samples locations ------------------------------
|
|
|
|
|
|
|
|
s.Start();
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-10-01 01:53:47 +00:00
|
|
|
// Apply 'dynamics' update
|
|
|
|
assert(g_particles);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
2014-10-01 01:53:47 +00:00
|
|
|
g_particles->Update(g_evalTime); // XXXX g_evalTime is not really elapsed time...
|
2014-09-22 23:01:43 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
std::vector<OpenSubdiv::Osd::PatchCoord> const &patchCoords
|
|
|
|
= g_particles->GetPatchCoords();
|
2014-10-01 01:53:47 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
// update patchcoord to be evaluated
|
|
|
|
g_evalOutput->UpdatePatchCoords(patchCoords);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-05-09 00:31:26 +00:00
|
|
|
// Evaluate the positions of the samples on the limit surface
|
2015-05-22 00:45:13 +00:00
|
|
|
if (g_drawMode == kNORMAL || g_drawMode == kSHADE) {
|
|
|
|
// evaluate positions and derivatives
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
g_evalOutput->EvalPatchesWithDerivatives();
|
2015-05-22 00:45:13 +00:00
|
|
|
} else {
|
|
|
|
// evaluate positions
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
g_evalOutput->EvalPatches();
|
2015-05-09 00:31:26 +00:00
|
|
|
}
|
2013-06-18 01:13:13 +00:00
|
|
|
|
2015-05-22 00:45:13 +00:00
|
|
|
// color
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
if (g_drawMode == kVARYING) {
|
2015-05-22 00:45:13 +00:00
|
|
|
// XXX: is this really varying?
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
g_evalOutput->EvalPatchesVarying();
|
2015-05-22 00:45:13 +00:00
|
|
|
}
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
s.Stop();
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-10-01 01:53:47 +00:00
|
|
|
g_evalTime = float(s.GetElapsed());
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-05 22:07:46 +00:00
|
|
|
createOsdMesh(ShapeDesc const & shapeDesc, int level) {
|
|
|
|
|
|
|
|
|
|
|
|
Shape * shape = Shape::parseObj(shapeDesc.data.c_str(), shapeDesc.scheme);
|
2013-04-19 02:55:05 +00:00
|
|
|
|
2015-05-31 05:10:07 +00:00
|
|
|
// create Far mesh (topology)
|
2015-01-07 01:40:11 +00:00
|
|
|
OpenSubdiv::Sdc::SchemeType sdctype = GetSdcType(*shape);
|
2014-09-05 22:07:46 +00:00
|
|
|
OpenSubdiv::Sdc::Options sdcoptions = GetSdcOptions(*shape);
|
2013-04-19 02:55:05 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
Far::TopologyRefiner *topologyRefiner =
|
2015-01-06 08:03:21 +00:00
|
|
|
OpenSubdiv::Far::TopologyRefinerFactory<Shape>::Create(*shape,
|
|
|
|
OpenSubdiv::Far::TopologyRefinerFactory<Shape>::Options(sdctype, sdcoptions));
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
g_orgPositions=shape->verts;
|
2014-10-01 01:53:47 +00:00
|
|
|
g_positions.resize(g_orgPositions.size(), 0.0f);
|
2013-04-19 02:55:05 +00:00
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
delete shape;
|
|
|
|
|
2014-10-01 01:53:47 +00:00
|
|
|
float speed = g_particles ? g_particles->GetSpeed() : 0.2f;
|
2014-09-05 22:07:46 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
createCoarseMesh(*topologyRefiner);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
Far::StencilTable const * vertexStencils = NULL;
|
|
|
|
Far::StencilTable const * varyingStencils = NULL;
|
2014-10-01 01:53:47 +00:00
|
|
|
int nverts=0;
|
2014-09-05 22:07:46 +00:00
|
|
|
{
|
2014-10-01 01:53:47 +00:00
|
|
|
// Apply feature adaptive refinement to the mesh so that we can use the
|
|
|
|
// limit evaluation API features.
|
2014-12-30 22:07:24 +00:00
|
|
|
Far::TopologyRefiner::AdaptiveOptions options(level);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
topologyRefiner->RefineAdaptive(options);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
// Generate stencil table to update the bi-cubic patches control
|
2014-10-01 01:53:47 +00:00
|
|
|
// vertices after they have been re-posed (both for vertex & varying
|
|
|
|
// interpolation)
|
2015-05-22 18:50:01 +00:00
|
|
|
Far::StencilTableFactory::Options soptions;
|
2014-11-12 01:35:52 +00:00
|
|
|
soptions.generateOffsets=true;
|
|
|
|
soptions.generateIntermediateLevels=true;
|
2014-09-05 22:07:46 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
vertexStencils =
|
|
|
|
Far::StencilTableFactory::Create(*topologyRefiner, soptions);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
soptions.interpolationMode = Far::StencilTableFactory::INTERPOLATE_VARYING;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
|
|
|
|
varyingStencils =
|
|
|
|
Far::StencilTableFactory::Create(*topologyRefiner, soptions);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
// Generate bi-cubic patch table for the limit surface
|
|
|
|
Far::PatchTableFactory::Options poptions;
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
if (g_endCap == kEndCapBSplineBasis) {
|
|
|
|
poptions.SetEndCapType(
|
|
|
|
Far::PatchTableFactory::Options::ENDCAP_BSPLINE_BASIS);
|
|
|
|
} else {
|
|
|
|
poptions.SetEndCapType(
|
|
|
|
Far::PatchTableFactory::Options::ENDCAP_GREGORY_BASIS);
|
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
Far::PatchTable const * patchTable =
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
Far::PatchTableFactory::Create(*topologyRefiner, poptions);
|
2015-04-23 23:58:45 +00:00
|
|
|
|
2015-05-29 19:41:11 +00:00
|
|
|
// append local points stencils
|
|
|
|
if (Far::StencilTable const *localPointStencilTable =
|
|
|
|
patchTable->GetLocalPointStencilTable()) {
|
2015-05-22 18:50:01 +00:00
|
|
|
Far::StencilTable const *table =
|
2015-05-29 19:41:11 +00:00
|
|
|
Far::StencilTableFactory::AppendLocalPointStencilTable(
|
|
|
|
*topologyRefiner, vertexStencils, localPointStencilTable);
|
2015-04-18 00:36:55 +00:00
|
|
|
delete vertexStencils;
|
2015-05-22 18:50:01 +00:00
|
|
|
vertexStencils = table;
|
2015-04-08 01:34:05 +00:00
|
|
|
}
|
2015-05-29 19:41:11 +00:00
|
|
|
if (Far::StencilTable const *localPointVaryingStencilTable =
|
|
|
|
patchTable->GetLocalPointVaryingStencilTable()) {
|
2015-05-22 18:50:01 +00:00
|
|
|
Far::StencilTable const *table =
|
2015-05-29 19:41:11 +00:00
|
|
|
Far::StencilTableFactory::AppendLocalPointStencilTable(
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
*topologyRefiner,
|
2015-05-29 19:41:11 +00:00
|
|
|
varyingStencils, localPointVaryingStencilTable);
|
2015-04-18 00:36:55 +00:00
|
|
|
delete varyingStencils;
|
2015-05-22 18:50:01 +00:00
|
|
|
varyingStencils = table;
|
2015-04-08 01:34:05 +00:00
|
|
|
}
|
2015-04-18 00:36:55 +00:00
|
|
|
|
|
|
|
// total number of vertices = coarse verts + refined verts + gregory basis verts
|
|
|
|
nverts = vertexStencils->GetNumControlVertices() +
|
|
|
|
vertexStencils->GetNumStencils();
|
2015-04-08 01:34:05 +00:00
|
|
|
|
2015-05-22 18:50:01 +00:00
|
|
|
if (g_patchTable) delete g_patchTable;
|
|
|
|
g_patchTable = patchTable;
|
2014-09-05 22:07:46 +00:00
|
|
|
}
|
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
// note that for patch eval we need coarse+refined combined buffer.
|
|
|
|
int nCoarseVertices = topologyRefiner->GetLevel(0).GetNumVertices();
|
|
|
|
|
|
|
|
delete g_evalOutput;
|
|
|
|
if (g_kernel == kCPU) {
|
|
|
|
g_evalOutput = new EvalOutput<Osd::CpuVertexBuffer,
|
|
|
|
Osd::CpuGLVertexBuffer,
|
|
|
|
Far::StencilTable,
|
|
|
|
Osd::CpuPatchTable,
|
|
|
|
Osd::CpuEvaluator>
|
|
|
|
(vertexStencils, varyingStencils,
|
|
|
|
nCoarseVertices, nverts, g_nParticles, g_patchTable);
|
|
|
|
#ifdef OPENSUBDIV_HAS_OPENMP
|
|
|
|
} else if (g_kernel == kOPENMP) {
|
|
|
|
g_evalOutput = new EvalOutput<Osd::CpuVertexBuffer,
|
|
|
|
Osd::CpuGLVertexBuffer,
|
|
|
|
Far::StencilTable,
|
|
|
|
Osd::CpuPatchTable,
|
|
|
|
Osd::OmpEvaluator>
|
|
|
|
(vertexStencils, varyingStencils,
|
|
|
|
nCoarseVertices, nverts, g_nParticles, g_patchTable);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_TBB
|
|
|
|
} else if (g_kernel == kTBB) {
|
|
|
|
g_evalOutput = new EvalOutput<Osd::CpuVertexBuffer,
|
|
|
|
Osd::CpuGLVertexBuffer,
|
|
|
|
Far::StencilTable,
|
|
|
|
Osd::CpuPatchTable,
|
|
|
|
Osd::TbbEvaluator>
|
|
|
|
(vertexStencils, varyingStencils,
|
|
|
|
nCoarseVertices, nverts, g_nParticles, g_patchTable);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_CUDA
|
|
|
|
} else if (g_kernel == kCUDA) {
|
|
|
|
g_evalOutput = new EvalOutput<Osd::CudaVertexBuffer,
|
|
|
|
Osd::CudaGLVertexBuffer,
|
|
|
|
Osd::CudaStencilTable,
|
|
|
|
Osd::CudaPatchTable,
|
|
|
|
Osd::CudaEvaluator>
|
|
|
|
(vertexStencils, varyingStencils,
|
|
|
|
nCoarseVertices, nverts, g_nParticles, g_patchTable);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_OPENCL
|
|
|
|
} else if (g_kernel == kCL) {
|
|
|
|
static Osd::EvaluatorCacheT<Osd::CLEvaluator> clEvaluatorCache;
|
|
|
|
g_evalOutput = new EvalOutput<Osd::CLVertexBuffer,
|
|
|
|
Osd::CLGLVertexBuffer,
|
|
|
|
Osd::CLStencilTable,
|
|
|
|
Osd::CLPatchTable,
|
|
|
|
Osd::CLEvaluator,
|
|
|
|
CLDeviceContext>
|
|
|
|
(vertexStencils, varyingStencils,
|
|
|
|
nCoarseVertices, nverts, g_nParticles, g_patchTable,
|
|
|
|
&clEvaluatorCache, &g_clDeviceContext);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
|
|
|
|
} else if (g_kernel == kGLXFB) {
|
|
|
|
static Osd::EvaluatorCacheT<Osd::GLXFBEvaluator> glXFBEvaluatorCache;
|
|
|
|
g_evalOutput = new EvalOutput<Osd::GLVertexBuffer,
|
|
|
|
Osd::GLVertexBuffer,
|
|
|
|
Osd::GLStencilTableTBO,
|
|
|
|
Osd::GLPatchTable,
|
|
|
|
Osd::GLXFBEvaluator>
|
|
|
|
(vertexStencils, varyingStencils,
|
|
|
|
nCoarseVertices, nverts, g_nParticles, g_patchTable,
|
|
|
|
&glXFBEvaluatorCache);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
|
|
|
|
} else if (g_kernel == kGLCompute) {
|
|
|
|
static Osd::EvaluatorCacheT<Osd::GLComputeEvaluator> glComputeEvaluatorCache;
|
|
|
|
g_evalOutput = new EvalOutput<Osd::GLVertexBuffer,
|
|
|
|
Osd::GLVertexBuffer,
|
|
|
|
Osd::GLStencilTableSSBO,
|
|
|
|
Osd::GLPatchTable,
|
|
|
|
Osd::GLComputeEvaluator>
|
|
|
|
(vertexStencils, varyingStencils,
|
|
|
|
nCoarseVertices, nverts, g_nParticles, g_patchTable,
|
|
|
|
&glComputeEvaluatorCache);
|
|
|
|
#endif
|
2013-06-05 18:44:30 +00:00
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
// Create the 'uv particles' manager - this class manages the limit
|
|
|
|
// location samples (ptex face index, (s,t) and updates them between frames.
|
|
|
|
// Note: the number of limit locations can be entirely arbitrary
|
|
|
|
delete g_particles;
|
|
|
|
g_particles = new STParticles(*topologyRefiner, g_patchTable,
|
|
|
|
g_nParticles, !g_randomStart);
|
|
|
|
g_nParticles = g_particles->GetNumParticles();
|
|
|
|
g_particles->SetSpeed(speed);
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
updateGeom();
|
|
|
|
|
2015-05-26 18:22:17 +00:00
|
|
|
delete topologyRefiner;
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static bool
|
2014-12-25 21:03:53 +00:00
|
|
|
linkDefaultProgram() {
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
#if defined(GL_ARB_tessellation_shader) || defined(GL_VERSION_4_0)
|
|
|
|
#define GLSL_VERSION_DEFINE "#version 400\n"
|
|
|
|
#else
|
|
|
|
#define GLSL_VERSION_DEFINE "#version 150\n"
|
|
|
|
#endif
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
static const char *vsSrc =
|
|
|
|
GLSL_VERSION_DEFINE
|
|
|
|
"in vec3 position;\n"
|
|
|
|
"in vec3 color;\n"
|
2015-05-22 00:45:13 +00:00
|
|
|
"in vec3 tangentU;\n"
|
|
|
|
"in vec3 tangentV;\n"
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
"in vec2 patchCoord;\n"
|
2013-04-19 02:55:05 +00:00
|
|
|
"out vec4 fragColor;\n"
|
2015-05-22 00:45:13 +00:00
|
|
|
"uniform mat4 ModelViewMatrix;\n"
|
|
|
|
"uniform mat4 ProjectionMatrix;\n"
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
"uniform int DrawMode;\n"
|
2013-04-19 02:55:05 +00:00
|
|
|
"void main() {\n"
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
" vec3 normal = (ModelViewMatrix * "
|
|
|
|
" vec4(normalize(cross(tangentU, tangentV)), 0)).xyz;\n"
|
2015-05-22 00:45:13 +00:00
|
|
|
" gl_Position = ProjectionMatrix * ModelViewMatrix * "
|
2013-04-19 02:55:05 +00:00
|
|
|
" vec4(position, 1);\n"
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
" if (DrawMode == 0) {\n" // UV
|
|
|
|
" fragColor = vec4(patchCoord.x, patchCoord.y, 0, 1);\n"
|
|
|
|
" } else if (DrawMode == 2) {\n"
|
|
|
|
" fragColor = vec4(normal*0.5+vec3(0.5), 1);\n"
|
|
|
|
" } else if (DrawMode == 3) {\n"
|
|
|
|
" fragColor = vec4(vec3(1)*dot(normal, vec3(0,0,1)), 1);\n"
|
2015-05-28 00:23:36 +00:00
|
|
|
" } else if (DrawMode == 4) {\n" // face varying
|
|
|
|
" fragColor = vec4(1);\n"
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
" } else {\n" // varying
|
|
|
|
" fragColor = vec4(color, 1);\n"
|
|
|
|
" }\n"
|
2013-04-19 02:55:05 +00:00
|
|
|
"}\n";
|
|
|
|
|
|
|
|
static const char *fsSrc =
|
|
|
|
GLSL_VERSION_DEFINE
|
|
|
|
"in vec4 fragColor;\n"
|
|
|
|
"out vec4 color;\n"
|
|
|
|
"void main() {\n"
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
" color = fragColor;\n"
|
2013-04-19 02:55:05 +00:00
|
|
|
"}\n";
|
|
|
|
|
|
|
|
GLuint program = glCreateProgram();
|
2015-05-22 00:45:13 +00:00
|
|
|
GLuint vertexShader = GLUtils::CompileShader(GL_VERTEX_SHADER, vsSrc);
|
|
|
|
GLuint fragmentShader = GLUtils::CompileShader(GL_FRAGMENT_SHADER, fsSrc);
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
glAttachShader(program, vertexShader);
|
|
|
|
glAttachShader(program, fragmentShader);
|
|
|
|
|
2013-05-22 19:36:21 +00:00
|
|
|
glBindAttribLocation(program, 0, "position");
|
|
|
|
glBindAttribLocation(program, 1, "color");
|
2015-05-22 00:45:13 +00:00
|
|
|
glBindAttribLocation(program, 2, "tangentU");
|
|
|
|
glBindAttribLocation(program, 3, "tangentV");
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
glBindAttribLocation(program, 4, "patchCoord");
|
2013-05-22 19:36:21 +00:00
|
|
|
glBindFragDataLocation(program, 0, "color");
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
glLinkProgram(program);
|
|
|
|
|
|
|
|
GLint status;
|
|
|
|
glGetProgramiv(program, GL_LINK_STATUS, &status);
|
|
|
|
if (status == GL_FALSE) {
|
|
|
|
GLint infoLogLength;
|
|
|
|
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
|
|
|
|
char *infoLog = new char[infoLogLength];
|
|
|
|
glGetProgramInfoLog(program, infoLogLength, NULL, infoLog);
|
|
|
|
printf("%s\n", infoLog);
|
|
|
|
delete[] infoLog;
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
|
|
|
|
g_defaultProgram.program = program;
|
2015-05-22 00:45:13 +00:00
|
|
|
g_defaultProgram.uniformModelViewMatrix =
|
|
|
|
glGetUniformLocation(program, "ModelViewMatrix");
|
|
|
|
g_defaultProgram.uniformProjectionMatrix =
|
|
|
|
glGetUniformLocation(program, "ProjectionMatrix");
|
|
|
|
g_defaultProgram.uniformDrawMode =
|
|
|
|
glGetUniformLocation(program, "DrawMode");
|
2013-04-19 02:55:05 +00:00
|
|
|
g_defaultProgram.attrPosition = glGetAttribLocation(program, "position");
|
|
|
|
g_defaultProgram.attrColor = glGetAttribLocation(program, "color");
|
2015-05-22 00:45:13 +00:00
|
|
|
g_defaultProgram.attrTangentU = glGetAttribLocation(program, "tangentU");
|
|
|
|
g_defaultProgram.attrTangentV = glGetAttribLocation(program, "tangentV");
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
g_defaultProgram.attrPatchCoord = glGetAttribLocation(program, "patchCoord");
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static inline void
|
2014-12-25 21:03:53 +00:00
|
|
|
setSharpnessColor(float s, float *r, float *g, float *b) {
|
2013-04-19 02:55:05 +00:00
|
|
|
// 0.0 2.0 4.0
|
|
|
|
// green --- yellow --- red
|
|
|
|
*r = std::min(1.0f, s * 0.5f);
|
|
|
|
*g = std::min(1.0f, 2.0f - s*0.5f);
|
|
|
|
*b = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
drawCageEdges() {
|
|
|
|
|
|
|
|
glUseProgram(g_defaultProgram.program);
|
2015-05-22 00:45:13 +00:00
|
|
|
glUniformMatrix4fv(g_defaultProgram.uniformModelViewMatrix,
|
|
|
|
1, GL_FALSE, g_transformData.ModelViewMatrix);
|
|
|
|
glUniformMatrix4fv(g_defaultProgram.uniformProjectionMatrix,
|
|
|
|
1, GL_FALSE, g_transformData.ProjectionMatrix);
|
|
|
|
glUniform1i(g_defaultProgram.uniformDrawMode, 0);
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
std::vector<float> vbo;
|
|
|
|
vbo.reserve(g_coarseEdges.size() * 6);
|
|
|
|
float r, g, b;
|
|
|
|
for (int i = 0; i < (int)g_coarseEdges.size(); i+=2) {
|
|
|
|
setSharpnessColor(g_coarseEdgeSharpness[i/2], &r, &g, &b);
|
|
|
|
for (int j = 0; j < 2; ++j) {
|
|
|
|
vbo.push_back(g_positions[g_coarseEdges[i+j]*3]);
|
|
|
|
vbo.push_back(g_positions[g_coarseEdges[i+j]*3+1]);
|
|
|
|
vbo.push_back(g_positions[g_coarseEdges[i+j]*3+2]);
|
|
|
|
vbo.push_back(r);
|
|
|
|
vbo.push_back(g);
|
|
|
|
vbo.push_back(b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
glBindVertexArray(g_cageEdgeVAO);
|
|
|
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, g_cageEdgeVBO);
|
|
|
|
glBufferData(GL_ARRAY_BUFFER, (int)vbo.size() * sizeof(float), &vbo[0],
|
|
|
|
GL_STATIC_DRAW);
|
|
|
|
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrPosition);
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrColor);
|
2015-05-22 00:45:13 +00:00
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrTangentU);
|
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrTangentV);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrPatchCoord);
|
2013-04-19 02:55:05 +00:00
|
|
|
glVertexAttribPointer(g_defaultProgram.attrPosition,
|
|
|
|
3, GL_FLOAT, GL_FALSE, sizeof (GLfloat) * 6, 0);
|
|
|
|
glVertexAttribPointer(g_defaultProgram.attrColor,
|
|
|
|
3, GL_FLOAT, GL_FALSE, sizeof (GLfloat) * 6, (void*)12);
|
|
|
|
|
|
|
|
glDrawArrays(GL_LINES, 0, (int)g_coarseEdges.size());
|
|
|
|
|
|
|
|
glBindVertexArray(0);
|
|
|
|
glUseProgram(0);
|
2014-09-05 22:07:46 +00:00
|
|
|
}
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
drawCageVertices() {
|
|
|
|
|
|
|
|
glUseProgram(g_defaultProgram.program);
|
2015-05-22 00:45:13 +00:00
|
|
|
glUniformMatrix4fv(g_defaultProgram.uniformModelViewMatrix,
|
|
|
|
1, GL_FALSE, g_transformData.ModelViewMatrix);
|
|
|
|
glUniformMatrix4fv(g_defaultProgram.uniformProjectionMatrix,
|
|
|
|
1, GL_FALSE, g_transformData.ProjectionMatrix);
|
|
|
|
glUniform1i(g_defaultProgram.uniformDrawMode, 0);
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
int numPoints = (int)g_positions.size()/3;
|
|
|
|
std::vector<float> vbo;
|
|
|
|
vbo.reserve(numPoints*6);
|
|
|
|
float r, g, b;
|
|
|
|
for (int i = 0; i < numPoints; ++i) {
|
2013-06-05 18:44:30 +00:00
|
|
|
|
|
|
|
switch (g_drawMode) {
|
|
|
|
|
|
|
|
case kVARYING : { r=g_varyingColors[i*3+0];
|
|
|
|
g=g_varyingColors[i*3+1];
|
2014-09-05 22:07:46 +00:00
|
|
|
b=g_varyingColors[i*3+2];
|
2013-06-05 18:44:30 +00:00
|
|
|
} break;
|
|
|
|
|
|
|
|
case kUV : { setSharpnessColor(g_coarseVertexSharpness[i], &r, &g, &b);
|
|
|
|
} break;
|
|
|
|
|
|
|
|
default : break;
|
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
vbo.push_back(g_positions[i*3+0]);
|
|
|
|
vbo.push_back(g_positions[i*3+1]);
|
|
|
|
vbo.push_back(g_positions[i*3+2]);
|
|
|
|
vbo.push_back(r);
|
|
|
|
vbo.push_back(g);
|
|
|
|
vbo.push_back(b);
|
|
|
|
}
|
|
|
|
|
|
|
|
glBindVertexArray(g_cageVertexVAO);
|
|
|
|
|
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, g_cageVertexVBO);
|
|
|
|
glBufferData(GL_ARRAY_BUFFER, (int)vbo.size() * sizeof(float), &vbo[0],
|
|
|
|
GL_STATIC_DRAW);
|
|
|
|
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrPosition);
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrColor);
|
2015-05-22 00:45:13 +00:00
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrTangentU);
|
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrTangentV);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrPatchCoord);
|
2013-04-19 02:55:05 +00:00
|
|
|
glVertexAttribPointer(g_defaultProgram.attrPosition,
|
|
|
|
3, GL_FLOAT, GL_FALSE, sizeof (GLfloat) * 6, 0);
|
|
|
|
glVertexAttribPointer(g_defaultProgram.attrColor,
|
|
|
|
3, GL_FLOAT, GL_FALSE, sizeof (GLfloat) * 6, (void*)12);
|
|
|
|
|
|
|
|
glPointSize(10.0f);
|
|
|
|
glDrawArrays(GL_POINTS, 0, numPoints);
|
|
|
|
glPointSize(1.0f);
|
|
|
|
|
|
|
|
glBindVertexArray(0);
|
|
|
|
glUseProgram(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
drawSamples() {
|
|
|
|
glUseProgram(g_defaultProgram.program);
|
|
|
|
|
2015-05-22 00:45:13 +00:00
|
|
|
glUniformMatrix4fv(g_defaultProgram.uniformModelViewMatrix,
|
|
|
|
1, GL_FALSE, g_transformData.ModelViewMatrix);
|
|
|
|
glUniformMatrix4fv(g_defaultProgram.uniformProjectionMatrix,
|
|
|
|
1, GL_FALSE, g_transformData.ProjectionMatrix);
|
|
|
|
glUniform1i(g_defaultProgram.uniformDrawMode, g_drawMode);
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
glBindVertexArray(g_samplesVAO);
|
|
|
|
|
2015-05-22 00:45:13 +00:00
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrPosition);
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrColor);
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrTangentU);
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrTangentV);
|
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, g_evalOutput->BindVertexData());
|
2015-05-22 00:45:13 +00:00
|
|
|
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof (GLfloat) * 6, 0);
|
|
|
|
glVertexAttribPointer(1, 3, GL_FLOAT, GL_FALSE, sizeof (GLfloat) * 6, (float*)12);
|
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, g_evalOutput->BindDerivatives());
|
2015-05-22 00:45:13 +00:00
|
|
|
glVertexAttribPointer(2, 3, GL_FLOAT, GL_FALSE, sizeof (GLfloat) * 6, 0);
|
|
|
|
glVertexAttribPointer(3, 3, GL_FLOAT, GL_FALSE, sizeof (GLfloat) * 6, (float*)12);
|
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
glBindBuffer(GL_ARRAY_BUFFER, g_evalOutput->BindPatchCoords());
|
|
|
|
glVertexAttribPointer(4, 2, GL_FLOAT, GL_FALSE, sizeof (GLfloat) * 5, (float*)12);
|
|
|
|
|
2015-05-22 00:45:13 +00:00
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrPosition);
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrColor);
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrTangentU);
|
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrTangentV);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
glEnableVertexAttribArray(g_defaultProgram.attrPatchCoord);
|
2015-05-22 00:45:13 +00:00
|
|
|
|
2014-10-01 01:53:47 +00:00
|
|
|
glPointSize(2.0f);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
int nPatchCoords = (int)g_particles->GetPatchCoords().size();
|
|
|
|
glDrawArrays(GL_POINTS, 0, nPatchCoords);
|
2013-04-19 02:55:05 +00:00
|
|
|
glPointSize(1.0f);
|
|
|
|
|
2015-05-22 00:45:13 +00:00
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrPosition);
|
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrColor);
|
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrTangentU);
|
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrTangentV);
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
glDisableVertexAttribArray(g_defaultProgram.attrPatchCoord);
|
2015-05-22 00:45:13 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
glBindVertexArray(0);
|
|
|
|
|
|
|
|
glUseProgram(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
display() {
|
2014-09-10 20:46:26 +00:00
|
|
|
|
|
|
|
g_hud.GetFrameBuffer()->Bind();
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
Stopwatch s;
|
|
|
|
s.Start();
|
|
|
|
|
|
|
|
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
|
|
|
|
|
|
|
|
glViewport(0, 0, g_width, g_height);
|
|
|
|
|
|
|
|
double aspect = g_width/(double)g_height;
|
|
|
|
identity(g_transformData.ModelViewMatrix);
|
|
|
|
translate(g_transformData.ModelViewMatrix, -g_pan[0], -g_pan[1], -g_dolly);
|
|
|
|
rotate(g_transformData.ModelViewMatrix, g_rotate[1], 1, 0, 0);
|
|
|
|
rotate(g_transformData.ModelViewMatrix, g_rotate[0], 0, 1, 0);
|
|
|
|
rotate(g_transformData.ModelViewMatrix, -90, 1, 0, 0);
|
|
|
|
translate(g_transformData.ModelViewMatrix,
|
|
|
|
-g_center[0], -g_center[1], -g_center[2]);
|
|
|
|
perspective(g_transformData.ProjectionMatrix,
|
|
|
|
45.0f, (float)aspect, 0.01f, 500.0f);
|
|
|
|
multMatrix(g_transformData.ModelViewProjectionMatrix,
|
|
|
|
g_transformData.ModelViewMatrix,
|
|
|
|
g_transformData.ProjectionMatrix);
|
|
|
|
|
2014-10-01 01:53:47 +00:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
s.Stop();
|
|
|
|
float drawCpuTime = float(s.GetElapsed() * 1000.0f);
|
|
|
|
s.Start();
|
|
|
|
glFinish();
|
|
|
|
s.Stop();
|
|
|
|
float drawGpuTime = float(s.GetElapsed() * 1000.0f);
|
|
|
|
|
|
|
|
drawSamples();
|
|
|
|
|
|
|
|
if (g_drawCageEdges)
|
|
|
|
drawCageEdges();
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
if (g_drawCageVertices)
|
|
|
|
drawCageVertices();
|
|
|
|
|
2014-09-10 20:46:26 +00:00
|
|
|
g_hud.GetFrameBuffer()->ApplyImageShader();
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
if (g_hud.IsVisible()) {
|
|
|
|
g_fpsTimer.Stop();
|
|
|
|
double fps = 1.0/g_fpsTimer.GetElapsed();
|
|
|
|
g_fpsTimer.Start();
|
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
int nPatchCoords = (int)g_particles->GetPatchCoords().size();
|
|
|
|
|
2014-10-01 01:53:47 +00:00
|
|
|
g_hud.DrawString(10, -150, "Particle Speed ([) (]): %.1f", g_particles->GetSpeed());
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
g_hud.DrawString(10, -120, "# Samples : (%d / %d)", nPatchCoords, g_nParticles);
|
2013-04-19 02:55:05 +00:00
|
|
|
g_hud.DrawString(10, -100, "Compute : %.3f ms", g_computeTime);
|
2014-10-01 01:53:47 +00:00
|
|
|
g_hud.DrawString(10, -80, "Eval : %.3f ms", g_evalTime * 1000.f);
|
2013-04-19 02:55:05 +00:00
|
|
|
g_hud.DrawString(10, -60, "GPU Draw : %.3f ms", drawGpuTime);
|
|
|
|
g_hud.DrawString(10, -40, "CPU Draw : %.3f ms", drawCpuTime);
|
|
|
|
g_hud.DrawString(10, -20, "FPS : %3.1f", fps);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
if (g_drawMode==kFACEVARYING) {
|
|
|
|
static char msg[] = "Face-varying interpolation not implemented yet";
|
2013-06-08 00:53:23 +00:00
|
|
|
g_hud.DrawString(g_width/2-20/2*8, g_height/2, msg);
|
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
g_hud.Flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
glFinish();
|
|
|
|
|
2015-05-30 05:33:51 +00:00
|
|
|
GLUtils::CheckGLErrors("display leave");
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
idle() {
|
|
|
|
|
|
|
|
if (not g_freeze)
|
|
|
|
g_frame++;
|
|
|
|
|
|
|
|
updateGeom();
|
|
|
|
|
|
|
|
if (g_repeatCount != 0 and g_frame >= g_repeatCount)
|
|
|
|
g_running = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
motion(GLFWwindow *, double dx, double dy) {
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
int x=(int)dx, y=(int)dy;
|
|
|
|
|
|
|
|
if (g_mbutton[0] && !g_mbutton[1] && !g_mbutton[2]) {
|
|
|
|
// orbit
|
|
|
|
g_rotate[0] += x - g_prev_x;
|
|
|
|
g_rotate[1] += y - g_prev_y;
|
|
|
|
} else if (!g_mbutton[0] && !g_mbutton[1] && g_mbutton[2]) {
|
|
|
|
// pan
|
|
|
|
g_pan[0] -= g_dolly*(x - g_prev_x)/g_width;
|
|
|
|
g_pan[1] += g_dolly*(y - g_prev_y)/g_height;
|
|
|
|
} else if ((g_mbutton[0] && !g_mbutton[1] && g_mbutton[2]) or
|
|
|
|
(!g_mbutton[0] && g_mbutton[1] && !g_mbutton[2])) {
|
|
|
|
// dolly
|
|
|
|
g_dolly -= g_dolly*0.01f*(x - g_prev_x);
|
|
|
|
if(g_dolly <= 0.01) g_dolly = 0.01f;
|
|
|
|
}
|
|
|
|
|
|
|
|
g_prev_x = x;
|
|
|
|
g_prev_y = y;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-05-15 20:34:32 +00:00
|
|
|
mouse(GLFWwindow *, int button, int state, int /* mods */) {
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
if (button == 0 && state == GLFW_PRESS && g_hud.MouseClick(g_prev_x, g_prev_y))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (button < 3) {
|
|
|
|
g_mbutton[button] = (state == GLFW_PRESS);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
reshape(GLFWwindow *, int width, int height) {
|
|
|
|
|
|
|
|
g_width = width;
|
|
|
|
g_height = height;
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-02-22 03:25:00 +00:00
|
|
|
int windowWidth = g_width, windowHeight = g_height;
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-02-22 03:25:00 +00:00
|
|
|
// window size might not match framebuffer size on a high DPI display
|
|
|
|
glfwGetWindowSize(g_window, &windowWidth, &windowHeight);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-10-24 18:15:19 +00:00
|
|
|
g_hud.Rebuild(windowWidth, windowHeight, width, height);
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
void windowClose(GLFWwindow*) {
|
|
|
|
g_running = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
setSamples(bool add) {
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
if (add) {
|
|
|
|
g_nParticles = g_nParticles * 2;
|
|
|
|
} else {
|
|
|
|
g_nParticles = std::max(1, g_nParticles / 2);
|
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-05-15 20:34:32 +00:00
|
|
|
keyboard(GLFWwindow *, int key, int /* scancode */, int event, int /* mods */) {
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
if (event == GLFW_RELEASE) return;
|
|
|
|
if (g_hud.KeyDown(tolower(key))) return;
|
|
|
|
|
|
|
|
switch (key) {
|
|
|
|
case 'Q': g_running = 0; break;
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
case '=': setSamples(true); break;
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
case '-': setSamples(false); break;
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-11-25 20:41:19 +00:00
|
|
|
case '[': if (g_particles) {
|
2014-10-01 01:53:47 +00:00
|
|
|
g_particles->SetSpeed(g_particles->GetSpeed()-0.1f);
|
|
|
|
} break;
|
2014-11-25 20:41:19 +00:00
|
|
|
case ']': if (g_particles) {
|
2014-10-01 01:53:47 +00:00
|
|
|
g_particles->SetSpeed(g_particles->GetSpeed()+0.1f);
|
|
|
|
} break;
|
2014-09-22 23:01:43 +00:00
|
|
|
|
2013-06-20 18:53:33 +00:00
|
|
|
case GLFW_KEY_ESCAPE: g_hud.SetVisible(!g_hud.IsVisible()); break;
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-12-04 01:19:07 +00:00
|
|
|
callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
|
|
|
printf("Error: %d\n", err);
|
2013-04-19 02:55:05 +00:00
|
|
|
printf("%s", message);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
callbackModel(int m) {
|
2013-04-19 02:55:05 +00:00
|
|
|
if (m < 0)
|
|
|
|
m = 0;
|
|
|
|
|
|
|
|
if (m >= (int)g_defaultShapes.size())
|
|
|
|
m = (int)g_defaultShapes.size() - 1;
|
|
|
|
|
|
|
|
g_currentShape = m;
|
2014-09-05 22:07:46 +00:00
|
|
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
callbackEndCap(int endCap) {
|
|
|
|
g_endCap = endCap;
|
|
|
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
callbackKernel(int k) {
|
|
|
|
|
|
|
|
g_kernel = k;
|
|
|
|
|
|
|
|
#ifdef OPENSUBDIV_HAS_OPENCL
|
|
|
|
if (g_kernel == kCL and (not g_clDeviceContext.IsInitialized())) {
|
|
|
|
if (g_clDeviceContext.Initialize() == false) {
|
|
|
|
printf("Error in initializing OpenCL\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_CUDA
|
|
|
|
if (g_kernel == kCUDA and (not g_cudaDeviceContext.IsInitialized())) {
|
|
|
|
if (g_cudaDeviceContext.Initialize() == false) {
|
|
|
|
printf("Error in initializing Cuda\n");
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
callbackLevel(int l) {
|
2013-04-19 02:55:05 +00:00
|
|
|
g_level = l;
|
2014-09-05 22:07:46 +00:00
|
|
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
callbackAnimate(bool checked, int /* m */) {
|
|
|
|
g_moveScale = checked * 3.0f;
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
callbackFreeze(bool checked, int /* f */) {
|
2013-04-19 02:55:05 +00:00
|
|
|
g_freeze = checked;
|
|
|
|
}
|
|
|
|
|
2014-10-01 01:53:47 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
callbackCentered(bool checked, int /* f */) {
|
2015-05-12 23:13:57 +00:00
|
|
|
g_randomStart = checked;
|
2014-10-01 01:53:47 +00:00
|
|
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
|
|
|
}
|
|
|
|
|
2013-06-05 18:44:30 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
callbackDisplayCageVertices(bool checked, int /* d */) {
|
2013-06-05 18:44:30 +00:00
|
|
|
g_drawCageVertices = checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
callbackDisplayCageEdges(bool checked, int /* d */) {
|
2013-06-05 18:44:30 +00:00
|
|
|
g_drawCageEdges = checked;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
callbackDisplayVaryingColors(int mode) {
|
2013-06-05 18:44:30 +00:00
|
|
|
g_drawMode = mode;
|
2014-09-05 22:07:46 +00:00
|
|
|
createOsdMesh(g_defaultShapes[g_currentShape], g_level);
|
2013-06-05 18:44:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
initHUD() {
|
2014-09-10 20:46:26 +00:00
|
|
|
int windowWidth = g_width, windowHeight = g_height,
|
|
|
|
frameBufferWidth = g_width, frameBufferHeight = g_height;
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-02-22 03:25:00 +00:00
|
|
|
// window size might not match framebuffer size on a high DPI display
|
|
|
|
glfwGetWindowSize(g_window, &windowWidth, &windowHeight);
|
2014-09-10 20:46:26 +00:00
|
|
|
glfwGetFramebufferSize(g_window, &frameBufferWidth, &frameBufferHeight);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2014-10-24 18:15:19 +00:00
|
|
|
g_hud.Init(windowWidth, windowHeight, frameBufferWidth, frameBufferHeight);
|
2013-04-19 02:55:05 +00:00
|
|
|
|
2014-09-10 20:46:26 +00:00
|
|
|
g_hud.SetFrameBuffer(new GLFrameBuffer);
|
|
|
|
|
2014-04-28 17:10:10 +00:00
|
|
|
g_hud.AddCheckBox("Cage Edges (H)", true, 10, 10, callbackDisplayCageEdges, 0, 'h');
|
|
|
|
g_hud.AddCheckBox("Cage Verts (J)", true, 10, 30, callbackDisplayCageVertices, 0, 'j');
|
|
|
|
g_hud.AddCheckBox("Animate vertices (M)", g_moveScale != 0, 10, 50, callbackAnimate, 0, 'm');
|
|
|
|
g_hud.AddCheckBox("Freeze (spc)", false, 10, 70, callbackFreeze, 0, ' ');
|
2014-09-05 22:07:46 +00:00
|
|
|
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
g_hud.AddCheckBox("Random Start", g_randomStart, 10, 120, callbackCentered, 0);
|
|
|
|
|
|
|
|
int compute_pulldown = g_hud.AddPullDown("Compute (K)", 475, 10, 300,
|
|
|
|
callbackKernel, 'k');
|
|
|
|
g_hud.AddPullDownButton(compute_pulldown, "CPU", kCPU);
|
|
|
|
#ifdef OPENSUBDIV_HAS_OPENMP
|
|
|
|
g_hud.AddPullDownButton(compute_pulldown, "OPENMP", kOPENMP);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_TBB
|
|
|
|
g_hud.AddPullDownButton(compute_pulldown, "TBB", kTBB);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_CUDA
|
|
|
|
g_hud.AddPullDownButton(compute_pulldown, "CUDA", kCUDA);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_OPENCL
|
|
|
|
g_hud.AddPullDownButton(compute_pulldown, "OpenCL", kCL);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
|
|
|
|
g_hud.AddPullDownButton(compute_pulldown, "GL XFB", kGLXFB);
|
|
|
|
#endif
|
|
|
|
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
|
2015-05-28 15:43:05 +00:00
|
|
|
if (GLUtils::GL_ARBComputeShaderOrGL_VERSION_4_3()) {
|
|
|
|
g_hud.AddPullDownButton(compute_pulldown, "GL Compute", kGLCompute);
|
|
|
|
}
|
Osd API refactor: EvalStencils and EvalPatches
Add EvalStencils and EvalPatches API for most of CPU and GPU evaluators.
with this change, Eval API in the osd layer consists of following parts:
- Evaluators (Cpu, Omp, Tbb, Cuda, CL, GLXFB, GLCompute, D3D11Compute)
implements EvalStencils and EvalPatches(*). Both supports derivatives
(not fully implemented though)
- Interop vertex buffer classes (optional, same as before)
Note that these classes are not necessary to use Evaluators.
All evaluators have EvalStencils/Patches which take device-specific
buffer objects. For example, GLXFBEvaluator can take GLuint directly
for both stencil tables and input primvars. Although using these
interop classes makes it easy to integrate osd into relatively
simple applications.
- device-dependent StencilTable and PatchTable (optional)
These are also optional, but can be used simply a substitute of
Far::StencilTable and Far::PatchTable for osd evaluators.
- PatchArray, PatchCoord, PatchParam
They are tiny structs used for GPU based patch evaluation.
(*) TODO and known issues:
- CLEvaluator and D3D11Evaluator's EvalPatches() have not been implemented.
- GPU Gregory patch evaluation has not been implemented in EvalPatches().
- CudaEvaluator::EvalPatches() is very unstable.
- All patch evaluation kernels have not been well optimized.
- Currently GLXFB kernel doesn't support derivative evaluation.
There's a technical difficulty for the multi-stream output.
2015-05-26 04:51:55 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
int endcap_pulldown = g_hud.AddPullDown("End cap (E)", 10, 140, 200,
|
|
|
|
callbackEndCap, 'e');
|
|
|
|
g_hud.AddPullDownButton(endcap_pulldown, "BSpline",
|
|
|
|
kEndCapBSplineBasis,
|
|
|
|
g_endCap == kEndCapBSplineBasis);
|
|
|
|
g_hud.AddPullDownButton(endcap_pulldown, "GregoryBasis",
|
|
|
|
kEndCapGregoryBasis,
|
|
|
|
g_endCap == kEndCapGregoryBasis);
|
2014-10-01 01:53:47 +00:00
|
|
|
|
2014-04-28 23:36:39 +00:00
|
|
|
int shading_pulldown = g_hud.AddPullDown("Shading (W)", 250, 10, 250, callbackDisplayVaryingColors, 'w');
|
|
|
|
g_hud.AddPullDownButton(shading_pulldown, "(u,v)", kUV, g_drawMode==kUV);
|
|
|
|
g_hud.AddPullDownButton(shading_pulldown, "Varying", kVARYING, g_drawMode==kVARYING);
|
2015-05-22 00:45:13 +00:00
|
|
|
g_hud.AddPullDownButton(shading_pulldown, "Normal", kNORMAL, g_drawMode==kNORMAL);
|
|
|
|
g_hud.AddPullDownButton(shading_pulldown, "Shade", kSHADE, g_drawMode==kSHADE);
|
2014-04-28 23:36:39 +00:00
|
|
|
g_hud.AddPullDownButton(shading_pulldown, "FaceVarying", kFACEVARYING, g_drawMode==kFACEVARYING);
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
for (int i = 1; i < 11; ++i) {
|
|
|
|
char level[16];
|
|
|
|
sprintf(level, "Lv. %d", i);
|
|
|
|
g_hud.AddRadioButton(3, level, i==g_level, 10, 170+i*20, callbackLevel, i, '0'+(i%10));
|
|
|
|
}
|
|
|
|
|
2014-04-28 23:36:39 +00:00
|
|
|
int pulldown_handle = g_hud.AddPullDown("Shape (N)", -300, 10, 300, callbackModel, 'n');
|
2013-04-19 02:55:05 +00:00
|
|
|
for (int i = 0; i < (int)g_defaultShapes.size(); ++i) {
|
2014-04-28 06:05:18 +00:00
|
|
|
g_hud.AddPullDownButton(pulldown_handle, g_defaultShapes[i].name.c_str(),i);
|
2014-09-05 22:07:46 +00:00
|
|
|
}
|
2014-09-10 22:29:24 +00:00
|
|
|
|
2014-10-24 18:15:19 +00:00
|
|
|
g_hud.Rebuild(windowWidth, windowHeight, frameBufferWidth, frameBufferHeight);
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
2014-09-22 23:01:43 +00:00
|
|
|
initGL() {
|
|
|
|
|
2014-09-10 20:46:26 +00:00
|
|
|
glClearColor(0.1f, 0.1f, 0.1f, 0.0f);
|
2013-04-19 02:55:05 +00:00
|
|
|
glEnable(GL_DEPTH_TEST);
|
|
|
|
glDepthFunc(GL_LEQUAL);
|
|
|
|
glCullFace(GL_BACK);
|
|
|
|
glEnable(GL_CULL_FACE);
|
|
|
|
|
|
|
|
glGenVertexArrays(1, &g_cageVertexVAO);
|
|
|
|
glGenVertexArrays(1, &g_cageEdgeVAO);
|
|
|
|
glGenVertexArrays(1, &g_samplesVAO);
|
|
|
|
glGenBuffers(1, &g_cageVertexVBO);
|
|
|
|
glGenBuffers(1, &g_cageEdgeVBO);
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
uninitGL() {
|
|
|
|
|
|
|
|
glDeleteBuffers(1, &g_cageVertexVBO);
|
|
|
|
glDeleteBuffers(1, &g_cageEdgeVBO);
|
|
|
|
glDeleteVertexArrays(1, &g_cageVertexVAO);
|
|
|
|
glDeleteVertexArrays(1, &g_cageEdgeVAO);
|
|
|
|
glDeleteVertexArrays(1, &g_samplesVAO);
|
|
|
|
}
|
|
|
|
|
2014-12-20 22:44:50 +00:00
|
|
|
//------------------------------------------------------------------------------
|
|
|
|
static void
|
|
|
|
callbackErrorGLFW(int error, const char* description) {
|
|
|
|
fprintf(stderr, "GLFW Error (%d) : %s\n", error, description);
|
|
|
|
}
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
//------------------------------------------------------------------------------
|
2013-06-18 23:52:21 +00:00
|
|
|
int main(int argc, char **argv) {
|
2013-04-19 02:55:05 +00:00
|
|
|
|
|
|
|
bool fullscreen = false;
|
|
|
|
|
2013-06-18 23:52:21 +00:00
|
|
|
std::string str;
|
|
|
|
for (int i = 1; i < argc; ++i) {
|
|
|
|
if (!strcmp(argv[i], "-f"))
|
|
|
|
fullscreen = true;
|
|
|
|
else {
|
|
|
|
std::ifstream ifs(argv[1]);
|
|
|
|
if (ifs) {
|
|
|
|
std::stringstream ss;
|
|
|
|
ss << ifs.rdbuf();
|
|
|
|
ifs.close();
|
|
|
|
str = ss.str();
|
2014-10-01 01:53:47 +00:00
|
|
|
g_defaultShapes.push_back(ShapeDesc(argv[1], str.c_str(), kCatmark));
|
2013-06-18 23:52:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-12-04 01:19:07 +00:00
|
|
|
Far::SetErrorCallback(callbackError);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
|
|
|
initShapes();
|
2013-04-19 02:55:05 +00:00
|
|
|
|
2014-12-20 22:44:50 +00:00
|
|
|
glfwSetErrorCallback(callbackErrorGLFW);
|
2013-04-19 02:55:05 +00:00
|
|
|
if (not glfwInit()) {
|
|
|
|
printf("Failed to initialize GLFW\n");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
static const char windowTitle[] = "OpenSubdiv glEvalLimit " OPENSUBDIV_VERSION_STRING;
|
|
|
|
|
2015-05-30 05:33:51 +00:00
|
|
|
GLUtils::SetMinimumGLVersion();
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
if (fullscreen) {
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
g_primary = glfwGetPrimaryMonitor();
|
|
|
|
|
|
|
|
// apparently glfwGetPrimaryMonitor fails under linux : if no primary,
|
2014-09-05 22:07:46 +00:00
|
|
|
// settle for the first one in the list
|
2013-04-19 02:55:05 +00:00
|
|
|
if (not g_primary) {
|
|
|
|
int count=0;
|
|
|
|
GLFWmonitor ** monitors = glfwGetMonitors(&count);
|
|
|
|
|
|
|
|
if (count)
|
|
|
|
g_primary = monitors[0];
|
|
|
|
}
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
if (g_primary) {
|
2013-06-20 18:53:33 +00:00
|
|
|
GLFWvidmode const * vidmode = glfwGetVideoMode(g_primary);
|
|
|
|
g_width = vidmode->width;
|
|
|
|
g_height = vidmode->height;
|
2013-04-19 02:55:05 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-09-05 22:07:46 +00:00
|
|
|
if (not (g_window=glfwCreateWindow(g_width, g_height, windowTitle,
|
2013-04-19 02:55:05 +00:00
|
|
|
fullscreen and g_primary ? g_primary : NULL, NULL))) {
|
2015-05-30 05:33:51 +00:00
|
|
|
std::cerr << "Failed to create OpenGL context.\n";
|
2013-04-19 02:55:05 +00:00
|
|
|
glfwTerminate();
|
|
|
|
return 1;
|
|
|
|
}
|
2015-05-30 05:33:51 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
glfwMakeContextCurrent(g_window);
|
2015-05-30 05:33:51 +00:00
|
|
|
GLUtils::PrintGLVersion();
|
2014-02-22 03:25:00 +00:00
|
|
|
|
|
|
|
// accommodate high DPI displays (e.g. mac retina displays)
|
|
|
|
glfwGetFramebufferSize(g_window, &g_width, &g_height);
|
|
|
|
glfwSetFramebufferSizeCallback(g_window, reshape);
|
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
glfwSetKeyCallback(g_window, keyboard);
|
|
|
|
glfwSetCursorPosCallback(g_window, motion);
|
|
|
|
glfwSetMouseButtonCallback(g_window, mouse);
|
|
|
|
glfwSetWindowCloseCallback(g_window, windowClose);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-06-26 07:52:57 +00:00
|
|
|
#if defined(OSD_USES_GLEW)
|
2013-04-19 02:55:05 +00:00
|
|
|
#ifdef CORE_PROFILE
|
|
|
|
// this is the only way to initialize glew correctly under core profile context.
|
|
|
|
glewExperimental = true;
|
|
|
|
#endif
|
|
|
|
if (GLenum r = glewInit() != GLEW_OK) {
|
|
|
|
printf("Failed to initialize glew. Error = %s\n", glewGetErrorString(r));
|
|
|
|
exit(1);
|
|
|
|
}
|
|
|
|
#ifdef CORE_PROFILE
|
|
|
|
// clear GL errors which was generated during glewInit()
|
|
|
|
glGetError();
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
//std::string & data = g_defaultShapes[ g_currentShape ].data;
|
|
|
|
//Scheme scheme = g_defaultShapes[ g_currentShape ].scheme;
|
|
|
|
|
|
|
|
//createOsdMesh( data, g_level, scheme );
|
|
|
|
|
|
|
|
initGL();
|
|
|
|
linkDefaultProgram();
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
glfwSwapInterval(0);
|
|
|
|
|
|
|
|
initHUD();
|
|
|
|
callbackModel(g_currentShape);
|
|
|
|
|
|
|
|
while (g_running) {
|
|
|
|
idle();
|
|
|
|
display();
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
glfwPollEvents();
|
|
|
|
glfwSwapBuffers(g_window);
|
2014-09-05 22:07:46 +00:00
|
|
|
|
2013-04-19 02:55:05 +00:00
|
|
|
glFinish();
|
|
|
|
}
|
|
|
|
|
|
|
|
uninitGL();
|
|
|
|
glfwTerminate();
|
|
|
|
}
|