[Bf-blender-cvs] [a040157] master: OpenSubdiv: Add new OpenSubdiv related files

Sergey Sharybin noreply at git.blender.org
Mon Jul 20 22:30:54 CEST 2015


Commit: a040157e5dd7227fc61ee2608f30f2492db167be
Author: Sergey Sharybin
Date:   Mon Jul 20 15:18:35 2015 +0200
Branches: master
https://developer.blender.org/rBa040157e5dd7227fc61ee2608f30f2492db167be

OpenSubdiv: Add new OpenSubdiv related files

This includes C-API bindings in intern/opensubdiv and CMAke module
which finds the OpenSubdiv library. This filea are not in use so
far, making it a separate commit to make actual integration commit
more clear.

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

A	build_files/cmake/Modules/FindOpenSubdiv.cmake
A	intern/opensubdiv/CMakeLists.txt
A	intern/opensubdiv/SConscript
A	intern/opensubdiv/gpu_shader_opensubd_display.glsl
A	intern/opensubdiv/opensubdiv_capi.cc
A	intern/opensubdiv/opensubdiv_capi.h
A	intern/opensubdiv/opensubdiv_converter.cc
A	intern/opensubdiv/opensubdiv_converter_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
A	intern/opensubdiv/opensubdiv_evaluator_capi.cc
A	intern/opensubdiv/opensubdiv_gpu_capi.cc
A	intern/opensubdiv/opensubdiv_intern.h
A	intern/opensubdiv/opensubdiv_partitioned.h
A	intern/opensubdiv/opensubdiv_utils_capi.cc

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

