OsdMesh no longer owns its ComputeController

Now a ComputeController is passed as an
argument to OsdMesh::Create(). This is
a better match to the underlying object
model and can be much more efficient for
compute controllers that have expensive
resources, e.g. compiled shader kernels.

Fixes #103
This commit is contained in:
David G Yu 2013-02-19 17:33:32 -08:00
parent a1040e80d4
commit 452b30f72f
7 changed files with 221 additions and 52 deletions

View File

@ -68,10 +68,12 @@
#include <osd/cpuD3D11VertexBuffer.h>
#include <osd/cpuComputeContext.h>
#include <osd/cpuComputeController.h>
OpenSubdiv::OsdCpuComputeController * g_cpuComputeController = NULL;
#ifdef OPENSUBDIV_HAS_OPENMP
#include <osd/ompDispatcher.h>
#include <osd/ompComputeController.h>
OpenSubdiv::OsdOmpComputeController * g_ompComputeController = NULL;
#endif
#undef OPENSUBDIV_HAS_OPENCL // XXX: dyu OpenCL D3D11 interop needs work...
@ -85,6 +87,7 @@
cl_context g_clContext;
cl_command_queue g_clQueue;
OpenSubdiv::OsdCLComputeController * g_clComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_CUDA
@ -97,12 +100,14 @@
#include <cuda_d3d11_interop.h>
bool g_cudaInitialized = false;
OpenSubdiv::OsdCudaComputeController * g_cudaComputeController = NULL;
#endif
#include <osd/d3d11Dispatcher.h>
#include <osd/d3d11VertexBuffer.h>
#include <osd/d3d11ComputeContext.h>
#include <osd/d3d11ComputeController.h>
OpenSubdiv::OsdD3D11ComputeController * g_d3d11ComputeController = NULL;
#include <osd/d3d11Mesh.h>
OpenSubdiv::OsdD3D11MeshInterface *g_mesh;
@ -498,31 +503,62 @@ createOsdMesh( const char * shape, int level, int kernel, Scheme scheme=kCatmark
bits.set(OpenSubdiv::MeshAdaptive, doAdaptive);
if (g_kernel == kCPU) {
if (not g_cpuComputeController) {
g_cpuComputeController = new OpenSubdiv::OsdCpuComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCpuD3D11VertexBuffer,
OpenSubdiv::OsdCpuComputeController,
OpenSubdiv::OsdD3D11DrawContext>(hmesh, 6, level, bits, g_pd3dDeviceContext);
OpenSubdiv::OsdD3D11DrawContext>(
g_cpuComputeController,
hmesh, 6, level, bits,
g_pd3dDeviceContext);
#ifdef OPENSUBDIV_HAS_OPENMP
} else if (kernel == kOPENMP) {
if (not g_ompComputeController) {
g_ompComputeController = new OpenSubdiv::OsdOmpComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCpuD3D11VertexBuffer,
OpenSubdiv::OsdOmpComputeController,
OpenSubdiv::OsdD3D11DrawContext>(hmesh, 6, level, bits, g_pd3dDeviceContext);
OpenSubdiv::OsdD3D11DrawContext>(
g_ompComputeController,
hmesh, 6, level, bits,
g_pd3dDeviceContext);
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
} else if(kernel == kCL) {
if (not g_clComputeController) {
g_clComputeController = new OpenSubdiv::OsdCLComputeController(g_clContext, g_clQueue);
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCLD3D11VertexBuffer,
OpenSubdiv::OsdCLComputeController,
OpenSubdiv::OsdD3D11DrawContext>(hmesh, 6, level, bits, g_clContext, g_clQueue, g_pd3dDeviceContext);
OpenSubdiv::OsdD3D11DrawContext>(
g_clComputeController,
hmesh, 6, level, bits,
g_clContext, g_clQueue,
g_pd3dDeviceContext);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
} else if (g_kernel == kCUDA) {
if (not g_cudaComputeController) {
g_cudaComputeController = new OpenSubdiv::OsdCudaComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCudaD3D11VertexBuffer,
OpenSubdiv::OsdCudaComputeController,
OpenSubdiv::OsdD3D11DrawContext>(hmesh, 6, level, bits, g_pd3dDeviceContext);
OpenSubdiv::OsdD3D11DrawContext>(
g_cudaComputeController,
hmesh, 6, level, bits,
g_pd3dDeviceContext);
#endif
} else if (g_kernel == kDirectCompute) {
if (not g_d3d11ComputeController) {
g_d3d11ComputeController = new OpenSubdiv::OsdD3D11ComputeController(g_pd3dDeviceContext);
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdD3D11VertexBuffer,
OpenSubdiv::OsdD3D11ComputeController,
OpenSubdiv::OsdD3D11DrawContext>(hmesh, 6, level, bits, g_pd3dDeviceContext);
OpenSubdiv::OsdD3D11DrawContext>(
g_d3d11ComputeController,
hmesh, 6, level, bits,
g_pd3dDeviceContext);
} else {
printf("Unsupported kernel %s\n", getKernelName(kernel));
}
@ -994,14 +1030,24 @@ quit() {
SAFE_RELEASE(g_pd3dDeviceContext);
SAFE_RELEASE(g_pd3dDevice);
#ifdef OPENSUBDIV_HAS_CUDA
cudaDeviceReset();
delete g_cpuComputeController;
#ifdef OPENSUBDIV_HAS_OPENMP
delete g_ompComputeController;
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
delete g_clComputeController;
uninitCL(g_clContext, g_clQueue);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
delete g_cudaComputeController;
cudaDeviceReset();
#endif
delete g_d3d11ComputeController;
PostQuitMessage(0);
exit(0);
}

View File

@ -84,15 +84,18 @@
#include <osd/cpuGLVertexBuffer.h>
#include <osd/cpuComputeContext.h>
#include <osd/cpuComputeController.h>
OpenSubdiv::OsdCpuComputeController *g_cpuComputeController = NULL;
#ifdef OPENSUBDIV_HAS_OPENMP
#include <osd/ompDispatcher.h>
#include <osd/ompComputeController.h>
OpenSubdiv::OsdOmpComputeController *g_ompComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_GCD
#include <osd/gcdDispatcher.h>
#include <osd/gcdComputeController.h>
OpenSubdiv::OsdGcdComputeController *g_gcdComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
@ -105,6 +108,7 @@
cl_context g_clContext;
cl_command_queue g_clQueue;
OpenSubdiv::OsdCLComputeController *g_clComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_CUDA
@ -119,6 +123,7 @@
#include "../common/cudaInit.h"
bool g_cudaInitialized = false;
OpenSubdiv::OsdCudaComputeController *g_cudaComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
@ -126,6 +131,7 @@
#include <osd/glslTransformFeedbackComputeContext.h>
#include <osd/glslTransformFeedbackComputeController.h>
#include <osd/glVertexBuffer.h>
OpenSubdiv::OsdGLSLTransformFeedbackComputeController *g_glslTransformFeedbackComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
@ -133,6 +139,7 @@
#include <osd/glslComputeContext.h>
#include <osd/glslComputeController.h>
#include <osd/glVertexBuffer.h>
OpenSubdiv::OsdGLSLComputeController *g_glslComputeController = NULL;
#endif
#include <osd/glMesh.h>
@ -640,44 +647,80 @@ createOsdMesh( const char * shape, int level, int kernel, Scheme scheme=kCatmark
bits.set(OpenSubdiv::MeshAdaptive, doAdaptive);
if (kernel == kCPU) {
if (not g_cpuComputeController) {
g_cpuComputeController = new OpenSubdiv::OsdCpuComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCpuGLVertexBuffer,
OpenSubdiv::OsdCpuComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, 6, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_cpuComputeController,
hmesh, 6, level, bits);
#ifdef OPENSUBDIV_HAS_OPENMP
} else if (kernel == kOPENMP) {
if (not g_ompComputeController) {
g_ompComputeController = new OpenSubdiv::OsdOmpComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCpuGLVertexBuffer,
OpenSubdiv::OsdOmpComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, 6, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_ompComputeController,
hmesh, 6, level, bits);
#endif
#ifdef OPENSUBDIV_HAS_GCD
} else if (kernel == kGCD) {
if (not g_gcdComputeController) {
g_gcdComputeController = new OpenSubdiv::OsdGcdComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCpuGLVertexBuffer,
OpenSubdiv::OsdGcdComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, 6, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_gcdComputeController,
hmesh, 6, level, bits);
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
} else if(kernel == kCL) {
if (not g_clComputeController) {
g_clComputeController = new OpenSubdiv::OsdCLComputeController(g_clContext, g_clQueue);
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCLGLVertexBuffer,
OpenSubdiv::OsdCLComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, 6, level, bits, g_clContext, g_clQueue);
OpenSubdiv::OsdGLDrawContext>(
g_clComputeController,
hmesh, 6, level, bits,
g_clContext, g_clQueue);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
} else if(kernel == kCUDA) {
if (not g_cudaComputeController) {
g_cudaComputeController = new OpenSubdiv::OsdCudaComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCudaGLVertexBuffer,
OpenSubdiv::OsdCudaComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, 6, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_cudaComputeController,
hmesh, 6, level, bits);
#endif
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
} else if(kernel == kGLSL) {
if (not g_glslComputeController) {
g_glslTransformFeedbackComputeController = new OpenSubdiv::OsdGLSLTransformFeedbackComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdGLVertexBuffer,
OpenSubdiv::OsdGLSLTransformFeedbackComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, 6, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_glslTransformFeedbackComputeController,
hmesh, 6, level, bits);
#endif
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
} else if(kernel == kGLSLCompute) {
if (not g_glslComputeController) {
g_glslComputeController = new OpenSubdiv::OsdGLSLComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdGLVertexBuffer,
OpenSubdiv::OsdGLSLComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, 6, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_glslComputeController,
hmesh, 6, level, bits);
#endif
} else {
printf("Unsupported kernel %s\n", getKernelName(kernel));
@ -1445,13 +1488,33 @@ uninitGL() {
if (g_mesh)
delete g_mesh;
#ifdef OPENSUBDIV_HAS_CUDA
cudaDeviceReset();
delete g_cpuComputeController;
#ifdef OPENSUBDIV_HAS_OPENMP
delete g_ompComputeController;
#endif
#ifdef OPENSUBDIV_HAS_GCD
delete g_gcdComputeController;
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
delete g_clComputeController;
uninitCL(g_clContext, g_clQueue);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
delete g_cudaComputeController;
cudaDeviceReset();
#endif
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
delete g_glslTransformFeedbackComputeController;
#endif
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
delete g_glslComputeController;
#endif
}
//------------------------------------------------------------------------------

View File

@ -71,10 +71,12 @@
#include <osd/cpuDispatcher.h>
#include <osd/cpuComputeController.h>
extern OpenSubdiv::OsdCpuComputeController * g_cpuComputeController;
#ifdef OPENSUBDIV_HAS_OPENMP
#include <osd/ompDispatcher.h>
#include <osd/ompComputeController.h>
extern OpenSubdiv::OsdOmpComputeController * g_ompComputeController;
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
@ -82,11 +84,13 @@
#include <osd/clComputeController.h>
extern cl_context g_clContext;
extern cl_command_queue g_clQueue;
extern OpenSubdiv::OsdCLComputeController * g_clComputeController;
#endif
#ifdef OPENSUBDIV_HAS_CUDA
#include <osd/cudaDispatcher.h>
#include <osd/cudaComputeController.h>
extern OpenSubdiv::OsdCudaComputeController * g_cudaComputeController;
#endif
#include <vector>
@ -328,24 +332,33 @@ OsdMeshData::initializeMesh()
if (_kernel == kCPU) {
_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCpuGLVertexBuffer,
OpenSubdiv::OsdCpuComputeController,
OpenSubdiv::OsdGLDrawContext>(_hbrmesh, 3, _level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_cpuComputeController,
_hbrmesh, 3, _level, bits);
#ifdef OPENSUBDIV_HAS_OPENMP
} else if (_kernel == kOPENMP) {
_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCpuGLVertexBuffer,
OpenSubdiv::OsdOmpComputeController,
OpenSubdiv::OsdGLDrawContext>(_hbrmesh, 3, _level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_ompComputeController,
_hbrmesh, 3, _level, bits);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
} else if(_kernel == kCUDA) {
_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCudaGLVertexBuffer,
OpenSubdiv::OsdCudaComputeController,
OpenSubdiv::OsdGLDrawContext>(_hbrmesh, 3, _level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_cudaComputeController,
_hbrmesh, 3, _level, bits);
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
} else if(_kernel == kCL) {
_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCLGLVertexBuffer,
OpenSubdiv::OsdCLComputeController,
OpenSubdiv::OsdGLDrawContext>(_hbrmesh, 3, _level, bits, g_clContext, g_clQueue);
OpenSubdiv::OsdGLDrawContext>(
g_clComputeController,
_hbrmesh, 3, _level, bits,
g_clContext, g_clQueue);
#endif
}

View File

@ -91,10 +91,12 @@
#include <osd/cpuGLVertexBuffer.h>
#include <osd/cpuComputeContext.h>
#include <osd/cpuComputeController.h>
OpenSubdiv::OsdCpuComputeController * g_cpuComputeController = NULL;
#ifdef OPENSUBDIV_HAS_OPENMP
#include <osd/ompDispatcher.h>
#include <osd/ompComputeController.h>
OpenSubdiv::OsdOmpComputeController * g_ompComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
@ -107,6 +109,7 @@
cl_context g_clContext;
cl_command_queue g_clQueue;
OpenSubdiv::OsdCLComputeController * g_clComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_CUDA
@ -121,6 +124,7 @@
#include "../common/cudaInit.h"
bool g_cudaInitialized = false;
OpenSubdiv::OsdCudaComputeController * g_cudaComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
@ -128,6 +132,7 @@
#include <osd/glslTransformFeedbackComputeContext.h>
#include <osd/glslTransformFeedbackComputeController.h>
#include <osd/glVertexBuffer.h>
OpenSubdiv::OsdGLSLTransformFeedbackComputeController * g_glslTransformFeedbackComputeController = NULL;
#endif
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
@ -135,6 +140,7 @@
#include <osd/glslComputeContext.h>
#include <osd/glslComputeController.h>
#include <osd/glVertexBuffer.h>
OpenSubdiv::OsdGLSLComputeController * g_glslComputeController = NULL;
#endif
#include <osd/glMesh.h>
@ -817,38 +823,69 @@ createOsdMesh(int level, int kernel) {
int numVertexElements = g_adaptive ? 3 : 6;
if (kernel == kCPU) {
if (not g_cpuComputeController) {
g_cpuComputeController = new OpenSubdiv::OsdCpuComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCpuGLVertexBuffer,
OpenSubdiv::OsdCpuComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, numVertexElements, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_cpuComputeController,
hmesh, numVertexElements, level, bits);
#ifdef OPENSUBDIV_HAS_OPENMP
} else if (kernel == kOPENMP) {
if (not g_ompComputeController) {
g_ompComputeController = new OpenSubdiv::OsdOmpComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCpuGLVertexBuffer,
OpenSubdiv::OsdOmpComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, numVertexElements, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_ompComputeController,
hmesh, numVertexElements, level, bits);
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
} else if(kernel == kCL) {
if (not g_clComputeController) {
g_clComputeController = new OpenSubdiv::OsdCLComputeController(g_clContext, g_clQueue);
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCLGLVertexBuffer,
OpenSubdiv::OsdCLComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, numVertexElements, level, bits, g_clContext, g_clQueue);
OpenSubdiv::OsdGLDrawContext>(
g_clComputeController,
hmesh, numVertexElements, level, bits,
g_clContext, g_clQueue);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
} else if(kernel == kCUDA) {
if (not g_cudaComputeController) {
g_cudaComputeController = new OpenSubdiv::OsdCudaComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdCudaGLVertexBuffer,
OpenSubdiv::OsdCudaComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, numVertexElements, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_cudaComputeController,
hmesh, numVertexElements, level, bits);
#endif
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
} else if(kernel == kGLSL) {
if (not g_glslComputeController) {
g_glslTransformFeedbackComputeController = new OpenSubdiv::OsdGLSLTransformFeedbackComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdGLVertexBuffer,
OpenSubdiv::OsdGLSLTransformFeedbackComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, numVertexElements, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_glslTransformFeedbackComputeController,
hmesh, numVertexElements, level, bits);
#endif
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
} else if(kernel == kGLSLCompute) {
if (not g_glslComputeController) {
g_glslComputeController = new OpenSubdiv::OsdGLSLComputeController();
}
g_mesh = new OpenSubdiv::OsdMesh<OpenSubdiv::OsdGLVertexBuffer,
OpenSubdiv::OsdGLSLComputeController,
OpenSubdiv::OsdGLDrawContext>(hmesh, numVertexElements, level, bits);
OpenSubdiv::OsdGLDrawContext>(
g_glslComputeController,
hmesh, numVertexElements, level, bits);
#endif
} else {
printf("Unsupported kernel %s\n", getKernelName(kernel));
@ -1448,14 +1485,30 @@ void uninitGL() {
if(g_mesh)
delete g_mesh;
#ifdef OPENSUBDIV_HAS_CUDA
cudaDeviceReset();
delete g_cpuComputeController;
#ifdef OPENSUBDIV_HAS_OPENMP
delete g_ompComputeController;
#endif
#ifdef OPENSUBDIV_HAS_OPENCL
delete g_clComputeController;
uninitCL(g_clContext, g_clQueue);
#endif
#ifdef OPENSUBDIV_HAS_CUDA
delete g_cudaComputeController;
cudaDeviceReset();
#endif
#ifdef OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK
delete g_glslTransformFeedbackComputeController;
#endif
#ifdef OPENSUBDIV_HAS_GLSL_COMPUTE
delete g_glslComputeController;
#endif
if (g_animPositionBuffers.size())
glDeleteBuffers((int)g_animPositionBuffers.size(), &g_animPositionBuffers[0]);
if (g_diffuseEnvironmentMap) glDeleteTextures(1, &g_diffuseEnvironmentMap);

View File

@ -79,7 +79,8 @@ public:
typedef OsdD3D11DrawContext DrawContext;
typedef typename DrawContext::VertexBufferBinding VertexBufferBinding;
OsdMesh(HbrMesh<OsdVertex> * hmesh,
OsdMesh(ComputeController * computeController,
HbrMesh<OsdVertex> * hmesh,
int numElements,
int level,
OsdMeshBitset bits,
@ -88,7 +89,7 @@ public:
_farMesh(0),
_vertexBuffer(0),
_computeContext(0),
_computeController(0),
_computeController(computeController),
_drawContext(0),
_pd3d11DeviceContext(d3d11DeviceContext)
{
@ -102,7 +103,6 @@ public:
int numVertices = _farMesh->GetNumVertices();
_vertexBuffer = VertexBuffer::Create(numElements, numVertices, pd3d11Device);
_computeContext = ComputeContext::Create(_farMesh);
_computeController = new ComputeController();
_drawContext = DrawContext::Create(_farMesh, _vertexBuffer,
_pd3d11DeviceContext,
bits.test(MeshPtexData),
@ -113,7 +113,6 @@ public:
delete _farMesh;
delete _vertexBuffer;
delete _computeContext;
delete _computeController;
delete _drawContext;
}
@ -154,7 +153,8 @@ public:
typedef OsdD3D11DrawContext DrawContext;
typedef DrawContext::VertexBufferBinding VertexBufferBinding;
OsdMesh(HbrMesh<OsdVertex> * hmesh,
OsdMesh(ComputeController * computeController,
HbrMesh<OsdVertex> * hmesh,
int numElements,
int level,
OsdMeshBitset bits,
@ -163,7 +163,7 @@ public:
_farMesh(0),
_vertexBuffer(0),
_computeContext(0),
_computeController(0),
_computeController(computeController),
_drawContext(0),
_pd3d11DeviceContext(d3d11DeviceContext)
{
@ -177,7 +177,6 @@ public:
int numVertices = _farMesh->GetNumVertices();
_vertexBuffer = VertexBuffer::Create(numElements, numVertices, pd3d11Device);
_computeContext = ComputeContext::Create(_farMesh, _pd3d11DeviceContext);
_computeController = new ComputeController(_pd3d11DeviceContext);
_drawContext = DrawContext::Create(_farMesh, _vertexBuffer,
_pd3d11DeviceContext,
bits.test(MeshPtexData),
@ -188,7 +187,6 @@ public:
delete _farMesh;
delete _vertexBuffer;
delete _computeContext;
delete _computeController;
delete _drawContext;
}
@ -239,7 +237,8 @@ public:
typedef OsdD3D11DrawContext DrawContext;
typedef typename DrawContext::VertexBufferBinding VertexBufferBinding;
OsdMesh(HbrMesh<OsdVertex> * hmesh,
OsdMesh(ComputeController * computeController,
HbrMesh<OsdVertex> * hmesh,
int numElements,
int level,
OsdMeshBitset bits,
@ -250,7 +249,7 @@ public:
_farMesh(0),
_vertexBuffer(0),
_computeContext(0),
_computeController(0),
_computeController(computeController),
_drawContext(0),
_clContext(clContext),
_clQueue(clQueue),
@ -266,7 +265,6 @@ public:
int numVertices = _farMesh->GetNumVertices();
_vertexBuffer = typename VertexBuffer::Create(numElements, numVertices, _clContext, pd3d11Device);
_computeContext = ComputeContext::Create(_farMesh, _clContext);
_computeController = new ComputeController(_clContext, _clQueue);
_drawContext = DrawContext::Create(_farMesh, _vertexBuffer,
_pd3d11DeviceContext,
bits.test(MeshPtexData),
@ -277,7 +275,6 @@ public:
delete _farMesh;
delete _vertexBuffer;
delete _computeContext;
delete _computeController;
delete _drawContext;
}

View File

@ -86,7 +86,8 @@ public:
typedef OsdGLDrawContext DrawContext;
typedef typename DrawContext::VertexBufferBinding VertexBufferBinding;
OsdMesh(HbrMesh<OsdVertex> * hmesh,
OsdMesh(ComputeController * computeController,
HbrMesh<OsdVertex> * hmesh,
int numElements,
int level,
OsdMeshBitset bits) :
@ -94,7 +95,7 @@ public:
_farMesh(0),
_vertexBuffer(0),
_computeContext(0),
_computeController(0),
_computeController(computeController),
_drawContext(0)
{
FarMeshFactory<OsdVertex> meshFactory(hmesh, level, bits.test(MeshAdaptive));
@ -104,7 +105,6 @@ public:
int numVertices = _farMesh->GetNumVertices();
_vertexBuffer = VertexBuffer::Create(numElements, numVertices);
_computeContext = ComputeContext::Create(_farMesh);
_computeController = new ComputeController();
_drawContext = DrawContext::Create(_farMesh, _vertexBuffer,
bits.test(MeshPtexData),
bits.test(MeshFVarData));
@ -114,7 +114,6 @@ public:
delete _farMesh;
delete _vertexBuffer;
delete _computeContext;
delete _computeController;
delete _drawContext;
}
@ -155,7 +154,8 @@ public:
typedef OsdGLDrawContext DrawContext;
typedef typename DrawContext::VertexBufferBinding VertexBufferBinding;
OsdMesh(HbrMesh<OsdVertex> * hmesh,
OsdMesh(ComputeController * computeController,
HbrMesh<OsdVertex> * hmesh,
int numElements,
int level,
OsdMeshBitset bits,
@ -165,7 +165,7 @@ public:
_farMesh(0),
_vertexBuffer(0),
_computeContext(0),
_computeController(0),
_computeController(computeController),
_drawContext(0),
_clContext(clContext),
_clQueue(clQueue)
@ -177,7 +177,6 @@ public:
int numVertices = _farMesh->GetNumVertices();
_vertexBuffer = VertexBuffer::Create(numElements, numVertices, _clContext);
_computeContext = ComputeContext::Create(_farMesh, _clContext);
_computeController = new ComputeController(_clContext, _clQueue);
_drawContext = DrawContext::Create(_farMesh, _vertexBuffer,
bits.test(MeshPtexData),
bits.test(MeshFVarData));
@ -187,7 +186,6 @@ public:
delete _farMesh;
delete _vertexBuffer;
delete _computeContext;
delete _computeController;
delete _drawContext;
}

View File

@ -115,7 +115,8 @@ public:
typedef DRAW_CONTEXT DrawContext;
typedef typename DrawContext::VertexBufferBinding VertexBufferBinding;
OsdMesh(HbrMesh<OsdVertex> * hmesh,
OsdMesh(ComputeController * computeController,
HbrMesh<OsdVertex> * hmesh,
int numElements,
int level,
OsdMeshBitset bits = OsdMeshBitset()) :
@ -123,7 +124,7 @@ public:
_farMesh(0),
_vertexBuffer(0),
_computeContext(0),
_computeController(0),
_computeController(computeController),
_drawContext(0)
{
FarMeshFactory<OsdVertex> meshFactory(hmesh, level, bits.test(MeshAdaptive));
@ -133,7 +134,6 @@ public:
int numVertices = _farMesh->GetNumVertices();
_vertexBuffer = VertexBuffer::Create(numElements, numVertices);
_computeContext = ComputeContext::Create(_farMesh);
_computeController = new ComputeController();
_drawContext = DrawContext::Create(_farMesh, _vertexBuffer,
bits.test(MeshPtexData),
bits.test(MeshFVarData));
@ -143,7 +143,6 @@ public:
delete _farMesh;
delete _vertexBuffer;
delete _computeContext;
delete _computeController;
delete _drawContext;
}