mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2024-11-23 12:10:08 +00:00
Refactor error reporting system
- change error codes from situational to general (fatal / coding / run-time...) - pull error functions from Osd into Far - add a templated topology validation reporting system to Far::TopologyRefinerFactory - fix fallout on rest of code-base
This commit is contained in:
parent
9b3f25df2c
commit
cc6c0925a3
@ -25,11 +25,11 @@
|
||||
#include <D3D11.h>
|
||||
#include <D3Dcompiler.h>
|
||||
|
||||
#include <osd/error.h>
|
||||
#include <osd/vertex.h>
|
||||
#include <osd/d3d11DrawContext.h>
|
||||
#include <osd/d3d11DrawRegistry.h>
|
||||
#include <osd/d3d11PtexMipmapTexture.h>
|
||||
#include <far/error.h>
|
||||
|
||||
#include <osd/cpuD3D11VertexBuffer.h>
|
||||
#include <osd/cpuComputeContext.h>
|
||||
@ -1573,10 +1573,9 @@ updateRenderTarget(HWND hWnd) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackError(OpenSubdiv::Osd::ErrorType err, const char *message) {
|
||||
|
||||
callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
std::ostringstream s;
|
||||
s << "OsdError: " << err << "\n";
|
||||
s << "Error: " << err << "\n";
|
||||
s << message;
|
||||
OutputDebugString(s.str().c_str());
|
||||
}
|
||||
@ -1708,7 +1707,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
|
||||
}
|
||||
}
|
||||
|
||||
OpenSubdiv::Osd::SetErrorCallback(callbackError);
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||
|
||||
g_ptexColorFilename = colorFilename;
|
||||
if (g_ptexColorFilename == NULL) {
|
||||
|
@ -25,10 +25,10 @@
|
||||
#include <D3D11.h>
|
||||
#include <D3Dcompiler.h>
|
||||
|
||||
#include <osd/error.h>
|
||||
#include <osd/vertex.h>
|
||||
#include <osd/d3d11DrawContext.h>
|
||||
#include <osd/d3d11DrawRegistry.h>
|
||||
#include <far/error.h>
|
||||
|
||||
#include <osd/cpuD3D11VertexBuffer.h>
|
||||
#include <osd/cpuComputeContext.h>
|
||||
@ -1347,10 +1347,10 @@ updateRenderTarget(HWND hWnd) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackError(OpenSubdiv::Osd::ErrorType err, const char *message) {
|
||||
callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
|
||||
std::ostringstream s;
|
||||
s << "OsdError: " << err << "\n";
|
||||
s << "Error: " << err << "\n";
|
||||
s << message;
|
||||
OutputDebugString(s.str().c_str());
|
||||
}
|
||||
@ -1476,7 +1476,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmd
|
||||
|
||||
initShapes();
|
||||
|
||||
OpenSubdiv::Osd::SetErrorCallback(callbackError);
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||
|
||||
initD3D11(hWnd);
|
||||
|
||||
|
@ -48,10 +48,10 @@ GLFWmonitor* g_primary=0;
|
||||
#include <osd/cpuEvalLimitController.h>
|
||||
#include <osd/cpuVertexBuffer.h>
|
||||
#include <osd/cpuGLVertexBuffer.h>
|
||||
#include <osd/error.h>
|
||||
#include <osd/drawContext.h>
|
||||
#include <osd/mesh.h>
|
||||
#include <osd/vertex.h>
|
||||
#include <far/error.h>
|
||||
|
||||
#include <common/vtr_utils.h>
|
||||
#include "../common/stopwatch.h"
|
||||
@ -844,8 +844,8 @@ keyboard(GLFWwindow *, int key, int /* scancode */, int event, int /* mods */) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackError(OpenSubdiv::Osd::ErrorType err, const char *message) {
|
||||
printf("OsdError: %d\n", err);
|
||||
callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
printf("Error: %d\n", err);
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
@ -1017,7 +1017,7 @@ int main(int argc, char **argv) {
|
||||
}
|
||||
}
|
||||
|
||||
Osd::SetErrorCallback(callbackError);
|
||||
Far::SetErrorCallback(callbackError);
|
||||
|
||||
|
||||
initShapes();
|
||||
|
@ -42,10 +42,10 @@
|
||||
GLFWwindow* g_window = 0;
|
||||
GLFWmonitor* g_primary = 0;
|
||||
|
||||
#include <osd/error.h>
|
||||
#include <osd/vertex.h>
|
||||
#include <osd/glDrawContext.h>
|
||||
#include <osd/glDrawRegistry.h>
|
||||
#include <far/error.h>
|
||||
|
||||
#include <osd/cpuGLVertexBuffer.h>
|
||||
#include <osd/cpuComputeContext.h>
|
||||
@ -1208,9 +1208,8 @@ idle() {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackError(OpenSubdiv::Osd::ErrorType err, const char *message) {
|
||||
|
||||
printf("OsdError: %d\n", err);
|
||||
callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
printf("Error: %d\n", err);
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
@ -1259,7 +1258,7 @@ int main(int argc, char ** argv) {
|
||||
|
||||
initShapes();
|
||||
|
||||
OpenSubdiv::Osd::SetErrorCallback(callbackError);
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
|
@ -42,10 +42,10 @@
|
||||
GLFWwindow* g_window=0;
|
||||
GLFWmonitor* g_primary=0;
|
||||
|
||||
#include <osd/error.h>
|
||||
#include <osd/vertex.h>
|
||||
#include <osd/glDrawContext.h>
|
||||
#include <osd/glDrawRegistry.h>
|
||||
#include <far/error.h>
|
||||
|
||||
#include <osd/cpuGLVertexBuffer.h>
|
||||
#include <osd/cpuComputeContext.h>
|
||||
@ -1105,9 +1105,8 @@ idle() {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackError(OpenSubdiv::Osd::ErrorType err, const char *message) {
|
||||
|
||||
printf("OsdError: %d\n", err);
|
||||
callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
printf("Error: %d\n", err);
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
@ -1153,7 +1152,7 @@ int main(int argc, char ** argv) {
|
||||
}
|
||||
}
|
||||
initShapes();
|
||||
OpenSubdiv::Osd::SetErrorCallback(callbackError);
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
|
@ -55,10 +55,10 @@ GLFWmonitor* g_primary = 0;
|
||||
#include <png.h>
|
||||
#endif
|
||||
|
||||
#include <osd/error.h>
|
||||
#include <osd/glDrawContext.h>
|
||||
#include <osd/glDrawRegistry.h>
|
||||
#include <osd/glPtexMipmapTexture.h>
|
||||
#include <far/error.h>
|
||||
|
||||
#include <osd/cpuGLVertexBuffer.h>
|
||||
#include <osd/cpuComputeContext.h>
|
||||
@ -2294,8 +2294,8 @@ void usage(const char *program) {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackError(OpenSubdiv::Osd::ErrorType err, const char *message) {
|
||||
printf("OsdError: %d\n", err);
|
||||
callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
printf("Error: %d\n", err);
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
@ -2376,7 +2376,7 @@ int main(int argc, char ** argv) {
|
||||
}
|
||||
}
|
||||
|
||||
OpenSubdiv::Osd::SetErrorCallback(callbackError);
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||
|
||||
g_shaderSource = g_defaultShaderSource;
|
||||
reloadShaderFile();
|
||||
|
@ -42,11 +42,11 @@
|
||||
GLFWwindow* g_window=0;
|
||||
GLFWmonitor* g_primary=0;
|
||||
|
||||
#include <osd/error.h>
|
||||
#include <osd/vertex.h>
|
||||
#include <osd/glDrawContext.h>
|
||||
#include <osd/glDrawRegistry.h>
|
||||
#include <osd/glMesh.h>
|
||||
#include <far/error.h>
|
||||
|
||||
#include <osd/cpuGLVertexBuffer.h>
|
||||
#include <osd/cpuComputeContext.h>
|
||||
@ -1514,9 +1514,8 @@ idle() {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackError(Osd::ErrorType err, const char *message) {
|
||||
|
||||
printf("OsdError: %d\n", err);
|
||||
callbackError(Far::ErrorType err, const char *message) {
|
||||
printf("Error: %d\n", err);
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
@ -1553,7 +1552,7 @@ int main(int argc, char ** argv) {
|
||||
g_level = atoi(argv[++i]);
|
||||
}
|
||||
}
|
||||
Osd::SetErrorCallback(callbackError);
|
||||
Far::SetErrorCallback(callbackError);
|
||||
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
|
@ -42,7 +42,7 @@
|
||||
GLFWwindow* g_window=0;
|
||||
GLFWmonitor* g_primary=0;
|
||||
|
||||
#include <osd/error.h>
|
||||
#include <far/error.h>
|
||||
#include <osd/vertex.h>
|
||||
#include <osd/glDrawContext.h>
|
||||
#include <osd/glDrawRegistry.h>
|
||||
@ -1712,9 +1712,8 @@ idle() {
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
static void
|
||||
callbackError(OpenSubdiv::Osd::ErrorType err, const char *message)
|
||||
{
|
||||
printf("OsdError: %d\n", err);
|
||||
callbackError(OpenSubdiv::Far::ErrorType err, const char *message) {
|
||||
printf("Error: %d\n", err);
|
||||
printf("%s", message);
|
||||
}
|
||||
|
||||
@ -1743,8 +1742,8 @@ setGLCoreProfile()
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
int main(int argc, char ** argv)
|
||||
{
|
||||
int main(int argc, char ** argv) {
|
||||
|
||||
bool fullscreen = false;
|
||||
std::string str;
|
||||
std::vector<char const *> animobjs;
|
||||
@ -1783,7 +1782,7 @@ int main(int argc, char ** argv)
|
||||
|
||||
g_fpsTimer.Start();
|
||||
|
||||
OpenSubdiv::Osd::SetErrorCallback(callbackError);
|
||||
OpenSubdiv::Far::SetErrorCallback(callbackError);
|
||||
|
||||
if (not glfwInit()) {
|
||||
printf("Failed to initialize GLFW\n");
|
||||
|
@ -25,6 +25,7 @@
|
||||
#-------------------------------------------------------------------------------
|
||||
# source & headers
|
||||
set(SOURCE_FILES
|
||||
error.cpp
|
||||
gregoryBasis.cpp
|
||||
patchDescriptor.cpp
|
||||
patchMap.cpp
|
||||
@ -40,6 +41,7 @@ set(PRIVATE_HEADER_FILES
|
||||
)
|
||||
|
||||
set(PUBLIC_HEADER_FILES
|
||||
error.h
|
||||
gregoryBasis.h
|
||||
kernelBatch.h
|
||||
kernelBatchDispatcher.h
|
||||
|
@ -22,7 +22,7 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
@ -30,24 +30,16 @@
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
||||
namespace Osd {
|
||||
namespace Far {
|
||||
|
||||
static ErrorCallbackFunc errorFunc = 0;
|
||||
|
||||
static char const * errors[] = {
|
||||
"OSD_NO_ERROR",
|
||||
"OSD_INTERNAL_CODING_ERROR",
|
||||
"OSD_CL_PROGRAM_BUILD_ERROR",
|
||||
"OSD_CL_KERNEL_CREATE_ERROR",
|
||||
"OSD_CL_RUNTIME_ERROR",
|
||||
"OSD_CUDA_GL_ERROR",
|
||||
"OSD_GL_ERROR",
|
||||
"OSD_GLSL_COMPILE_ERROR",
|
||||
"OSD_GLSL_LINK_ERROR",
|
||||
"OSD_D3D11_COMPILE_ERROR",
|
||||
"OSD_D3D11_COMPUTE_BUFFER_CREATE_ERROR",
|
||||
"OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR",
|
||||
"OSD_D3D11_BUFFER_MAP_ERROR"
|
||||
"NO_ERROR",
|
||||
"FATAL_ERROR",
|
||||
"INTERNAL_CODING_ERROR",
|
||||
"CODING_ERROR",
|
||||
"RUNTIME_ERROR"
|
||||
};
|
||||
|
||||
void SetErrorCallback(ErrorCallbackFunc func) {
|
||||
@ -71,7 +63,7 @@ void Error(ErrorType err, const char *format, ...) {
|
||||
va_start(argptr, format);
|
||||
vsnprintf(message, 10240, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
|
||||
if (errorFunc) {
|
||||
errorFunc(err, message);
|
||||
} else {
|
||||
@ -93,15 +85,15 @@ void Warning(const char *format, ...) {
|
||||
va_start(argptr, format);
|
||||
vsnprintf(message, 10240, format, argptr);
|
||||
va_end(argptr);
|
||||
|
||||
|
||||
if (warningFunc) {
|
||||
warningFunc(message);
|
||||
} else {
|
||||
printf("OSD_WARNING : %s\n", message);
|
||||
printf("WARNING : %s\n", message);
|
||||
}
|
||||
}
|
||||
|
||||
} // end namespace
|
||||
} // end namespace
|
||||
|
||||
} // end namespace OPENSUBDIV_VERSION
|
||||
} // end namespace OpenSubdiv
|
@ -22,34 +22,24 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#ifndef OSD_ERROR_H
|
||||
#define OSD_ERROR_H
|
||||
#ifndef FAR_ERROR_H
|
||||
#define FAR_ERROR_H
|
||||
|
||||
#include "../version.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
||||
namespace Osd {
|
||||
namespace Far {
|
||||
|
||||
typedef enum {
|
||||
OSD_NO_ERROR,
|
||||
OSD_INTERNAL_CODING_ERROR,
|
||||
OSD_CL_PROGRAM_BUILD_ERROR,
|
||||
OSD_CL_KERNEL_CREATE_ERROR,
|
||||
OSD_CL_RUNTIME_ERROR,
|
||||
OSD_CUDA_GL_ERROR,
|
||||
OSD_GL_ERROR,
|
||||
OSD_GLSL_COMPILE_ERROR,
|
||||
OSD_GLSL_LINK_ERROR,
|
||||
OSD_D3D11_COMPILE_ERROR,
|
||||
OSD_D3D11_COMPUTE_BUFFER_CREATE_ERROR,
|
||||
OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
OSD_D3D11_BUFFER_MAP_ERROR
|
||||
NO_ERROR, ///< No error. Move along.
|
||||
FATAL_ERROR, ///< Issue a fatal error and end the program.
|
||||
INTERNAL_CODING_ERROR, ///< Issue an internal programming error, but continue execution.
|
||||
CODING_ERROR, ///< Issue a generic programming error, but continue execution.
|
||||
RUNTIME_ERROR ///< Issue a generic runtime error, but continue execution.
|
||||
} ErrorType;
|
||||
|
||||
|
||||
|
||||
typedef void (*ErrorCallbackFunc)(ErrorType err, const char *message);
|
||||
|
||||
/// Sets the error callback function (default is "printf")
|
||||
@ -96,4 +86,4 @@ using namespace OPENSUBDIV_VERSION;
|
||||
|
||||
} // end namespace OpenSubdiv
|
||||
|
||||
#endif // OSD_ERROR_H
|
||||
#endif // FAR_ERROR_H
|
@ -91,15 +91,15 @@ private:
|
||||
static PatchTables * createAdaptive( TopologyRefiner const & refiner, Options options );
|
||||
|
||||
// High-level methods for identifying and populating patches associated with faces:
|
||||
static void identifyAdaptivePatches( TopologyRefiner const & refiner,
|
||||
PatchTypes<int> & patchInventory,
|
||||
static void identifyAdaptivePatches( TopologyRefiner const & refiner,
|
||||
PatchTypes<int> & patchInventory,
|
||||
std::vector<PatchFaceTag> & patchTags,
|
||||
Options options );
|
||||
|
||||
static void populateAdaptivePatches( TopologyRefiner const & refiner,
|
||||
PatchTypes<int> const & patchInventory,
|
||||
static void populateAdaptivePatches( TopologyRefiner const & refiner,
|
||||
PatchTypes<int> const & patchInventory,
|
||||
std::vector<PatchFaceTag> const & patchTags,
|
||||
PatchTables * tables,
|
||||
PatchTables * tables,
|
||||
Options options );
|
||||
|
||||
// Methods for allocating and managing the patch table data arrays:
|
||||
|
@ -21,12 +21,13 @@
|
||||
// KIND, either express or implied. See the Apache License for the specific
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
#include "../sdc/type.h"
|
||||
#include "../sdc/options.h"
|
||||
#include "../sdc/crease.h"
|
||||
#include "../vtr/level.h"
|
||||
#include "../far/topologyRefiner.h"
|
||||
#include "../far/topologyRefinerFactory.h"
|
||||
#include "../far/topologyRefiner.h"
|
||||
#include "../vtr/level.h"
|
||||
|
||||
#if _MSC_VER
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
@ -78,8 +79,8 @@ TopologyRefinerFactoryBase::validateComponentTopologySizing(TopologyRefiner& ref
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
TopologyRefinerFactoryBase::validateVertexComponentTopologyAssignment(TopologyRefiner& refiner) {
|
||||
bool
|
||||
TopologyRefinerFactoryBase::validateVertexComponentTopologyAssignment(TopologyRefiner& refiner, char * msg) {
|
||||
|
||||
Vtr::Level& baseLevel = refiner.getBaseLevel();
|
||||
|
||||
@ -97,13 +98,15 @@ TopologyRefinerFactoryBase::validateVertexComponentTopologyAssignment(TopologyRe
|
||||
|
||||
bool applyValidation = false;
|
||||
if (applyValidation) {
|
||||
if (!baseLevel.validateTopology()) {
|
||||
printf("Invalid topology detected in TopologyRefinerFactory (%s)\n",
|
||||
if (not baseLevel.validateTopology()) {
|
||||
snprintf(msg, 1024, "Invalid topology detected in TopologyRefinerFactory (%s)\n",
|
||||
completeMissingTopology ? "partially specified and completed" : "fully specified");
|
||||
//baseLevel.print();
|
||||
assert(false);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void
|
||||
@ -306,7 +309,10 @@ TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignCo
|
||||
if (idx!=Vtr::INDEX_INVALID) {
|
||||
refiner.baseEdgeSharpness(idx) = desc.creaseWeights[edge];
|
||||
} else {
|
||||
// XXXX report error !
|
||||
char msg[1024];
|
||||
snprintf(msg, 1024, "Edge %d specified to be sharp does not exist (%d, %d)",
|
||||
edge, vertIndexPairs[0], vertIndexPairs[1]);
|
||||
reportInvalidTopology(msg, desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -317,10 +323,12 @@ TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignCo
|
||||
|
||||
int idx = desc.cornerVertexIndices[vert];
|
||||
|
||||
if (idx < refiner.GetNumVertices(0)) {
|
||||
if (idx > 0 and idx < refiner.GetNumVertices(0)) {
|
||||
refiner.baseVertexSharpness(idx) = desc.cornerWeights[vert];
|
||||
} else {
|
||||
// XXXX report error !
|
||||
char msg[1024];
|
||||
snprintf(msg, 1024, "Vertex %d specified to be sharp does not exist", idx);
|
||||
reportInvalidTopology(msg, desc);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -331,6 +339,13 @@ TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignCo
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::reportInvalidTopology(
|
||||
char const * msg, TopologyDescriptor const& mesh) {
|
||||
reportInvalidTopology(msg, mesh);
|
||||
}
|
||||
|
||||
TopologyRefinerFactoryBase::TopologyDescriptor::TopologyDescriptor() {
|
||||
memset(this, 0, sizeof(TopologyDescriptor));
|
||||
}
|
||||
|
@ -27,6 +27,7 @@
|
||||
#include "../version.h"
|
||||
|
||||
#include "../far/topologyRefiner.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <cassert>
|
||||
|
||||
@ -100,7 +101,7 @@ public:
|
||||
protected:
|
||||
|
||||
static void validateComponentTopologySizing(TopologyRefiner& refiner);
|
||||
static void validateVertexComponentTopologyAssignment(TopologyRefiner& refiner);
|
||||
static bool validateVertexComponentTopologyAssignment(TopologyRefiner& refiner, char * msg);
|
||||
static void validateFaceVaryingComponentTopologyAssignment(TopologyRefiner& refiner);
|
||||
|
||||
static void applyComponentTagsAndBoundarySharpness(TopologyRefiner& refiner);
|
||||
@ -123,12 +124,6 @@ class TopologyRefinerFactory : public TopologyRefinerFactoryBase {
|
||||
|
||||
public:
|
||||
|
||||
/// \brief Constructor
|
||||
TopologyRefinerFactory() : TopologyRefinerFactoryBase() { }
|
||||
|
||||
/// \brief Destructor
|
||||
~TopologyRefinerFactory() { }
|
||||
|
||||
/// \brief Instantiates TopologyRefiner from client-provided topological
|
||||
/// representation.
|
||||
///
|
||||
@ -164,6 +159,8 @@ protected:
|
||||
// Optional:
|
||||
static void assignFaceVaryingTopology(TopologyRefiner& refiner, MESH const& mesh);
|
||||
static void assignComponentTags(TopologyRefiner& refiner, MESH const& mesh);
|
||||
static void reportInvalidTopology(char const * msg, MESH const& mesh);
|
||||
|
||||
|
||||
protected:
|
||||
|
||||
@ -206,7 +203,10 @@ TopologyRefinerFactory<MESH>::populateBaseLevel(TopologyRefiner& refiner, MESH c
|
||||
|
||||
// Required specialization for MESH:
|
||||
assignComponentTopology(refiner, mesh);
|
||||
validateVertexComponentTopologyAssignment(refiner);
|
||||
char msg[1024];
|
||||
if (not validateVertexComponentTopologyAssignment(refiner, msg)) {
|
||||
reportInvalidTopology(msg, mesh);
|
||||
}
|
||||
|
||||
// Optional specialization for MESH:
|
||||
assignComponentTags(refiner, mesh);
|
||||
@ -335,6 +335,18 @@ TopologyRefinerFactory<MESH>::assignComponentTags(TopologyRefiner& /* refiner */
|
||||
//
|
||||
}
|
||||
|
||||
template <class MESH>
|
||||
void
|
||||
TopologyRefinerFactory<MESH>::reportInvalidTopology(char const * msg, MESH const& /* mesh */) {
|
||||
|
||||
//
|
||||
// Optional topology validation error reporting:
|
||||
// This method is called whenever the factory encounters topology validation
|
||||
// errors. By default, the Far::Warning callback is used.
|
||||
//
|
||||
Warning(msg);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
//
|
||||
@ -360,6 +372,11 @@ void
|
||||
TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignComponentTags(
|
||||
TopologyRefiner & refiner, TopologyDescriptor const & desc);
|
||||
|
||||
template <>
|
||||
void
|
||||
TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::reportInvalidTopology(
|
||||
char const * msg, TopologyDescriptor const& /* mesh */);
|
||||
|
||||
} // end namespace Far
|
||||
|
||||
} // end namespace OPENSUBDIV_VERSION
|
||||
|
@ -40,7 +40,6 @@ set(CPU_SOURCE_FILES
|
||||
cpuVertexBuffer.cpp
|
||||
drawContext.cpp
|
||||
drawRegistry.cpp
|
||||
error.cpp
|
||||
evalLimitContext.cpp
|
||||
)
|
||||
|
||||
@ -65,7 +64,6 @@ set(PUBLIC_HEADER_FILES
|
||||
cpuSmoothNormalContext.h
|
||||
cpuSmoothNormalController.h
|
||||
cpuVertexBuffer.h
|
||||
error.h
|
||||
evalLimitContext.h
|
||||
mesh.h
|
||||
nonCopyable.h
|
||||
|
@ -24,8 +24,8 @@
|
||||
|
||||
#include "../far/stencilTables.h"
|
||||
|
||||
#include "../osd/error.h"
|
||||
#include "../osd/clComputeContext.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
@ -43,7 +43,7 @@ createCLBuffer(std::vector<T> const & src, cl_context clContext) {
|
||||
src.size()*sizeof(T), (void*)(&src.at(0)), &errNum);
|
||||
|
||||
if (errNum!=CL_SUCCESS) {
|
||||
Error(OSD_CL_RUNTIME_ERROR, "clCreateBuffer: %d", errNum);
|
||||
Far::Error(Far::RUNTIME_ERROR, "clCreateBuffer: %d", errNum);
|
||||
}
|
||||
|
||||
return devicePtr;
|
||||
|
@ -23,7 +23,7 @@
|
||||
//
|
||||
|
||||
#include "../osd/clComputeController.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#if defined(_WIN32)
|
||||
#include <windows.h>
|
||||
@ -50,7 +50,7 @@ static cl_kernel buildKernel(cl_program prog, const char * name) {
|
||||
cl_kernel k = clCreateKernel(prog, name, &errNum);
|
||||
|
||||
if (errNum != CL_SUCCESS) {
|
||||
Error(OSD_CL_KERNEL_CREATE_ERROR, "buildKernel '%s' (%d)\n", name, errNum);
|
||||
Far::Error(Far::RUNTIME_ERROR, "buildKernel '%s' (%d)\n", name, errNum);
|
||||
}
|
||||
return k;
|
||||
}
|
||||
@ -77,13 +77,13 @@ public:
|
||||
const char *sources[] = { defineStr.c_str(), clSource };
|
||||
_program = clCreateProgramWithSource(clContext, 2, sources, 0, &errNum);
|
||||
if (errNum!=CL_SUCCESS) {
|
||||
Error(OSD_CL_PROGRAM_BUILD_ERROR,
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
"clCreateProgramWithSource (%d)", errNum);
|
||||
}
|
||||
|
||||
errNum = clBuildProgram(_program, 0, NULL, NULL, NULL, NULL);
|
||||
if (errNum != CL_SUCCESS) {
|
||||
Error(OSD_CL_PROGRAM_BUILD_ERROR, "clBuildProgram (%d) \n", errNum);
|
||||
Far::Error(Far::RUNTIME_ERROR, "clBuildProgram (%d) \n", errNum);
|
||||
|
||||
cl_int numDevices = 0;
|
||||
clGetContextInfo(clContext,
|
||||
@ -97,7 +97,7 @@ public:
|
||||
char cBuildLog[10240];
|
||||
clGetProgramBuildInfo(_program, devices[i],
|
||||
CL_PROGRAM_BUILD_LOG, sizeof(cBuildLog), cBuildLog, NULL);
|
||||
Error(OSD_CL_PROGRAM_BUILD_ERROR, cBuildLog);
|
||||
Far::Error(Far::RUNTIME_ERROR, cBuildLog);
|
||||
}
|
||||
delete[] devices;
|
||||
|
||||
@ -176,7 +176,7 @@ CLComputeController::ApplyStencilTableKernel(
|
||||
errNum = clEnqueueNDRangeKernel(
|
||||
_clQueue, kernel, 1, NULL, globalWorkSize, NULL, 0, NULL, NULL);
|
||||
if (errNum!=CL_SUCCESS) {
|
||||
Error(OSD_CL_RUNTIME_ERROR,
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
"ApplyStencilTableKernel (%d) ", errNum);
|
||||
}
|
||||
}
|
||||
@ -208,7 +208,7 @@ CLComputeController::ApplyStencilTableKernel(
|
||||
errNum = clEnqueueNDRangeKernel(
|
||||
_clQueue, kernel, 1, NULL, globalWorkSize, NULL, 0, NULL, NULL);
|
||||
if (errNum!=CL_SUCCESS) {
|
||||
Error(OSD_CL_RUNTIME_ERROR,
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
"ApplyStencilTableKernel (%d)", errNum);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@
|
||||
|
||||
#include "../osd/cpuComputeContext.h"
|
||||
#include "../osd/cpuKernel.h"
|
||||
#include "../osd/error.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
@ -55,7 +54,7 @@ CpuComputeContext::CpuComputeContext(
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
CpuComputeContext::~CpuComputeContext() {
|
||||
CpuComputeContext::~CpuComputeContext() {
|
||||
|
||||
delete _vertexStencilTables;
|
||||
delete _varyingStencilTables;
|
||||
|
@ -52,10 +52,9 @@ CpuSmoothNormalContext *
|
||||
CpuSmoothNormalContext::Create(Far::TopologyRefiner const & refiner,
|
||||
int level, bool resetMemory) {
|
||||
|
||||
int maxlevel = refiner.GetMaxLevel();
|
||||
assert((not refiner.IsUniform()) and (maxlevel>0) and
|
||||
(level>0) and (level<maxlevel));
|
||||
|
||||
assert((not refiner.IsUniform()) and
|
||||
(refiner.GetMaxLevel()>0) and
|
||||
(level>0) and (level<refiner.GetMaxLevel()));
|
||||
return new CpuSmoothNormalContext(refiner, level, resetMemory);
|
||||
}
|
||||
|
||||
|
@ -23,9 +23,8 @@
|
||||
//
|
||||
|
||||
#include "../osd/cudaGLVertexBuffer.h"
|
||||
#include "../osd/error.h"
|
||||
|
||||
#include "../osd/opengl.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <cuda_runtime.h>
|
||||
#include <cuda_gl_interop.h>
|
||||
@ -54,7 +53,7 @@ CudaGLVertexBuffer::Create(int numElements, int numVertices) {
|
||||
CudaGLVertexBuffer *instance =
|
||||
new CudaGLVertexBuffer(numElements, numVertices);
|
||||
if (instance->allocate()) return instance;
|
||||
Error(OSD_CUDA_GL_ERROR,"CudaGLVertexBuffer::Create failed.\n");
|
||||
Far::Error(Far::RUNTIME_ERROR,"CudaGLVertexBuffer::Create failed.\n");
|
||||
delete instance;
|
||||
return NULL;
|
||||
}
|
||||
@ -68,7 +67,7 @@ CudaGLVertexBuffer::UpdateData(const float *src, int startVertex, int numVertice
|
||||
_numElements * numVertices * sizeof(float),
|
||||
cudaMemcpyHostToDevice);
|
||||
if (err != cudaSuccess)
|
||||
Error(OSD_CUDA_GL_ERROR, "CudaGLVertexBuffer::UpdateData failed. : %s\n",
|
||||
Far::Error(Far::RUNTIME_ERROR, "CudaGLVertexBuffer::UpdateData failed. : %s\n",
|
||||
cudaGetErrorString(err));
|
||||
}
|
||||
|
||||
@ -134,10 +133,10 @@ CudaGLVertexBuffer::map() {
|
||||
|
||||
cudaError_t err = cudaGraphicsMapResources(1, &_cudaResource, 0);
|
||||
if (err != cudaSuccess)
|
||||
Error(OSD_CUDA_GL_ERROR, "CudaGLVertexBuffer::map failed.\n%s\n", cudaGetErrorString(err));
|
||||
Far::Error(Far::RUNTIME_ERROR, "CudaGLVertexBuffer::map failed.\n%s\n", cudaGetErrorString(err));
|
||||
err = cudaGraphicsResourceGetMappedPointer(&ptr, &num_bytes, _cudaResource);
|
||||
if (err != cudaSuccess)
|
||||
Error(OSD_CUDA_GL_ERROR, "CudaGLVertexBuffer::map failed.\n%s\n", cudaGetErrorString(err));
|
||||
Far::Error(Far::RUNTIME_ERROR, "CudaGLVertexBuffer::map failed.\n%s\n", cudaGetErrorString(err));
|
||||
_devicePtr = ptr;
|
||||
}
|
||||
|
||||
@ -147,7 +146,7 @@ CudaGLVertexBuffer::unmap() {
|
||||
if (_devicePtr == NULL) return;
|
||||
cudaError_t err = cudaGraphicsUnmapResources(1, &_cudaResource, 0);
|
||||
if (err != cudaSuccess)
|
||||
Error(OSD_CUDA_GL_ERROR, "CudaGLVertexBuffer::unmap failed.\n%s\n", cudaGetErrorString(err));
|
||||
Far::Error(Far::RUNTIME_ERROR, "CudaGLVertexBuffer::unmap failed.\n%s\n", cudaGetErrorString(err));
|
||||
_devicePtr = NULL;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
//
|
||||
|
||||
#include "../osd/glDrawRegistry.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include "../osd/opengl.h"
|
||||
|
||||
@ -246,8 +246,8 @@ _CompileShader(
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
char * infoLog = new char[infoLogLength];
|
||||
glGetShaderInfoLog(shader, infoLogLength, NULL, infoLog);
|
||||
Error(OSD_GLSL_COMPILE_ERROR,
|
||||
"Error compiling GLSL shader: %s\nDefines: \n%s\n",
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
"Error compiling GLSL shader: %s\nDefines: \n%s\n",
|
||||
infoLog, defString.c_str());
|
||||
delete[] infoLog;
|
||||
}
|
||||
@ -321,8 +321,8 @@ GLDrawRegistryBase::_CreateDrawConfig(
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
char * infoLog = new char[infoLogLength];
|
||||
glGetProgramInfoLog(program, infoLogLength, NULL, infoLog);
|
||||
Error(OSD_GLSL_LINK_ERROR,
|
||||
"Error linking GLSL program: %s\n", infoLog);
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
"Error linking GLSL program: %s\n", infoLog);
|
||||
delete[] infoLog;
|
||||
}
|
||||
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "../far/stencilTables.h"
|
||||
|
||||
#include "../osd/error.h"
|
||||
//#include "../osd/debug.h"
|
||||
#include "../osd/glslComputeContext.h"
|
||||
#include "../osd/opengl.h"
|
||||
|
@ -25,8 +25,8 @@
|
||||
#include "../osd/glslComputeController.h"
|
||||
#include "../osd/vertexDescriptor.h"
|
||||
//#include "../osd/debug.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../osd/opengl.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@ -107,10 +107,10 @@ public:
|
||||
if (linked == GL_FALSE) {
|
||||
char buffer[1024];
|
||||
glGetShaderInfoLog(shader, 1024, NULL, buffer);
|
||||
Error(OSD_GLSL_LINK_ERROR, buffer);
|
||||
Far::Error(Far::RUNTIME_ERROR, buffer);
|
||||
|
||||
glGetProgramInfoLog(_program, 1024, NULL, buffer);
|
||||
Error(OSD_GLSL_LINK_ERROR, buffer);
|
||||
Far::Error(Far::RUNTIME_ERROR, buffer);
|
||||
|
||||
glDeleteProgram(_program);
|
||||
_program = 0;
|
||||
@ -151,7 +151,7 @@ public:
|
||||
Match(VertexBufferDescriptor const & d) : desc(d) { }
|
||||
|
||||
bool operator() (KernelBundle const * kernel) {
|
||||
return (desc.length==kernel->_desc.length and
|
||||
return (desc.length==kernel->_desc.length and
|
||||
desc.stride==kernel->_desc.stride);
|
||||
}
|
||||
|
||||
@ -161,19 +161,19 @@ public:
|
||||
protected:
|
||||
|
||||
void dispatchCompute(int offset, int numCVs, int start, int end) const {
|
||||
|
||||
|
||||
int count = end - start;
|
||||
if (count<=0) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
glUniform1i(_uniformStart, start);
|
||||
glUniform1i(_uniformEnd, end);
|
||||
|
||||
glUniform1i(_uniformOffset, offset);
|
||||
glUniform1i(_uniformNumCVs, numCVs);
|
||||
|
||||
|
||||
glDispatchCompute(count/_workGroupSize + 1, 1, 1);
|
||||
|
||||
// sync for later reading.
|
||||
@ -217,7 +217,7 @@ GLSLComputeController::ApplyStencilTableKernel(
|
||||
Far::KernelBatch const &batch, ComputeContext const *context) const {
|
||||
|
||||
assert(context);
|
||||
|
||||
|
||||
_currentBindState.kernelBundle->ApplyStencilTableKernel(
|
||||
batch, _currentBindState.desc.offset, context->GetNumControlVertices());
|
||||
}
|
||||
|
@ -24,7 +24,6 @@
|
||||
|
||||
#include "../far/stencilTables.h"
|
||||
|
||||
#include "../osd/error.h"
|
||||
//#define OSD_DEBUG_BUILD
|
||||
//#include "../osd/debug.h"
|
||||
#include "../osd/glslTransformFeedbackComputeContext.h"
|
||||
|
@ -22,12 +22,12 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../osd/error.h"
|
||||
//#define OSD_DEBUG_BUILD
|
||||
#include "../osd/debug.h"
|
||||
#include "../osd/glslTransformFeedbackComputeController.h"
|
||||
#include "../osd/glslTransformFeedbackComputeContext.h"
|
||||
#include "../osd/opengl.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <algorithm>
|
||||
#include <cassert>
|
||||
@ -118,7 +118,7 @@ public:
|
||||
std::string defineStr = defines.str();
|
||||
|
||||
const char *shaderSources[4] = {"#version 420\n", 0, 0, 0};
|
||||
|
||||
|
||||
shaderSources[1] = defineStr.c_str();
|
||||
shaderSources[2] = shaderDefines;
|
||||
shaderSources[3] = shaderSource;
|
||||
@ -166,10 +166,10 @@ public:
|
||||
if (linked == GL_FALSE) {
|
||||
char buffer[1024];
|
||||
glGetShaderInfoLog(shader, 1024, NULL, buffer);
|
||||
Error(OSD_GLSL_LINK_ERROR, buffer);
|
||||
Far::Error(Far::RUNTIME_ERROR, buffer);
|
||||
|
||||
glGetProgramInfoLog(_program, 1024, NULL, buffer);
|
||||
Error(OSD_GLSL_LINK_ERROR, buffer);
|
||||
Far::Error(Far::RUNTIME_ERROR, buffer);
|
||||
|
||||
glDeleteProgram(_program);
|
||||
_program = 0;
|
||||
|
@ -33,7 +33,6 @@
|
||||
#include "../far/stencilTables.h"
|
||||
#include "../far/stencilTablesFactory.h"
|
||||
|
||||
#include "../osd/error.h"
|
||||
#include "../osd/vertex.h"
|
||||
#include "../osd/vertexDescriptor.h"
|
||||
|
||||
|
@ -23,7 +23,6 @@
|
||||
//
|
||||
|
||||
#include "../osd/ptexMipmapTextureLoader.h"
|
||||
#include "../osd/error.h"
|
||||
|
||||
#include <Ptexture.h>
|
||||
#include <vector>
|
||||
@ -127,7 +126,7 @@ PtexMipmapTextureLoader::Block::guttering(PtexMipmapTextureLoader *loader,
|
||||
+---*---|
|
||||
| D/E\C |
|
||||
| / \ |
|
||||
|/ \|
|
||||
|/ \|
|
||||
+-------+
|
||||
*/
|
||||
|
||||
@ -835,7 +834,7 @@ PtexMipmapTextureLoader::optimizePacking(int maxNumPages,
|
||||
|
||||
// pick a smaller mipmap
|
||||
numTexels -= block->GetNumTexels();
|
||||
block->SetSize((unsigned char)(block->ulog2-1),
|
||||
block->SetSize((unsigned char)(block->ulog2-1),
|
||||
(unsigned char)(block->vlog2-1), _maxLevels != 0);
|
||||
numTexels += block->GetNumTexels();
|
||||
|
||||
|
@ -22,8 +22,8 @@
|
||||
// language governing permissions and limitations under the Apache License.
|
||||
//
|
||||
|
||||
#include "../osd/error.h"
|
||||
#include "../osd/ptexTextureLoader.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <Ptexture.h>
|
||||
#include <algorithm>
|
||||
@ -242,7 +242,7 @@ PtexTextureLoader::PtexTextureLoader( PtexTexture * p,
|
||||
_txc = _txn;
|
||||
}
|
||||
|
||||
PtexTextureLoader::~PtexTextureLoader()
|
||||
PtexTextureLoader::~PtexTextureLoader()
|
||||
{
|
||||
ClearPages();
|
||||
}
|
||||
@ -650,13 +650,13 @@ getCornerPixel(PtexTexture *ptex, float *resultPixel, int numchannels,
|
||||
int valence = 0;
|
||||
do {
|
||||
valence++;
|
||||
|
||||
|
||||
if (valence > 255) {
|
||||
Warning("High valence detected in %s : invalid adjacency around "
|
||||
"face %d", ptex->path(), face);
|
||||
Far::Warning("High valence detected in %s : invalid adjacency around "
|
||||
"face %d", ptex->path(), face);
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
Ptex::FaceInfo info = ptex->getFaceInfo(currentFace);
|
||||
ptex->getPixel(currentFace,
|
||||
uv[currentEdge][0] * (info.res.u()-1),
|
||||
@ -752,7 +752,7 @@ guttering(PtexTexture *_ptex, PtexTextureLoader::block *b, unsigned char *pptr,
|
||||
int dv = (b->v+gwidth*uv[edge][1]);
|
||||
|
||||
/* There are 3 cases when filling a corner pixel on gutter.
|
||||
|
||||
|
||||
case 1: Regular 4 valence
|
||||
We already have correct 'B' and 'C' pixels by edge resampling above.
|
||||
so here only one more pixel 'D' is needed,
|
||||
@ -788,7 +788,7 @@ guttering(PtexTexture *_ptex, PtexTextureLoader::block *b, unsigned char *pptr,
|
||||
+---*---|
|
||||
| D/E\C |
|
||||
| / \ |
|
||||
|/ \|
|
||||
|/ \|
|
||||
+-------+
|
||||
*/
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user