diff --git a/build_files/cmake/Modules/FindOpenSubdiv.cmake b/build_files/cmake/Modules/FindOpenSubdiv.cmake
new file mode 100644
index 0000000..efbe8a9
--- /dev/null
+++ b/build_files/cmake/Modules/FindOpenSubdiv.cmake
@@ -0,0 +1,111 @@
+# - Find OpenSubdiv library
+# Find the native OpenSubdiv includes and library
+# This module defines
+#  OPENSUBDIV_INCLUDE_DIRS, where to find OpenSubdiv headers, Set when
+#                           OPENSUBDIV_INCLUDE_DIR is found.
+#  OPENSUBDIV_LIBRARIES, libraries to link against to use OpenSubdiv.
+#  OPENSUBDIV_ROOT_DIR, the base directory to search for OpenSubdiv.
+#                        This can also be an environment variable.
+#  OPENSUBDIV_FOUND, if false, do not try to use OpenSubdiv.
+#
+# also defined, but not for general use are
+#  OPENSUBDIV_LIBRARY, where to find the OpenSubdiv library.
+
+#=============================================================================
+# Copyright 2013 Blender Foundation.
+#
+# Distributed under the OSI-approved BSD License (the "License");
+# see accompanying file Copyright.txt for details.
+#
+# This software is distributed WITHOUT ANY WARRANTY; without even the
+# implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+# See the License for more information.
+#=============================================================================
+
+# If OPENSUBDIV_ROOT_DIR was defined in the environment, use it.
+IF(NOT OPENSUBDIV_ROOT_DIR AND NOT $ENV{OPENSUBDIV_ROOT_DIR} STREQUAL "")
+  SET(OPENSUBDIV_ROOT_DIR $ENV{OPENSUBDIV_ROOT_DIR})
+ENDIF()
+
+SET(_opensubdiv_FIND_COMPONENTS
+  osdGPU
+  osdCPU
+)
+
+SET(_opensubdiv_SEARCH_DIRS
+  ${OPENSUBDIV_ROOT_DIR}
+  /usr/local
+  /sw # Fink
+  /opt/local # DarwinPorts
+  /opt/csw # Blastwave
+  /opt/lib/opensubdiv
+)
+
+FIND_PATH(OPENSUBDIV_INCLUDE_DIR
+  NAMES
+    opensubdiv/osd/mesh.h
+  HINTS
+    ${_opensubdiv_SEARCH_DIRS}
+  PATH_SUFFIXES
+    include
+)
+
+SET(_opensubdiv_LIBRARIES)
+FOREACH(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
+  STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
+
+  FIND_LIBRARY(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY
+    NAMES
+      ${COMPONENT}
+    HINTS
+      ${_opensubdiv_SEARCH_DIRS}
+    PATH_SUFFIXES
+      lib64 lib
+    )
+  LIST(APPEND _opensubdiv_LIBRARIES "${OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY}")
+ENDFOREACH()
+
+MACRO(OPENSUBDIV_CHECK_CONTROLLER
+      controller_include_file
+      variable_name)
+  IF(EXISTS "${OPENSUBDIV_INCLUDE_DIR}/opensubdiv/osd/${controller_include_file}")
+    SET(${variable_name} TRUE)
+  ELSE()
+    SET(${variable_name} FALSE)
+  ENDIF()
+ENDMACRO()
+
+
+# handle the QUIETLY and REQUIRED arguments and set OPENSUBDIV_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(OpenSubdiv DEFAULT_MSG
+    _opensubdiv_LIBRARIES OPENSUBDIV_INCLUDE_DIR)
+
+IF(OPENSUBDIV_FOUND)
+  SET(OPENSUBDIV_LIBRARIES ${_opensubdiv_LIBRARIES})
+  SET(OPENSUBDIV_INCLUDE_DIRS ${OPENSUBDIV_INCLUDE_DIR})
+
+  # Find available compute controllers.
+
+  FIND_PACKAGE(OpenMP)
+  IF(OPENMP_FOUND)
+    SET(OPENSUBDIV_HAS_OPENMP TRUE)
+  ELSE()
+    SET(OPENSUBDIV_HAS_OPENMP FALSE)
+  ENDIF()
+
+  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(
+  OPENSUBDIV_INCLUDE_DIR
+)
+FOREACH(COMPONENT ${_opensubdiv_FIND_COMPONENTS})
+  STRING(TOUPPER ${COMPONENT} UPPERCOMPONENT)
+  MARK_AS_ADVANCED(OPENSUBDIV_${UPPERCOMPONENT}_LIBRARY)
+ENDFOREACH()
diff --git a/intern/opensubdiv/CMakeLists.txt b/intern/opensubdiv/CMakeLists.txt
new file mode 100644
index 0000000..3f88ba5
--- /dev/null
+++ b/intern/opensubdiv/CMakeLists.txt
@@ -0,0 +1,90 @@
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2013, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Sergey Sharybin.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+set(INC
+	.
+	../guardedalloc
+)
+
+set(INC_SYS
+	${OPENSUBDIV_INCLUDE_DIR}
+	${GLEW_INCLUDE_PATH}
+)
+
+set(SRC
+	opensubdiv_capi.cc
+	opensubdiv_converter.cc
+	opensubdiv_device_context_cuda.cc
+	opensubdiv_device_context_opencl.cc
+	opensubdiv_evaluator_capi.cc
+	opensubdiv_gpu_capi.cc
+	opensubdiv_utils_capi.cc
+
+	opensubdiv_capi.h
+	opensubdiv_converter_capi.h
+	opensubdiv_device_context_cuda.h
+	opensubdiv_device_context_opencl.h
+	opensubdiv_intern.h
+	opensubdiv_partitioned.h
+)
+
+macro(OPENSUBDIV_DEFINE_COMPONENT component)
+	if(${${component}})
+		add_definitions(-D${component})
+	endif()
+endmacro()
+
+OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_OPENMP)
+# TODO(sergey): OpenCL is not tested and totally unstable atm.
+# OPENSUBDIV_DEFINE_COMPONENT(OPENSUBDIV_HAS_OPENCL)
+# 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)
+
+data_to_c_simple(gpu_shader_opensubd_display.glsl SRC)
+
+add_definitions(-DGLEW_STATIC)
+
+if(WIN32)
+	add_definitions(-DNOMINMAX)
+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
+		../../extern/clew/include
+	)
+	add_definitions(-DOPENSUBDIV_HAS_CLEW)
+endif()
+
+blender_add_lib(bf_intern_opensubdiv "${SRC}" "${INC}" "${INC_SYS}")
diff --git a/intern/opensubdiv/SConscript b/intern/opensubdiv/SConscript
new file mode 100644
index 0000000..58926c6
--- /dev/null
+++ b/intern/opensubdiv/SConscript
@@ -0,0 +1,67 @@
+#!/usr/bin/env python
+#
+# ***** BEGIN GPL LICENSE BLOCK *****
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# The Original Code is Copyright (C) 2013, Blender Foundation
+# All rights reserved.
+#
+# The Original Code is: all of this file.
+#
+# Contributor(s): Sergey Sharybin.
+#
+# ***** END GPL LICENSE BLOCK *****
+
+import os
+
+Import('env')
+
+sources = env.Glob('*.cc')
+
+defs = [ 'GLEW_STATIC' ]
+
+if env['OURPLATFORM'] in ('win32-vc', 'win32-mingw', 'linuxcross', 'win64-vc', 'win64-mingw'):
+    defs += [ 'NOMINMAX' ]
+
+incs = '. ../guardedalloc #extern/clew/include/'
+incs += ' ' + env['BF_OPENSUBDIV_INC']
+incs += ' #/extern/glew/include'
+
+def checkOpenSubdivHeaderDefine(header, define):
+    include_path = Dir(env.subst(env['BF_OPENSUBDIV_INC'])).abspath
+    header_path = os.path.join(include_path, 'opensubdiv', 'osd', header)
+    if os.path.exists(header_path):
+        defs.append(define)
+        return True
+    return False
+
+checkOpenSubdivHeaderDefine("tbbComputeController.h", 'OPENSUBDIV_HAS_TBB')
+checkOpenSubdivHeaderDefine("gcdComputeController.h", 'OPENSUBDIV_HAS_GCD')
+if checkOpenSubdivHeaderDefine("clComputeController.h", 'OPENSUBDIV_HAS_OPENCL'):
+    defs += ['OPENSUBDIV_HAS_CLEW']
+    incs += ' #/extern/clew/include'
+if checkOpenSubdivHeaderDefine("cudaComputeController.h", 'OPENSUBDIV_HAS_CUDA'):
+    defs += ['OPENSUBDIV_HAS_CUEW']
+    incs += ' #/extern/cuew/include'
+checkOpenSubdivHeaderDefine("glslTransformFeedbackComputeController.h", 'OPENSUBDIV_HAS_GLSL_TRANSFORM_FEEDBACK')
+checkOpenSubdivHeaderDefine("osd/glslComputeController.h", 'OPENSUBDIV_HAS_GLSL_COMPUTE')
+
+# generated data files
+sources.extend((
+    os.path.join(env['DATA_SOURCES'], "gpu_shader_opensubd_display.glsl.c"),
+))
+
+env.BlenderLib('bf_intern_opensubdiv', sources, Split(incs), defs, libtype=['extern','player'], priority=[10, 185])
diff --git a/intern/opensubdiv/gpu_shader_opensubd_display.glsl b/intern/opensubdiv/gpu_shader_opensubd_display.glsl
new file mode 100644
index 0000000..fb46971
--- /dev/null
+++ b/intern/opensubdiv/gpu_shader_opensubd_display.glsl
@@ -0,0 +1,335 @@
+/*
+ * ***** BEGIN GPL LICENSE BLOCK *****
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with

@@ Diff output truncated at 10240 characters. @@




More information about the Bf-blender-cvs mailing list