[Bf-blender-cvs] [5a794c96850] master: OpenSubdiv: Use own utility header
Sergey Sharybin
noreply at git.blender.org
Wed Jan 16 11:33:40 CET 2019
Commit: 5a794c96850e4023ef10582a7de6128e7b7a1f3b
Author: Sergey Sharybin
Date: Tue Jan 15 11:08:33 2019 +0100
Branches: master
https://developer.blender.org/rB5a794c96850e4023ef10582a7de6128e7b7a1f3b
OpenSubdiv: Use own utility header
Replaces direct access to std.
===================================================================
M intern/opensubdiv/internal/opensubdiv_converter_factory.cc
M intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h
M intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc
M intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc
M intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
M intern/opensubdiv/internal/opensubdiv_gl_mesh.cc
M intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc
M intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc
M intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h
M intern/opensubdiv/internal/opensubdiv_topology_refiner.cc
M intern/opensubdiv/internal/opensubdiv_util.cc
M intern/opensubdiv/internal/opensubdiv_util.h
===================================================================
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc
index 4f3fb1462f3..df78e12104d 100644
--- a/intern/opensubdiv/internal/opensubdiv_converter_factory.cc
+++ b/intern/opensubdiv/internal/opensubdiv_converter_factory.cc
@@ -24,16 +24,19 @@
#include <cassert>
#include <cstdio>
-#include <stack>
-#include <vector>
#include <opensubdiv/far/topologyRefinerFactory.h>
#include "internal/opensubdiv_converter_internal.h"
#include "internal/opensubdiv_converter_orient.h"
#include "internal/opensubdiv_internal.h"
+#include "internal/opensubdiv_util.h"
#include "opensubdiv_converter_capi.h"
+using opensubdiv_capi::min;
+using opensubdiv_capi::vector;
+using opensubdiv_capi::stack;
+
struct TopologyRefinerData {
const OpenSubdiv_Converter* converter;
};
@@ -119,8 +122,8 @@ TopologyRefinerFactory<TopologyRefinerData>::assignComponentTopology(
// TODO(sergey): Find a way to move this to an utility function.
#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
// Make face normals consistent.
- std::vector<bool> face_used(num_faces, false);
- std::stack<int> traverse_stack;
+ vector<bool> face_used(num_faces, false);
+ stack<int> traverse_stack;
int face_start = 0, num_traversed_faces = 0;
// Traverse all islands.
while (num_traversed_faces != num_faces) {
@@ -182,7 +185,7 @@ TopologyRefinerFactory<TopologyRefinerData>::assignComponentTopology(
#endif // OPENSUBDIV_ORIENT_TOPOLOGY
// Vertex relations.
const int num_vertices = converter->getNumVertices(converter);
- std::vector<int> vertex_faces, vertex_edges;
+ vector<int> vertex_faces, vertex_edges;
for (int vertex_index = 0; vertex_index < num_vertices; ++vertex_index) {
// Vertex-faces.
IndexArray dst_vertex_faces = getBaseVertexFaces(refiner, vertex_index);
@@ -199,7 +202,7 @@ TopologyRefinerFactory<TopologyRefinerData>::assignComponentTopology(
// TODO(sergey): Find a way to move this to an utility function.
#ifdef OPENSUBDIV_ORIENT_TOPOLOGY
// Order vertex edges and faces to be in a CCW order.
- std::fill(face_used.begin(), face_used.end(), false);
+ fill(face_used.begin(), face_used.end(), false);
// Number of edges and faces added to the ordered array.
int edge_count_ordered = 0, face_count_ordered = 0;
// Add loose edges straight into the edges array.
@@ -387,8 +390,8 @@ inline bool TopologyRefinerFactory<TopologyRefinerData>::assignComponentTags(
const float sharpness0 = refiner._levels[0]->getEdgeSharpness(edge0);
const float sharpness1 = refiner._levels[0]->getEdgeSharpness(edge1);
// TODO(sergey): Find a better mixing between edge and vertex sharpness.
- sharpness += std::min(sharpness0, sharpness1);
- sharpness = std::min(sharpness, 1.0f);
+ sharpness += min(sharpness0, sharpness1);
+ sharpness = min(sharpness, 1.0f);
}
setBaseVertexSharpness(refiner, vertex_index, sharpness);
}
diff --git a/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h b/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h
index 3125bc600e5..3e946595bba 100644
--- a/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h
+++ b/intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h
@@ -21,9 +21,9 @@
#include "internal/opensubdiv_converter_orient.h"
-#include <algorithm>
#include <cmath>
-#include <utility>
+
+#include "internal/opensubdiv_util.h"
namespace opensubdiv_capi {
@@ -54,8 +54,8 @@ inline void reverseFaceLoops(
for (int i = 0; i < num_face_vertices / 2; ++i) {
const int j = num_face_vertices - i - 1;
if (i != j) {
- std::swap((*face_vertices)[i], (*face_vertices)[j]);
- std::swap((*face_edges)[i], (*face_edges)[j]);
+ swap((*face_vertices)[i], (*face_vertices)[j]);
+ swap((*face_edges)[i], (*face_edges)[j]);
}
}
reverseFaceVertices(&(*face_vertices)[0], num_face_vertices);
diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc
index 875f503b9ab..f5bc12efa84 100644
--- a/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc
+++ b/intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc
@@ -42,9 +42,10 @@
#include <cuda.h>
#include <cuda_gl_interop.h>
#include <cuda_runtime_api.h>
-#include <algorithm>
#include <cstdio>
+#include "internal/opensubdiv_util.h"
+
#define message(fmt, ...)
// #define message(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
#define error(fmt, ...) fprintf(stderr, fmt, __VA_ARGS__)
@@ -125,7 +126,7 @@ int cutGetMaxGflopsDeviceId() {
while (current_device < device_count) {
cuDeviceComputeCapability(&compat_major, &compat_minor, current_device);
if (compat_major > 0 && compat_major < 9999) {
- best_SM_arch = std::max(best_SM_arch, compat_major);
+ best_SM_arch = max(best_SM_arch, compat_major);
}
current_device++;
}
diff --git a/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc
index 00f58af894a..f6f1458b189 100644
--- a/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc
+++ b/intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc
@@ -36,8 +36,8 @@
#include <cstdio>
#include <cstring>
-#include <string>
-#include <vector>
+
+#include "internal/opensubdiv_util.h"
#define message(...) // fprintf(stderr, __VA_ARGS__)
#define error(...) fprintf(stderr, __VA_ARGS__)
@@ -56,7 +56,7 @@ cl_platform_id findPlatform() {
error("No OpenCL platform found.\n");
return NULL;
}
- std::vector<cl_platform_id> cl_platform_ids(num_platforms);
+ vector<cl_platform_id> cl_platform_ids(num_platforms);
ci_error_number = clGetPlatformIDs(num_platforms, &cl_platform_ids[0], NULL);
char ch_buffer[1024];
for (cl_uint i = 0; i < num_platforms; ++i) {
@@ -94,7 +94,7 @@ int findExtensionSupportedDevice(cl_device_id* cl_devices,
}
if (extensions_size > 0) {
// Get extensions string.
- std::string extensions('\0', extensions_size);
+ string extensions('\0', extensions_size);
cl_error_number = clGetDeviceInfo(cl_devices[i],
CL_DEVICE_EXTENSIONS,
extensions_size,
@@ -109,7 +109,7 @@ int findExtensionSupportedDevice(cl_device_id* cl_devices,
//
// The actual string would be "cl_khr_d3d11_sharing"
// or "cl_nv_d3d11_sharing"
- if (extensions.find(extension_name) != std::string::npos) {
+ if (extensions.find(extension_name) != string::npos) {
return i;
}
}
@@ -203,7 +203,7 @@ bool CLDeviceContext::Initialize() {
error("No sharable devices.\n");
return false;
}
- std::vector<cl_device_id> cl_devices(num_devices);
+ vector<cl_device_id> cl_devices(num_devices);
clGetGLContextInfoAPPLE(_clContext, kCGLContext,
CL_CGL_DEVICES_FOR_SUPPORTED_VIRTUAL_SCREENS_APPLE,
num_devices * sizeof(cl_device_id),
@@ -219,7 +219,7 @@ bool CLDeviceContext::Initialize() {
return false;
}
// Create the device list.
- std::vector<cl_device_id> cl_devices(num_devices);
+ vector<cl_device_id> cl_devices(num_devices);
clGetDeviceIDs(cp_platform,
CL_DEVICE_TYPE_GPU,
num_devices,
diff --git a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
index 564c8a8c3ec..71bc75c6bb3 100644
--- a/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
+++ b/intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc
@@ -20,7 +20,6 @@
#include <cassert>
#include <cstdio>
-#include <vector>
#ifdef _MSC_VER
# include <iso646.h>
@@ -40,6 +39,7 @@
#include "internal/opensubdiv_topology_refiner_internal.h"
#include "internal/opensubdiv_util.h"
+#include "internal/opensubdiv_util.h"
#include "opensubdiv_topology_refiner_capi.h"
using OpenSubdiv::Osd::BufferDescriptor;
@@ -68,7 +68,7 @@ namespace {
// Helper class to wrap numerous of patch coordinates into a buffer.
// Used to pass coordinates to the CPU evaluator. Other evaluators are not
// supported.
-class PatchCoordBuffer : public std::vector<PatchCoord> {
+class PatchCoordBuffer : public vector<PatchCoord> {
public:
static PatchCoordBuffer* Create(int size) {
PatchCoordBuffer* buffer = new PatchCoordBuffer();
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc
index 649c5ce7b7d..06ff0276464 100644
--- a/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh.cc
@@ -106,9 +106,6 @@ typedef Mesh<GLVertexBuffer,
GLPatchTable> OsdGLSLComputeMesh;
#endif
-#include <string>
-#include <vector>
-
#include "MEM_guardedalloc.h"
#include "opensubdiv_topology_refiner_capi.h"
@@ -116,6 +113,9 @@ typedef Mesh<GLVertexBuffer,
#include "internal/opensubdiv_gl_mesh_fvar.h"
#include "internal/opensubdiv_gl_mesh_internal.h"
#include "internal/opensubdiv_topology_refiner_internal.h"
+#include "internal/opensubdiv_util.h"
+
+using opensubdiv_capi::vector;
namespace {
@@ -267,8 +267,8 @@ struct OpenSubdiv_GLMesh *openSubdiv_createOsdGLMeshFromTopologyRefiner(
if (osd_topology_refiner->GetNumFVarChannels() > 0) {
// TODO(sergey): This is a temporary stub to get things compiled. Need
// to store base level UVs somewhere else.
- std::vector<float> uvs;
- std::vector<float> fvar_data_buffer;
+ vector<float> uvs;
+ vector<float> fvar_data_buffer;
opensubdiv_capi::interpolateFVarData(*osd_topology_refiner,
uvs,
&fvar_data_buffer);
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc
index 0d2f8dc9842..c1efc439b2e 100644
--- a/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc
@@ -37,6 +37,7 @@
#include "inte
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list