[Bf-blender-cvs] [b2cfd24] opensubdiv-modifier: OpenSubdiv: Initial work to make use of 3.0 API

Sergey Sharybin noreply at git.blender.org
Sat Jul 11 20:01:46 CEST 2015


Commit: b2cfd24868aac64504656ab3a6ce7dd40c9dfc47
Author: Sergey Sharybin
Date:   Tue Jul 7 08:54:06 2015 +0200
Branches: opensubdiv-modifier
https://developer.blender.org/rBb2cfd24868aac64504656ab3a6ce7dd40c9dfc47

OpenSubdiv: Initial work to make use of 3.0 API

Only basic stuff like getting rid of old deprecated API usage and some
experiments with new API.

Blender compiles but nothing quite really works yet.

===================================================================

M	build_files/cmake/Modules/FindOpenSubdiv.cmake
M	intern/opensubdiv/CMakeLists.txt
D	intern/opensubdiv/clInit.h
D	intern/opensubdiv/cudaInit.h
M	intern/opensubdiv/opensubdiv_capi.cc
M	intern/opensubdiv/opensubdiv_capi.h
A	intern/opensubdiv/opensubdiv_device_context_cuda.cc
A	intern/opensubdiv/opensubdiv_device_context_cuda.h
A	intern/opensubdiv/opensubdiv_device_context_opencl.cc
A	intern/opensubdiv/opensubdiv_device_context_opencl.h
M	intern/opensubdiv/opensubdiv_gpu_capi.cc
M	intern/opensubdiv/opensubdiv_partitioned.h
A	intern/opensubdiv/opensubdiv_utils_capi.cc
M	source/blender/blenkernel/intern/CCGSubSurf.c
M	source/blender/makesrna/intern/rna_userdef.c

===================================================================

diff --git a/build_files/cmake/Modules/FindOpenSubdiv.cmake b/build_files/cmake/Modules/FindOpenSubdiv.cmake
index 7733c76..efbe8a9 100644
--- a/build_files/cmake/Modules/FindOpenSubdiv.cmake
+++ b/build_files/cmake/Modules/FindOpenSubdiv.cmake
@@ -28,7 +28,6 @@ IF(NOT OPENSUBDIV_ROOT_DIR AND NOT $ENV{OPENSUBDIV_ROOT_DIR} STREQUAL "")
 ENDIF()
 
 SET(_opensubdiv_FIND_COMPONENTS
-  osdutil
   osdGPU
   osdCPU
 )
@@ -96,12 +95,11 @@ IF(OPENSUBDIV_FOUND)
     SET(OPENSUBDIV_HAS_OPENMP FALSE)
   ENDIF()
 
-  OPENSUBDIV_CHECK_CONTROLLER("tbbComputeController.h" OPENSUBDIV_HAS_TBB)
-  OPENSUBDIV_CHECK_CONTROLLER("gcdComputeController.h" OPENSUBDIV_HAS_GCD)
-  OPENSUBDIV_CHECK_CONTROLLER("clComputeController.h" OPENSUBDIV_HAS_OPENCL)
-  OPENSUBDIV_CHECK_CONTROLLER("cudaComputeController.h" OPENSUBDIV_HAS_CUDA)
-  OPENSUBDIV_CHECK_CONTROLLER("glslTransformFeedbackComputeController.h" OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
-  OPENSUBDIV_CHECK_CONTROLLER("osd/glslComputeController.h" OPENSUBDIV_HAS_GLSL_COMPUTE)
+  OPENSUBDIV_CHECK_CONTROLLER("tbbEvaluator.h" OPENSUBDIV_HAS_TBB)
+  OPENSUBDIV_CHECK_CONTROLLER("clEvaluator.h" OPENSUBDIV_HAS_OPENCL)
+  OPENSUBDIV_CHECK_CONTROLLER("cudaEvaluator.h" OPENSUBDIV_HAS_CUDA)
+  OPENSUBDIV_CHECK_CONTROLLER("glXFBEvaluator.h" OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
+  OPENSUBDIV_CHECK_CONTROLLER("glComputeEvaluator.h" OPENSUBDIV_HAS_GLSL_COMPUTE)
 ENDIF(OPENSUBDIV_FOUND)
 
 MARK_AS_ADVANCED(
diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt
index 4dde50e..ec0dc8e 100644
--- a/intern/opensubdiv/CMakeLists.txt
+++ b/intern/opensubdiv/CMakeLists.txt
@@ -31,14 +31,20 @@ set(INC
 set(INC_SYS
 	${OPENSUBDIV_INCLUDE_DIR}
 	${GLEW_INCLUDE_PATH}
+	/usr/local/cuda/include
 )
 
 set(SRC
 	opensubdiv_capi.cc
+	opensubdiv_device_context_cuda.cc
+	opensubdiv_device_context_opencl.cc
 	opensubdiv_gpu_capi.cc
-	clInit.h
-	cudaInit.h
+	opensubdiv_utils_capi.cc
+
 	opensubdiv_capi.h
+	opensubdiv_device_context_cuda.h
+	opensubdiv_device_context_opencl.h
+	opensubdiv_partitioned.h
 )
 
 macro(OPENSUBDIV_DEFINE_COMPONENT component)
@@ -49,7 +55,8 @@ endmacro()
 
 OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_OPENMP)
 OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_OPENCL)
-OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_CUDA)
+# TODO(sergey): CUDA stays disabled for util it's ported to drievr API.
+# OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_CUDA)
 OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK)
 OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_GLSL_COMPUTE)
 
