[Bf-blender-cvs] [8f5f0aa] temp-cycles-microdisplacement: Allow building without OpenSubdiv

Mai Lavelle noreply at git.blender.org
Sun May 8 00:39:50 CEST 2016


Commit: 8f5f0aaabe359fdac623065934eb2666bf6e2ec5
Author: Mai Lavelle
Date:   Tue Apr 26 16:16:17 2016 -0400
Branches: temp-cycles-microdisplacement
https://developer.blender.org/rB8f5f0aaabe359fdac623065934eb2666bf6e2ec5

Allow building without OpenSubdiv

This makes cycles subdivision code respect build options, disabling OSD code paths when desired. Since Catmull-Clark
subdivision requires OSD this subdivision type is unavailable with OSD disabled and linear subdivision will be used as a
fallback.

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

M	CMakeLists.txt
M	intern/cycles/CMakeLists.txt
M	intern/cycles/blender/blender_mesh.cpp
M	intern/cycles/render/mesh.cpp
M	intern/cycles/render/mesh.h
M	intern/cycles/render/mesh_subdivision.cpp
M	intern/cycles/subd/CMakeLists.txt

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

diff --git a/CMakeLists.txt b/CMakeLists.txt
index 438cb1c..0d6e764 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -384,6 +384,7 @@ option(WITH_CYCLES					"Enable Cycles Render Engine" ON)
 option(WITH_CYCLES_STANDALONE		"Build Cycles standalone application" OFF)
 option(WITH_CYCLES_STANDALONE_GUI	"Build Cycles standalone with GUI" OFF)
 option(WITH_CYCLES_OSL				"Build Cycles with OSL support" ${_init_CYCLES_OSL})
+option(WITH_CYCLES_OPENSUBDIV		"Build Cycles with OpenSubdiv support" ON)
 option(WITH_CYCLES_CUDA_BINARIES	"Build Cycles CUDA binaries" OFF)
 set(CYCLES_CUDA_BINARIES_ARCH sm_20 sm_21 sm_30 sm_35 sm_37 sm_50 sm_52 CACHE STRING "CUDA architectures to build binaries for")
 mark_as_advanced(CYCLES_CUDA_BINARIES_ARCH)
@@ -2347,6 +2348,11 @@ if(WITH_CYCLES)
 			message(FATAL_ERROR "Cycles OSL requires WITH_LLVM, the library may not have been found. Configure LLVM or disable WITH_CYCLES_OSL")
 		endif()
 	endif()
+
+	if(WITH_CYCLES_OPENSUBDIV AND NOT WITH_OPENSUBDIV)
+		message(STATUS "WITH_CYCLES_OPENSUBDIV requires WITH_OPENSUBDIV to be ON, turning OFF")
+		set(WITH_CYCLES_OPENSUBDIV OFF)
+	endif()
 endif()
 
 if(WITH_INTERNATIONAL)
diff --git a/intern/cycles/CMakeLists.txt b/intern/cycles/CMakeLists.txt
index 3b6c25c..4876725 100644
--- a/intern/cycles/CMakeLists.txt
+++ b/intern/cycles/CMakeLists.txt
@@ -146,6 +146,10 @@ if(WITH_CYCLES_OSL)
 	)
 endif()
 
+if(WITH_CYCLES_OPENSUBDIV)
+	add_definitions(-DWITH_OPENSUBDIV)
+endif()
+
 set(WITH_CYCLES_DEVICE_OPENCL TRUE)
 set(WITH_CYCLES_DEVICE_CUDA TRUE)
 set(WITH_CYCLES_DEVICE_MULTI TRUE)
diff --git a/intern/cycles/blender/blender_mesh.cpp b/intern/cycles/blender/blender_mesh.cpp
index 081b315..db9a8c4 100644
--- a/intern/cycles/blender/blender_mesh.cpp
+++ b/intern/cycles/blender/blender_mesh.cpp
@@ -24,7 +24,6 @@
 #include "blender_session.h"
 #include "blender_util.h"
 
-#include "subd_mesh.h"
 #include "subd_patch.h"
 #include "subd_split.h"
 
diff --git a/intern/cycles/render/mesh.cpp b/intern/cycles/render/mesh.cpp
index 2e852f0..f7060d8 100644
--- a/intern/cycles/render/mesh.cpp
+++ b/intern/cycles/render/mesh.cpp
@@ -116,13 +116,17 @@ Mesh::Mesh()
 	has_volume = false;
 	has_surface_bssrdf = false;
 
+#ifdef WITH_OPENSUBDIV
 	osd_data = NULL;
+#endif
 }
 
 Mesh::~Mesh()
 {
 	delete bvh;
+#ifdef WITH_OPENSUBDIV
 	free_osd_data();
+#endif
 }
 
 void Mesh::reserve(int numverts, int numtris, int numcurves, int numcurvekeys, int numpatches)
@@ -156,7 +160,9 @@ void Mesh::clear()
 
 	patches.clear();
 	subpatches.clear();
+#ifdef WITH_OPENSUBDIV
 	free_osd_data();
+#endif
 
 	attributes.clear();
 	curve_attributes.clear();
diff --git a/intern/cycles/render/mesh.h b/intern/cycles/render/mesh.h
index 0e9777b..e37c334 100644
--- a/intern/cycles/render/mesh.h
+++ b/intern/cycles/render/mesh.h
@@ -39,7 +39,9 @@ class Scene;
 class SceneParams;
 class AttributeRequest;
 class DiagSplit;
