Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/intern
diff options
context:
space:
mode:
authorSergey Sharybin <sergey.vfx@gmail.com>2019-01-15 13:08:33 +0300
committerSergey Sharybin <sergey.vfx@gmail.com>2019-01-16 13:00:42 +0300
commit5a794c96850e4023ef10582a7de6128e7b7a1f3b (patch)
tree10450eebb7bf28cf1ac965d7fc86b1c712cb5baf /intern
parentf36f60543ff8b99066f43a9df9a62b43cc3153c3 (diff)
OpenSubdiv: Use own utility header
Replaces direct access to std.
Diffstat (limited to 'intern')
-rw-r--r--intern/opensubdiv/internal/opensubdiv_converter_factory.cc19
-rw-r--r--intern/opensubdiv/internal/opensubdiv_converter_orient_impl.h8
-rw-r--r--intern/opensubdiv/internal/opensubdiv_device_context_cuda.cc5
-rw-r--r--intern/opensubdiv/internal/opensubdiv_device_context_opencl.cc14
-rw-r--r--intern/opensubdiv/internal/opensubdiv_evaluator_internal.cc4
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh.cc10
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh_draw.cc3
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc10
-rw-r--r--intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h8
-rw-r--r--intern/opensubdiv/internal/opensubdiv_topology_refiner.cc5
-rw-r--r--intern/opensubdiv/internal/opensubdiv_util.cc14
-rw-r--r--intern/opensubdiv/internal/opensubdiv_util.h14
12 files changed, 66 insertions, 48 deletions
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 "internal/opensubdiv_gl_mesh_fvar.h"
#include "internal/opensubdiv_gl_mesh_internal.h"
+#include "internal/opensubdiv_util.h"
#include "opensubdiv_capi.h"
#include "opensubdiv_gl_mesh_capi.h"
@@ -485,7 +486,7 @@ void drawPartitionPatchesRange(GLMeshInterface* mesh,
start_patch < traversed_patches + num_block_patches) {
const int num_control_verts = desc.GetNumControlVertices();
const int start_draw_patch = start_patch - traversed_patches;
- const int num_draw_patches = std::min(
+ const int num_draw_patches = min(
num_remained_patches, num_block_patches - start_draw_patch);
perform_drawElements(
program, i + start_draw_patch, num_draw_patches * num_control_verts,
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc
index 5c9033c8dd1..32787ef05a3 100644
--- a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.cc
@@ -21,6 +21,8 @@
#include <GL/glew.h>
#include <opensubdiv/far/primvarRefiner.h>
+#include "internal/opensubdiv_util.h"
+
namespace opensubdiv_capi {
////////////////////////////////////////////////////////////////////////////////
@@ -58,7 +60,7 @@ void GLMeshFVarData::create(
/// Expand fvar data to per-patch array.
const int max_level = topology_refiner->GetMaxLevel();
const int num_channels = patch_table->GetNumFVarChannels();
- std::vector<float> data;
+ vector<float> data;
int fvar_data_offset = 0;
channel_offsets.resize(num_channels);
for (int channel = 0; channel < num_channels; ++channel) {
@@ -122,8 +124,8 @@ struct FVarVertex {
};
void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner& refiner,
- const std::vector<float>& uvs,
- std::vector<float>* fvar_data) {
+ const vector<float>& uvs,
+ vector<float>* fvar_data) {
const int fvar_width = 2;
const int max_level = refiner.GetMaxLevel();
size_t fvar_data_offset = 0, values_offset = 0;
@@ -139,7 +141,7 @@ void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner& refiner,
if (refiner.IsUniform()) {
// For uniform we only keep the highest level of refinement.
fvar_data->resize(fvar_data->size() + num_values_max * fvar_width);
- std::vector<FVarVertex> buffer(num_values_total - num_values_max);
+ vector<FVarVertex> buffer(num_values_total - num_values_max);
FVarVertex* src = &buffer[0];
memcpy(src, &uvs[values_offset], num_values * sizeof(float));
// Defer the last level to treat separately with its alternate
diff --git a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h
index 039a94eaf86..0c5982f2c8b 100644
--- a/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h
+++ b/intern/opensubdiv/internal/opensubdiv_gl_mesh_fvar.h
@@ -26,7 +26,7 @@
#include <opensubdiv/far/topologyRefiner.h>
#include <opensubdiv/far/patchTable.h>
-#include <vector>
+#include "internal/opensubdiv_util.h"
namespace opensubdiv_capi {
@@ -44,13 +44,13 @@ class GLMeshFVarData {
unsigned int texture_buffer;
unsigned int offset_buffer;
- std::vector<int> channel_offsets;
+ vector<int> channel_offsets;
int fvar_width;
};
void interpolateFVarData(const OpenSubdiv::Far::TopologyRefiner& refiner,
- const std::vector<float>& uvs,
- std::vector<float>* fvar_data);
+ const vector<float>& uvs,
+ vector<float>* fvar_data);
} // namespace opensubdiv_capi
diff --git a/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc
index 1840a4fc989..296e373c31f 100644
--- a/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc
+++ b/intern/opensubdiv/internal/opensubdiv_topology_refiner.cc
@@ -25,6 +25,9 @@
#include "internal/opensubdiv_converter_internal.h"
#include "internal/opensubdiv_internal.h"
#include "internal/opensubdiv_topology_refiner_internal.h"
+#include "internal/opensubdiv_util.h"
+
+using opensubdiv_capi::vector;
namespace {
@@ -327,7 +330,7 @@ bool checkGeometryFacesMatch(
const int num_faces = base_level.GetNumFaces();
// TODO(sergey): Consider using data structure which keeps handful of
// elements on stack before doing heep allocation.
- std::vector<int> conv_face_vertices;
+ vector<int> conv_face_vertices;
for (int face_index = 0; face_index < num_faces; ++face_index) {
const ConstIndexArray& face_vertices =
base_level.GetFaceVertices(face_index);
diff --git a/intern/opensubdiv/internal/opensubdiv_util.cc b/intern/opensubdiv/internal/opensubdiv_util.cc
index 87bfce2116c..317d9d9e06a 100644
--- a/intern/opensubdiv/internal/opensubdiv_util.cc
+++ b/intern/opensubdiv/internal/opensubdiv_util.cc
@@ -28,20 +28,20 @@
namespace opensubdiv_capi {
-void stringSplit(std::vector<std::string>* tokens,
- const std::string& str,
- const std::string& separators,
+void stringSplit(vector<string>* tokens,
+ const string& str,
+ const string& separators,
bool skip_empty) {
size_t token_start = 0, token_length = 0;
for (size_t i = 0; i < str.length(); ++i) {
const char ch = str[i];
- if (separators.find(ch) == std::string::npos) {
+ if (separators.find(ch) == string::npos) {
// Append non-separator char to a token.
++token_length;
} else {
// Append current token to the list (if any).
if (token_length > 0 || !skip_empty) {
- std::string token = str.substr(token_start, token_length);
+ string token = str.substr(token_start, token_length);
tokens->push_back(token);
}
// Re-set token pointers,
@@ -52,8 +52,8 @@ void stringSplit(std::vector<std::string>* tokens,
// Append token which might be at the end of the string.
if ((token_length != 0) ||
(!skip_empty && token_start > 0 &&
- separators.find(str[token_start-1]) != std::string::npos)) {
- std::string token = str.substr(token_start, token_length);
+ separators.find(str[token_start-1]) != string::npos)) {
+ string token = str.substr(token_start, token_length);
tokens->push_back(token);
}
}
diff --git a/intern/opensubdiv/internal/opensubdiv_util.h b/intern/opensubdiv/internal/opensubdiv_util.h
index 1f5ddc00f01..e7123d9d97b 100644
--- a/intern/opensubdiv/internal/opensubdiv_util.h
+++ b/intern/opensubdiv/internal/opensubdiv_util.h
@@ -20,12 +20,20 @@
#ifndef OPENSUBDIV_UTIL_H_
#define OPENSUBDIV_UTIL_H_
+#include <algorithm>
#include <vector>
+#include <stack>
#include <string>
+#include <utility>
namespace opensubdiv_capi {
+using std::fill;
+using std::max;
+using std::min;
+using std::stack;
using std::string;
+using std::swap;
using std::vector;
#define foreach(x, y) for (x : y)
@@ -34,9 +42,9 @@ using std::vector;
#define STRINGIFY_APPEND(a, b) "" a #b
#define STRINGIFY(x) STRINGIFY_APPEND("", x)
-void stringSplit(std::vector<std::string>* tokens,
- const std::string& str,
- const std::string& separators,
+void stringSplit(vector<string>* tokens,
+ const string& str,
+ const string& separators,
bool skip_empty);
} // namespace opensubdiv_capi