@@ -61,12 +68,13 @@ if(WIN32)
 	add_definitions(-DNOMINMAX)
 endif()
 
-if(OPENSUBDIV_HAS_CUDA)
-	list(APPEND INC
-		../../extern/cuew/include
-	)
-	add_definitions(-DOPENSUBDIV_HAS_CUEW)
-endif()
+# TODO(sergey): Put CUEW back when CUDA is officially supported by OSD.
+#if(OPENSUBDIV_HAS_CUDA)
+#	list(APPEND INC
+#		../../extern/cuew/include
+#	)
+#	add_definitions(-DOPENSUBDIV_HAS_CUEW)
+#endif()
 
 if(OPENSUBDIV_HAS_OPENCL)
 	list(APPEND INC
diff --git a/intern/opensubdiv/clInit.h b/intern/opensubdiv/clInit.h
deleted file mode 100644
index 37de12d..0000000
--- a/intern/opensubdiv/clInit.h
+++ /dev/null
@@ -1,192 +0,0 @@
-//
-//   Copyright 2013 Pixar
-//
-//   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:
-//
-//   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.
-//
-//   You may obtain a copy of the Apache License at
-//
-//       http://www.apache.org/licenses/LICENSE-2.0
-//
-//   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.
-//
-
-#ifndef OSD_EXAMPLE_CL_INIT_H
-#define OSD_EXAMPLE_CL_INIT_H
-
-#if defined(_WIN32)
-#  include <windows.h>
-#elif defined(__APPLE__)
-#  include <OpenGL/OpenGL.h>
-#else
-#  include <GL/glx.h>
-#endif
-
-#include <opensubdiv/osd/opencl.h>
-
-#include <cstdio>
-
-static bool HAS_CL_VERSION_1_1() {
-#ifdef OPENSUBDIV_HAS_OPENCL
-#  ifdef OPENSUBDIV_HAS_CLEW
-	static bool clewInitialized = false;
-	static bool clewLoadSuccess;
-	if (!clewInitialized) {
-		clewInitialized = true;
-		clewLoadSuccess = clewInit() == CLEW_SUCCESS;
-		if (!clewLoadSuccess) {
-			fprintf(stderr, "Loading OpenCL failed.\n");
-		}
-		else {
-			cl_uint num_platforms;
-			if (clGetPlatformIDs(0, NULL, &num_platforms) != CL_SUCCESS) {
-				clewLoadSuccess = false;
-			}
-		}
-	}
-	return clewLoadSuccess;
-#  endif
-    return true;
-#else
-    return false;
-#endif
-}
-
-static bool initCL(cl_context *clContext, cl_command_queue *clQueue)
-{
-	cl_int ciErrNum;
-	cl_platform_id cpPlatform = 0;
-	cl_uint num_platforms;
-	ciErrNum = clGetPlatformIDs(0, NULL, &num_platforms);
-	if (ciErrNum != CL_SUCCESS) {
-		printf("Error %d in clGetPlatformIDs call.\n", ciErrNum);
-		return false;
-	}
-	if (num_platforms == 0) {
-		printf("No OpenCL platform found.\n");
-		return false;
-	}
-	cl_platform_id *clPlatformIDs = new cl_platform_id[num_platforms];
-	ciErrNum = clGetPlatformIDs(num_platforms, clPlatformIDs, NULL);
-	char chBuffer[1024];
-	for (cl_uint i = 0; i < num_platforms; ++i) {
-		ciErrNum = clGetPlatformInfo(clPlatformIDs[i],
-		                             CL_PLATFORM_NAME,
-		                             1024,
-		                             chBuffer,
-		                             NULL);
-		if (ciErrNum == CL_SUCCESS) {
-			cpPlatform = clPlatformIDs[i];
-		}
-	}
-
-#if defined(_WIN32)
-	cl_context_properties props[] = {
-		CL_GL_CONTEXT_KHR, (cl_context_properties)wglGetCurrentContext(),
-		CL_WGL_HDC_KHR, (cl_context_properties)wglGetCurrentDC(),
-		CL_CONTEXT_PLATFORM, (cl_context_properties)cpPlatform,
-		0
-	};
-#elif defined(__APPLE__)
-	CGLContextObj kCGLContext = CGLGetCurrentContext();
-	CGLShareGroupObj kCGLShareGroup = CGLGetShareGroup(kCGLContext);
-	cl_context_properties props[] = {
-		CL_CONTEXT_PROPERTY_USE_CGL_SHAREGROUP_APPLE,
-		(cl_context_properties)kCGLShareGroup,
-		0
-	};
-#else
-	cl_context_properties props[] = {
-		CL_GL_CONTEXT_KHR, (cl_context_properties)glXGetCurrentContext(),
-		CL_GLX_DISPLAY_KHR, (cl_context_properties)glXGetCurrentDisplay(),
-		CL_CONTEXT_PLATFORM, (cl_context_properties)cpPlatform,
-		0
-	};
-#endif
-	delete [] clPlatformIDs;
-
-#if defined(__APPLE__)
-	*clContext = clCreateContext(props,
-	                             0,
-	                             NULL,
-	                             clLogMessagesToStdoutAPPLE,
-	                             NULL,
-	                             &ciErrNum);
-	if (ciErrNum != CL_SUCCESS) {
-		printf("Error %d in clCreateContext\n", ciErrNum);
-		return false;
-	}
-
-	size_t devicesSize = 0;
-	clGetGLContextInfoAPPLE(*clContext,
-	                        kCGLContext,
-	                        CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE,
-	                        0,
-	                        NULL,
-	                        &devicesSize);
-	int numDevices = int(devicesSize / sizeof(cl_device_id));
-	if (numDevices == 0) {
-		printf("No sharable devices.\n");
-		return false;
-	}
-	cl_device_id *clDevices = new cl_device_id[numDevices];
-	clGetGLContextInfoAPPLE(*clContext,
-	                        kCGLContext,
-	                        CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE,
-	                        numDevices * sizeof(cl_device_id),
-	                        clDevices, NULL);
-#else
-	cl_uint numDevices = 0;
-	clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU, 0, NULL, &numDevices);
-	if (numDevices == 0) {
-		printf("No sharable devices.\n");
-		return false;
-	}
-	cl_device_id *clDevices = new cl_device_id[numDevices];
-	clGetDeviceIDs(cpPlatform, CL_DEVICE_TYPE_GPU, numDevices, clDevices, NULL);
-
-	*clContext = clCreateContext(props,
-	                             numDevices,
-	                             clDevices,
-	                             NULL,
-	                             NULL,
-	                             &ciErrNum);
-	if (ciErrNum != CL_SUCCESS) {
-		printf("Error %d in clCreateContext\n", ciErrNum);
-		delete [] clDevices;
-		return false;
-	}
-#endif
-
-	*clQueue = clCreateCommandQueue(*clContext, clDevices[0], 0, &ciErrNum);
-	delete [] clDevices;
-	if (ciErrNum != CL_SUCCESS) {
-		printf("Error %d in clCreateCommandQueue\n", ciErrNum);
-		return false;
-	}
-	return true;
-}
-
-static void uninitCL(cl_context clContext, cl_command_queue clQueue)
-{
-	/* It's possible that OpenCL wasn't used and hence wasn't initialized yet,
-	 * no need to cleanup in this case.
-	 */
-	if (clReleaseCommandQueue) {
-		clReleaseCommandQueue(clQueue);
-		clReleaseContext(clContext);
-	}
-}
-
-#endif  /* OSD_EXAMPLE_CL_INIT_H */
diff --git a/intern/opensubdiv/opensubdiv_capi.cc b/intern/opensubdiv/opensubdiv_capi.cc
index e353801..88b271a 100644
--- a/intern/opensubdiv/opensubdiv_capi.cc
+++ b/intern/opensubdiv/opensubdiv_capi.cc
@@ -33,225 +33,116 @@
 #include <GL/glew.h>
 
 #include <opensubdiv/osd/glMesh.h>
-#include <opensubdiv/osd/glDrawRegistry.h>
-#include <opensubdiv/osdutil/evaluator_capi.h>
-#include <opensubdiv/osdutil/topology.h>
-#include <opensubdiv/osdutil/mesh.h>
+#include <opensubdiv/far/topologyRefinerFactory.h>
 
-// CPU Backend
+/* CPU Backend */
 #include <opensubdiv/osd/cpuGLVertexBuffer.h>
-#include <opensubdiv/osd/cpuComputeContext.h>
-#include <opensubdiv/osd/cpuComputeController.h>
+#include <opensubdiv/osd/cpuEvaluator.h>
 
 #ifdef OPENSUBDIV_HAS_OPENMP
-#  include <opensubdiv/osd/ompComputeController.h>
-#endif
+#  include <opensubdiv/osd/ompEvaluator.h>
+#endif  /* OPENSUBDIV_HAS_OPENMP */
 
 #ifdef OPEN

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list