mirror of
https://github.com/PixarAnimationStudios/OpenSubdiv
synced 2025-01-11 17:10:08 +00:00
Fix Win build
- make sure we don't get conflicting enums (CODE_ERROR) - fix template specialization for Far::TopologyRefinerFactory in regression/common/vtr_utils - fix remaining error reporting code around osd
This commit is contained in:
parent
cc6c0925a3
commit
0ff7b15711
@ -54,6 +54,7 @@ _add_possibly_cuda_executable(dxPtexViewer WIN32
|
||||
"${SHADER_FILES}"
|
||||
"${INC_FILES}"
|
||||
$<TARGET_OBJECTS:regression_common_obj>
|
||||
$<TARGET_OBJECTS:regression_vtr_utils_obj>
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
|
@ -52,6 +52,7 @@ _add_possibly_cuda_executable(dxViewer WIN32
|
||||
"${SHADER_FILES}"
|
||||
"${INC_FILES}"
|
||||
$<TARGET_OBJECTS:regression_common_obj>
|
||||
$<TARGET_OBJECTS:regression_vtr_utils_obj>
|
||||
$<TARGET_OBJECTS:examples_common_obj>
|
||||
)
|
||||
|
||||
|
@ -46,7 +46,6 @@ GLFWmonitor* g_primary=0;
|
||||
#define snprintf _snprintf
|
||||
#endif
|
||||
|
||||
#include <osd/error.h>
|
||||
#include <osd/vertex.h>
|
||||
#include <osd/cpuGLVertexBuffer.h>
|
||||
|
||||
|
@ -35,11 +35,11 @@ namespace Far {
|
||||
static ErrorCallbackFunc errorFunc = 0;
|
||||
|
||||
static char const * errors[] = {
|
||||
"NO_ERROR",
|
||||
"FATAL_ERROR",
|
||||
"INTERNAL_CODING_ERROR",
|
||||
"CODING_ERROR",
|
||||
"RUNTIME_ERROR"
|
||||
"FAR_NO_ERROR",
|
||||
"FAR_FATAL_ERROR",
|
||||
"FAR_INTERNAL_CODING_ERROR",
|
||||
"FAR_CODING_ERROR",
|
||||
"FAR_RUNTIME_ERROR"
|
||||
};
|
||||
|
||||
void SetErrorCallback(ErrorCallbackFunc func) {
|
||||
|
@ -33,11 +33,11 @@ namespace OPENSUBDIV_VERSION {
|
||||
namespace Far {
|
||||
|
||||
typedef enum {
|
||||
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.
|
||||
FAR_NO_ERROR, ///< No error. Move along.
|
||||
FAR_FATAL_ERROR, ///< Issue a fatal error and end the program.
|
||||
FAR_INTERNAL_CODING_ERROR, ///< Issue an internal programming error, but continue execution.
|
||||
FAR_CODING_ERROR, ///< Issue a generic programming error, but continue execution.
|
||||
FAR_RUNTIME_ERROR ///< Issue a generic runtime error, but continue execution.
|
||||
} ErrorType;
|
||||
|
||||
typedef void (*ErrorCallbackFunc)(ErrorType err, const char *message);
|
||||
|
@ -342,8 +342,8 @@ TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::assignCo
|
||||
template <>
|
||||
void
|
||||
TopologyRefinerFactory<TopologyRefinerFactoryBase::TopologyDescriptor>::reportInvalidTopology(
|
||||
char const * msg, TopologyDescriptor const& mesh) {
|
||||
reportInvalidTopology(msg, mesh);
|
||||
char const * msg, TopologyDescriptor const& /* mesh */) {
|
||||
Warning(msg);
|
||||
}
|
||||
|
||||
TopologyRefinerFactoryBase::TopologyDescriptor::TopologyDescriptor() {
|
||||
|
@ -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) {
|
||||
Far::Error(Far::RUNTIME_ERROR, "clCreateBuffer: %d", errNum);
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, "clCreateBuffer: %d", errNum);
|
||||
}
|
||||
|
||||
return devicePtr;
|
||||
|
@ -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) {
|
||||
Far::Error(Far::RUNTIME_ERROR, "buildKernel '%s' (%d)\n", name, errNum);
|
||||
Far::Error(Far::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) {
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"clCreateProgramWithSource (%d)", errNum);
|
||||
}
|
||||
|
||||
errNum = clBuildProgram(_program, 0, NULL, NULL, NULL, NULL);
|
||||
if (errNum != CL_SUCCESS) {
|
||||
Far::Error(Far::RUNTIME_ERROR, "clBuildProgram (%d) \n", errNum);
|
||||
Far::Error(Far::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);
|
||||
Far::Error(Far::RUNTIME_ERROR, cBuildLog);
|
||||
Far::Error(Far::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) {
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
Far::Error(Far::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) {
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"ApplyStencilTableKernel (%d)", errNum);
|
||||
}
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
//
|
||||
|
||||
#include "../osd/clD3D11VertexBuffer.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <D3D11.h>
|
||||
#include <CL/cl_d3d11.h>
|
||||
@ -96,7 +96,7 @@ CLD3D11VertexBuffer::allocate(cl_context clContext, ID3D11Device *device) {
|
||||
HRESULT hr;
|
||||
hr = device->CreateBuffer(&hBufferDesc, NULL, &_d3d11Buffer);
|
||||
if(FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR, "Fail in CreateBuffer\n");
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, "Fail in CreateBuffer\n");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@
|
||||
//
|
||||
|
||||
#include "../osd/cpuD3D11VertexBuffer.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <D3D11.h>
|
||||
#include <cassert>
|
||||
@ -92,7 +92,7 @@ CpuD3D11VertexBuffer::BindD3D11Buffer(ID3D11DeviceContext *deviceContext) {
|
||||
D3D11_MAP_WRITE_DISCARD, 0, &resource);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_BUFFER_MAP_ERROR, "Fail to map buffer\n");
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, "Fail to map buffer\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ CpuD3D11VertexBuffer::allocate(ID3D11Device *device) {
|
||||
HRESULT hr;
|
||||
hr = device->CreateBuffer(&hBufferDesc, NULL, &_d3d11Buffer);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Fail in CreateBuffer\n");
|
||||
return false;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
//
|
||||
|
||||
#include "../osd/cudaD3D11VertexBuffer.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <D3D11.h>
|
||||
#include <cuda_runtime.h>
|
||||
@ -108,7 +108,7 @@ CudaD3D11VertexBuffer::allocate(ID3D11Device *device) {
|
||||
HRESULT hr;
|
||||
hr = device->CreateBuffer(&hBufferDesc, NULL, &_d3d11Buffer);
|
||||
if(FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Fail in CreateBuffer\n");
|
||||
return false;
|
||||
}
|
||||
|
@ -53,7 +53,7 @@ CudaGLVertexBuffer::Create(int numElements, int numVertices) {
|
||||
CudaGLVertexBuffer *instance =
|
||||
new CudaGLVertexBuffer(numElements, numVertices);
|
||||
if (instance->allocate()) return instance;
|
||||
Far::Error(Far::RUNTIME_ERROR,"CudaGLVertexBuffer::Create failed.\n");
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,"CudaGLVertexBuffer::Create failed.\n");
|
||||
delete instance;
|
||||
return NULL;
|
||||
}
|
||||
@ -67,7 +67,7 @@ CudaGLVertexBuffer::UpdateData(const float *src, int startVertex, int numVertice
|
||||
_numElements * numVertices * sizeof(float),
|
||||
cudaMemcpyHostToDevice);
|
||||
if (err != cudaSuccess)
|
||||
Far::Error(Far::RUNTIME_ERROR, "CudaGLVertexBuffer::UpdateData failed. : %s\n",
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, "CudaGLVertexBuffer::UpdateData failed. : %s\n",
|
||||
cudaGetErrorString(err));
|
||||
}
|
||||
|
||||
@ -133,10 +133,10 @@ CudaGLVertexBuffer::map() {
|
||||
|
||||
cudaError_t err = cudaGraphicsMapResources(1, &_cudaResource, 0);
|
||||
if (err != cudaSuccess)
|
||||
Far::Error(Far::RUNTIME_ERROR, "CudaGLVertexBuffer::map failed.\n%s\n", cudaGetErrorString(err));
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, "CudaGLVertexBuffer::map failed.\n%s\n", cudaGetErrorString(err));
|
||||
err = cudaGraphicsResourceGetMappedPointer(&ptr, &num_bytes, _cudaResource);
|
||||
if (err != cudaSuccess)
|
||||
Far::Error(Far::RUNTIME_ERROR, "CudaGLVertexBuffer::map failed.\n%s\n", cudaGetErrorString(err));
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, "CudaGLVertexBuffer::map failed.\n%s\n", cudaGetErrorString(err));
|
||||
_devicePtr = ptr;
|
||||
}
|
||||
|
||||
@ -146,7 +146,7 @@ CudaGLVertexBuffer::unmap() {
|
||||
if (_devicePtr == NULL) return;
|
||||
cudaError_t err = cudaGraphicsUnmapResources(1, &_cudaResource, 0);
|
||||
if (err != cudaSuccess)
|
||||
Far::Error(Far::RUNTIME_ERROR, "CudaGLVertexBuffer::unmap failed.\n%s\n", cudaGetErrorString(err));
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, "CudaGLVertexBuffer::unmap failed.\n%s\n", cudaGetErrorString(err));
|
||||
_devicePtr = NULL;
|
||||
}
|
||||
|
||||
|
@ -25,7 +25,7 @@
|
||||
#include "../far/stencilTables.h"
|
||||
|
||||
#include "../osd/d3d11ComputeContext.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <D3D11.h>
|
||||
#include <vector>
|
||||
@ -80,7 +80,7 @@ struct D3D11Table {
|
||||
|
||||
HRESULT hr = device->CreateBuffer(&bd, &initData, &buffer);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_COMPUTE_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Error creating compute table buffer\n");
|
||||
return;
|
||||
}
|
||||
@ -94,7 +94,7 @@ struct D3D11Table {
|
||||
|
||||
hr = device->CreateShaderResourceView(buffer, &srvd, &srv);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_COMPUTE_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Error creating compute table shader resource view\n");
|
||||
return;
|
||||
}
|
||||
|
@ -23,7 +23,7 @@
|
||||
//
|
||||
|
||||
#include "../osd/d3d11ComputeController.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
#include "../osd/vertexDescriptor.h"
|
||||
|
||||
#define INITGUID // for IID_ID3D11ShaderReflection
|
||||
@ -116,7 +116,7 @@ public:
|
||||
&computeShaderBuffer, &errorBuffer);
|
||||
if (FAILED(hr)) {
|
||||
if (errorBuffer != NULL) {
|
||||
Error(OSD_D3D11_COMPILE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Error compiling HLSL shader: %s\n",
|
||||
(CHAR*)errorBuffer->GetBufferPointer());
|
||||
errorBuffer->Release();
|
||||
|
@ -23,7 +23,7 @@
|
||||
//
|
||||
|
||||
#include "../osd/d3d11DrawRegistry.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <D3D11.h>
|
||||
#include <D3Dcompiler.h>
|
||||
@ -228,7 +228,7 @@ _CompileShader(
|
||||
dwShaderFlags, 0, &pBlob, &pBlobError);
|
||||
if (FAILED(hr)) {
|
||||
if ( pBlobError != NULL ) {
|
||||
Error(OSD_D3D11_COMPILE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Error compiling HLSL shader: %s\n",
|
||||
(CHAR*)pBlobError->GetBufferPointer());
|
||||
pBlobError->Release();
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "../osd/d3d11PtexMipmapTexture.h"
|
||||
#include "../osd/ptexMipmapTextureLoader.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <Ptexture.h>
|
||||
#include <D3D11.h>
|
||||
@ -68,7 +68,7 @@ genTextureBuffer(ID3D11DeviceContext *deviceContext, int size, void const * data
|
||||
deviceContext->GetDevice(&device);
|
||||
hr = device->CreateBuffer(&hBufferDesc, NULL, &buffer);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Fail in CreateBuffer\n");
|
||||
return 0;
|
||||
}
|
||||
@ -77,7 +77,7 @@ genTextureBuffer(ID3D11DeviceContext *deviceContext, int size, void const * data
|
||||
hr = deviceContext->Map(buffer, 0,
|
||||
D3D11_MAP_WRITE_DISCARD, 0, &resource);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Fail in Map buffer\n");
|
||||
buffer->Release();
|
||||
return 0;
|
||||
|
@ -24,7 +24,7 @@
|
||||
|
||||
#include "../osd/d3d11PtexTexture.h"
|
||||
#include "../osd/ptexTextureLoader.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <Ptexture.h>
|
||||
#include <D3D11.h>
|
||||
@ -68,7 +68,7 @@ genTextureBuffer(ID3D11DeviceContext *deviceContext, int size, void const * data
|
||||
deviceContext->GetDevice(&device);
|
||||
hr = device->CreateBuffer(&hBufferDesc, NULL, &buffer);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Fail in CreateBuffer\n");
|
||||
return 0;
|
||||
}
|
||||
@ -77,7 +77,7 @@ genTextureBuffer(ID3D11DeviceContext *deviceContext, int size, void const * data
|
||||
hr = deviceContext->Map(buffer, 0,
|
||||
D3D11_MAP_WRITE_DISCARD, 0, &resource);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Fail in Map buffer\n");
|
||||
buffer->Release();
|
||||
return 0;
|
||||
|
@ -23,7 +23,7 @@
|
||||
//
|
||||
|
||||
#include "../osd/d3d11VertexBuffer.h"
|
||||
#include "../osd/error.h"
|
||||
#include "../far/error.h"
|
||||
|
||||
#include <D3D11.h>
|
||||
#include <cassert>
|
||||
@ -70,7 +70,7 @@ D3D11VertexBuffer::UpdateData(const float *src, int startVertex, int numVertices
|
||||
D3D11_MAP_WRITE_DISCARD, 0, &resource);
|
||||
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_BUFFER_MAP_ERROR, "Failed to map buffer\n");
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, "Failed to map buffer\n");
|
||||
return;
|
||||
}
|
||||
|
||||
@ -122,7 +122,7 @@ D3D11VertexBuffer::allocate(ID3D11Device *device) {
|
||||
|
||||
HRESULT hr = device->CreateBuffer(&hBufferDesc, NULL, &_buffer);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Failed to create vertex buffer\n");
|
||||
return false;
|
||||
}
|
||||
@ -136,7 +136,7 @@ D3D11VertexBuffer::allocate(ID3D11Device *device) {
|
||||
|
||||
hr = device->CreateBuffer(&hBufferDesc, NULL, &_uploadBuffer);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Failed to create upload vertex buffer\n");
|
||||
return false;
|
||||
}
|
||||
@ -149,7 +149,7 @@ D3D11VertexBuffer::allocate(ID3D11Device *device) {
|
||||
uavd.Buffer.NumElements = _numElements * _numVertices;
|
||||
hr = device->CreateUnorderedAccessView(_buffer, &uavd, &_uav);
|
||||
if (FAILED(hr)) {
|
||||
Error(OSD_D3D11_VERTEX_BUFFER_CREATE_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Failed to create unordered access resource view\n");
|
||||
return false;
|
||||
}
|
||||
|
@ -246,7 +246,7 @@ _CompileShader(
|
||||
glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
char * infoLog = new char[infoLogLength];
|
||||
glGetShaderInfoLog(shader, infoLogLength, NULL, infoLog);
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Error compiling GLSL shader: %s\nDefines: \n%s\n",
|
||||
infoLog, defString.c_str());
|
||||
delete[] infoLog;
|
||||
@ -321,7 +321,7 @@ GLDrawRegistryBase::_CreateDrawConfig(
|
||||
glGetProgramiv(program, GL_INFO_LOG_LENGTH, &infoLogLength);
|
||||
char * infoLog = new char[infoLogLength];
|
||||
glGetProgramInfoLog(program, infoLogLength, NULL, infoLog);
|
||||
Far::Error(Far::RUNTIME_ERROR,
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR,
|
||||
"Error linking GLSL program: %s\n", infoLog);
|
||||
delete[] infoLog;
|
||||
}
|
||||
|
@ -107,10 +107,10 @@ public:
|
||||
if (linked == GL_FALSE) {
|
||||
char buffer[1024];
|
||||
glGetShaderInfoLog(shader, 1024, NULL, buffer);
|
||||
Far::Error(Far::RUNTIME_ERROR, buffer);
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, buffer);
|
||||
|
||||
glGetProgramInfoLog(_program, 1024, NULL, buffer);
|
||||
Far::Error(Far::RUNTIME_ERROR, buffer);
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, buffer);
|
||||
|
||||
glDeleteProgram(_program);
|
||||
_program = 0;
|
||||
|
@ -166,10 +166,10 @@ public:
|
||||
if (linked == GL_FALSE) {
|
||||
char buffer[1024];
|
||||
glGetShaderInfoLog(shader, 1024, NULL, buffer);
|
||||
Far::Error(Far::RUNTIME_ERROR, buffer);
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, buffer);
|
||||
|
||||
glGetProgramInfoLog(_program, 1024, NULL, buffer);
|
||||
Far::Error(Far::RUNTIME_ERROR, buffer);
|
||||
Far::Error(Far::FAR_RUNTIME_ERROR, buffer);
|
||||
|
||||
glDeleteProgram(_program);
|
||||
_program = 0;
|
||||
|
132
regression/common/vtr_utils.cpp
Normal file → Executable file
132
regression/common/vtr_utils.cpp
Normal file → Executable file
@ -81,3 +81,135 @@ InterpolateFVarData(OpenSubdiv::Far::TopologyRefiner & refiner,
|
||||
refiner.InterpolateFaceVarying(src, dst, channel);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
||||
namespace Far {
|
||||
|
||||
template <>
|
||||
void
|
||||
TopologyRefinerFactory<Shape>::resizeComponentTopology(
|
||||
Far::TopologyRefiner & refiner, Shape const & shape) {
|
||||
|
||||
int nfaces = shape.GetNumFaces(),
|
||||
nverts = shape.GetNumVertices();
|
||||
|
||||
refiner.setNumBaseFaces(nfaces);
|
||||
for (int i=0; i<nfaces; ++i) {
|
||||
|
||||
int nv = shape.nvertsPerFace[i];
|
||||
refiner.setNumBaseFaceVertices(i, nv);
|
||||
}
|
||||
|
||||
// Vertices and vert-faces and vert-edges
|
||||
refiner.setNumBaseVertices(nverts);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
template <>
|
||||
void
|
||||
TopologyRefinerFactory<Shape>::assignComponentTopology(
|
||||
Far::TopologyRefiner & refiner, Shape const & shape) {
|
||||
|
||||
{ // Face relations:
|
||||
int nfaces = refiner.getNumBaseFaces();
|
||||
|
||||
for (int i=0, ofs=0; i < nfaces; ++i) {
|
||||
|
||||
Far::IndexArray dstFaceVerts = refiner.setBaseFaceVertices(i);
|
||||
//IndexArray dstFaceEdges = refiner.setBaseFaceEdges(i);
|
||||
|
||||
for (int j=0; j<dstFaceVerts.size(); ++j) {
|
||||
dstFaceVerts[j] = shape.faceverts[ofs++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
template <>
|
||||
void
|
||||
TopologyRefinerFactory<Shape>::assignFaceVaryingTopology(
|
||||
Far::TopologyRefiner & refiner, Shape const & shape) {
|
||||
|
||||
// UV layyout (we only parse 1 channel)
|
||||
if (not shape.faceuvs.empty()) {
|
||||
|
||||
int nfaces = refiner.getNumBaseFaces(),
|
||||
channel = refiner.createFVarChannel( (int)shape.faceuvs.size() );
|
||||
|
||||
for (int i=0, ofs=0; i < nfaces; ++i) {
|
||||
|
||||
Far::IndexArray dstFaceUVs =
|
||||
refiner.getBaseFVarFaceValues(i, channel);
|
||||
|
||||
for (int j=0; j<dstFaceUVs.size(); ++j) {
|
||||
dstFaceUVs[j] = shape.faceuvs[ofs++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
template <>
|
||||
void
|
||||
TopologyRefinerFactory<Shape>::assignComponentTags(
|
||||
Far::TopologyRefiner & refiner, Shape const & shape) {
|
||||
|
||||
|
||||
for (int i=0; i<(int)shape.tags.size(); ++i) {
|
||||
|
||||
Shape::tag * t = shape.tags[i];
|
||||
|
||||
if (t->name=="crease") {
|
||||
|
||||
for (int j=0; j<(int)t->intargs.size()-1; j += 2) {
|
||||
|
||||
OpenSubdiv::Vtr::Index edge = refiner.FindEdge(/*level*/0, t->intargs[j], t->intargs[j+1]);
|
||||
if (edge==OpenSubdiv::Vtr::INDEX_INVALID) {
|
||||
printf("cannot find edge for crease tag (%d,%d)\n", t->intargs[j], t->intargs[j+1] );
|
||||
} else {
|
||||
int nfloat = (int) t->floatargs.size();
|
||||
refiner.baseEdgeSharpness(edge) =
|
||||
std::max(0.0f, ((nfloat > 1) ? t->floatargs[j] : t->floatargs[0]));
|
||||
}
|
||||
}
|
||||
} else if (t->name=="corner") {
|
||||
|
||||
for (int j=0; j<(int)t->intargs.size(); ++j) {
|
||||
int vertex = t->intargs[j];
|
||||
if (vertex<0 or vertex>=refiner.GetNumVertices(/*level*/0)) {
|
||||
printf("cannot find vertex for corner tag (%d)\n", vertex );
|
||||
} else {
|
||||
int nfloat = (int) t->floatargs.size();
|
||||
refiner.baseVertexSharpness(vertex) =
|
||||
std::max(0.0f, ((nfloat > 1) ? t->floatargs[j] : t->floatargs[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // Hole tags
|
||||
for (int i=0; i<(int)shape.tags.size(); ++i) {
|
||||
Shape::tag * t = shape.tags[i];
|
||||
if (t->name=="hole") {
|
||||
for (int j=0; j<(int)t->intargs.size(); ++j) {
|
||||
refiner.setBaseFaceHole(t->intargs[j], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template <>
|
||||
void
|
||||
TopologyRefinerFactory<Shape>::reportInvalidTopology(char const * msg, Shape const& /* shape */) {
|
||||
Warning(msg);
|
||||
}
|
||||
|
||||
} // namespace Far
|
||||
|
||||
} // namespace OPENSUBDIV_VERSION
|
||||
} // namespace OpenSubdiv
|
||||
|
@ -117,135 +117,6 @@ GetSdcOptions(Shape const & shape) {
|
||||
return result;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace OpenSubdiv {
|
||||
namespace OPENSUBDIV_VERSION {
|
||||
|
||||
namespace Far {
|
||||
|
||||
template <>
|
||||
inline void
|
||||
TopologyRefinerFactory<Shape>::resizeComponentTopology(
|
||||
Far::TopologyRefiner & refiner, Shape const & shape) {
|
||||
|
||||
int nfaces = shape.GetNumFaces(),
|
||||
nverts = shape.GetNumVertices();
|
||||
|
||||
refiner.setNumBaseFaces(nfaces);
|
||||
for (int i=0; i<nfaces; ++i) {
|
||||
|
||||
int nv = shape.nvertsPerFace[i];
|
||||
refiner.setNumBaseFaceVertices(i, nv);
|
||||
}
|
||||
|
||||
// Vertices and vert-faces and vert-edges
|
||||
refiner.setNumBaseVertices(nverts);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
template <>
|
||||
inline void
|
||||
TopologyRefinerFactory<Shape>::assignComponentTopology(
|
||||
Far::TopologyRefiner & refiner, Shape const & shape) {
|
||||
|
||||
{ // Face relations:
|
||||
int nfaces = refiner.getNumBaseFaces();
|
||||
|
||||
for (int i=0, ofs=0; i < nfaces; ++i) {
|
||||
|
||||
Far::IndexArray dstFaceVerts = refiner.setBaseFaceVertices(i);
|
||||
//IndexArray dstFaceEdges = refiner.setBaseFaceEdges(i);
|
||||
|
||||
for (int j=0; j<dstFaceVerts.size(); ++j) {
|
||||
dstFaceVerts[j] = shape.faceverts[ofs++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
template <>
|
||||
inline void
|
||||
TopologyRefinerFactory<Shape>::assignFaceVaryingTopology(
|
||||
Far::TopologyRefiner & refiner, Shape const & shape) {
|
||||
|
||||
// UV layyout (we only parse 1 channel)
|
||||
if (not shape.faceuvs.empty()) {
|
||||
|
||||
int nfaces = refiner.getNumBaseFaces(),
|
||||
channel = refiner.createFVarChannel( (int)shape.faceuvs.size() );
|
||||
|
||||
for (int i=0, ofs=0; i < nfaces; ++i) {
|
||||
|
||||
Far::IndexArray dstFaceUVs =
|
||||
refiner.getBaseFVarFaceValues(i, channel);
|
||||
|
||||
for (int j=0; j<dstFaceUVs.size(); ++j) {
|
||||
dstFaceUVs[j] = shape.faceuvs[ofs++];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------
|
||||
template <>
|
||||
inline void
|
||||
TopologyRefinerFactory<Shape>::assignComponentTags(
|
||||
Far::TopologyRefiner & refiner, Shape const & shape) {
|
||||
|
||||
|
||||
for (int i=0; i<(int)shape.tags.size(); ++i) {
|
||||
|
||||
Shape::tag * t = shape.tags[i];
|
||||
|
||||
if (t->name=="crease") {
|
||||
|
||||
for (int j=0; j<(int)t->intargs.size()-1; j += 2) {
|
||||
|
||||
OpenSubdiv::Vtr::Index edge = refiner.FindEdge(/*level*/0, t->intargs[j], t->intargs[j+1]);
|
||||
if (edge==OpenSubdiv::Vtr::INDEX_INVALID) {
|
||||
printf("cannot find edge for crease tag (%d,%d)\n", t->intargs[j], t->intargs[j+1] );
|
||||
} else {
|
||||
int nfloat = (int) t->floatargs.size();
|
||||
refiner.baseEdgeSharpness(edge) =
|
||||
std::max(0.0f, ((nfloat > 1) ? t->floatargs[j] : t->floatargs[0]));
|
||||
}
|
||||
}
|
||||
} else if (t->name=="corner") {
|
||||
|
||||
for (int j=0; j<(int)t->intargs.size(); ++j) {
|
||||
int vertex = t->intargs[j];
|
||||
if (vertex<0 or vertex>=refiner.GetNumVertices(/*level*/0)) {
|
||||
printf("cannot find vertex for corner tag (%d)\n", vertex );
|
||||
} else {
|
||||
int nfloat = (int) t->floatargs.size();
|
||||
refiner.baseVertexSharpness(vertex) =
|
||||
std::max(0.0f, ((nfloat > 1) ? t->floatargs[j] : t->floatargs[0]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
{ // Hole tags
|
||||
for (int i=0; i<(int)shape.tags.size(); ++i) {
|
||||
Shape::tag * t = shape.tags[i];
|
||||
if (t->name=="hole") {
|
||||
for (int j=0; j<(int)t->intargs.size(); ++j) {
|
||||
refiner.setBaseFaceHole(t->intargs[j], true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace Far
|
||||
|
||||
} // namespace OPENSUBDIV_VERSION
|
||||
} // namespace OpenSubdiv
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
void
|
||||
InterpolateFVarData(OpenSubdiv::Far::TopologyRefiner & refiner,
|
||||
Shape const & shape, std::vector<float> & fvarData);
|
||||
|
Loading…
Reference in New Issue
Block a user