+#ifdef WITH_OPENSUBDIV
 class MeshOsdData;
+#endif
 
 /* Mesh */
 
@@ -141,7 +143,9 @@ public:
 
 	vector<Patch> patches;
 	vector<SubPatch> subpatches;
+#ifdef WITH_OPENSUBDIV
 	MeshOsdData* osd_data;
+#endif
 
 	vector<uint> used_shaders;
 	AttributeSet attributes;
@@ -215,8 +219,10 @@ public:
 	/* Check if the mesh should be treated as instanced. */
 	bool is_instanced() const;
 
+#ifdef WITH_OPENSUBDIV
 	void update_osd();
 	void free_osd_data();
+#endif
 
 	void split_patches(DiagSplit *split);
 	void diced_subpatch_size(int subpatch_id, uint* num_verts, uint* num_tris, int* total_size);
diff --git a/intern/cycles/render/mesh_subdivision.cpp b/intern/cycles/render/mesh_subdivision.cpp
index 6281d4b..c67b966 100644
--- a/intern/cycles/render/mesh_subdivision.cpp
+++ b/intern/cycles/render/mesh_subdivision.cpp
@@ -14,6 +14,7 @@
  * limitations under the License.
  */
 
+#ifdef WITH_OPENSUBDIV
 /* TODO: Move the OpenSubdiv includes to a separate header. */
 #ifdef _MSC_VER
 #  include <iso646.h>
@@ -26,6 +27,7 @@
 #include <opensubdiv/far/patchTableFactory.h>
 #include <opensubdiv/far/patchMap.h>
 #include <opensubdiv/far/ptexIndices.h>
+#endif
 
 #include "bvh.h"
 #include "bvh_build.h"
@@ -51,10 +53,11 @@
 #include "../subd/subd_split.h"
 #include "../subd/subd_patch.h"
 
-using namespace OpenSubdiv;
-
 CCL_NAMESPACE_BEGIN
 
+#ifdef WITH_OPENSUBDIV
+using namespace OpenSubdiv;
+
 struct OsdVertex {
 	float3 v;
 
@@ -250,6 +253,7 @@ struct OsdPatch : Patch {
 	bool is_triangle() { return !mesh->patches[patch].is_quad(); }
 	BoundBox bound() { return BoundBox::empty; }
 };
+#endif
 
 static float3 patch_normal(Mesh* mesh, int patch) {
 	Mesh::Patch& t = mesh->patches[patch];
@@ -333,18 +337,23 @@ void Mesh::dice_subpatch(TessellatedSubPatch* diced, int subpatch_id)
 	diced->shader = reinterpret_cast<ShaderManager*>(NULL)->get_shader_id(patch.shader, this, true);
 	diced->smooth = patch.smooth;
 
+#ifdef WITH_OPENSUBDIV
 	OsdPatch osd_patch;
+#endif
 	LinearQuadPatch quad_patch;
 	LinearTrianglePatch tri_patch;
 	ccl::Patch* subd_patch;
 
+#ifdef WITH_OPENSUBDIV
 	if(subdivision_type == SUBDIVISION_CATMULL_CLARK) {
 		osd_patch.mesh = this;
 		osd_patch.patch = subpatches[subpatch_id].patch;
 
 		subd_patch = &osd_patch;
 	}
-	else {
+	else
+#endif
+	{
 		Attribute *attr_vN = attributes.find(ATTR_STD_VERTEX_NORMAL);
 		float3 *vN = attr_vN->data_float3();
 
@@ -431,12 +440,15 @@ void Mesh::dice_subpatch(TessellatedSubPatch* diced, int subpatch_id)
 
 void Mesh::split_patches(DiagSplit *split)
 {
+#ifdef WITH_OPENSUBDIV
 	update_osd();
+#endif
 
 	Attribute *attr_vN = attributes.find(ATTR_STD_VERTEX_NORMAL);
 	float3 *vN = attr_vN->data_float3();
 
 	for(int p = 0; p < patches.size(); p++) {
+#ifdef WITH_OPENSUBDIV
 		if(subdivision_type == SUBDIVISION_CATMULL_CLARK) {
 			OsdPatch patch;
 			patch.mesh = this;
@@ -447,7 +459,9 @@ void Mesh::split_patches(DiagSplit *split)
 			else 
 				split->split_triangle(&patch);
 		}
-		else {
+		else
+#endif
+		{
 			if(patches[p].is_quad()) {
 				LinearQuadPatch patch;
 
diff --git a/intern/cycles/subd/CMakeLists.txt b/intern/cycles/subd/CMakeLists.txt
index 1ccf80d..2b9b886 100644
--- a/intern/cycles/subd/CMakeLists.txt
+++ b/intern/cycles/subd/CMakeLists.txt
@@ -13,22 +13,16 @@ set(INC_SYS
 
 set(SRC
 	subd_dice.cpp
-	subd_mesh.cpp
 	subd_patch.cpp
 	subd_split.cpp
 )
 
 set(SRC_HEADERS
 	subd_dice.h
-	subd_mesh.h
 	subd_patch.h
 	subd_split.h
 )
 
-if(WITH_CYCLES_OPENSUBDIV)
-	add_definitions(-DWITH_OPENSUBDIV)
-endif()
-
 include_directories(${INC})
 include_directories(SYSTEM ${INC_SYS})




More information about the Bf-blender-cvs mailing list