Fix error handling in OsdUtilMeshBatch when failed to create vertex buffers.

This commit is contained in:
Takahito Tejima 2013-09-03 15:13:00 -07:00
parent 1e69dbe630
commit 3755603b36
2 changed files with 58 additions and 13 deletions

View File

@ -365,13 +365,21 @@ OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, COMPUTE_CONTROLLER>::initialize(Co
FarPatchTables const * patchTables = farMultiMesh->GetPatchTables();
_vertexBuffer = numVertexElements ? VertexBuffer::Create(numVertexElements, Base::GetNumVertices()) : NULL;
_varyingBuffer = numVaryingElements ? VertexBuffer::Create(numVaryingElements, Base::GetNumVertices()) : NULL;
if (numVertexElements) {
_vertexBuffer = VertexBuffer::Create(numVertexElements, Base::GetNumVertices());
if (not _vertexBuffer) return false;
}
if (numVaryingElements) {
_varyingBuffer = VertexBuffer::Create(numVaryingElements, Base::GetNumVertices());
if (not _varyingBuffer) return false;
}
_drawContext = DrawContext::Create(patchTables, requireFVarData);
if (not _drawContext) return false;
_drawContext->UpdateVertexTexture(_vertexBuffer);
if (_vertexBuffer) _drawContext->UpdateVertexTexture(_vertexBuffer);
return true;
}
@ -388,13 +396,21 @@ OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, COMPUTE_CONTROLLER>::initialize(Fa
Base::initialize(entries, numVertices, numPtexFaces, numVertexElements, batchIndex);
_vertexBuffer = numVertexElements ? VertexBuffer::Create(numVertexElements, numVertices) : NULL;
_varyingBuffer = numVaryingElements ? VertexBuffer::Create(numVaryingElements, numVertices) : NULL;
if (numVertexElements) {
_vertexBuffer = VertexBuffer::Create(numVertexElements, numVertices);
if (not _vertexBuffer) return false;
}
if (numVaryingElements) {
_varyingBuffer = VertexBuffer::Create(numVaryingElements, numVertices);
if (not _varyingBuffer) return false;
}
_drawContext = DrawContext::Create(patchTables, requireFVarData);
if (not _drawContext) return false;
_drawContext->UpdateVertexTexture(_vertexBuffer);
if (_vertexBuffer) _drawContext->UpdateVertexTexture(_vertexBuffer);
return true;
}
@ -429,7 +445,12 @@ OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, COMPUTE_CONTROLLER>::Create(Comput
OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, COMPUTE_CONTROLLER> *batch =
new OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, COMPUTE_CONTROLLER>();
batch->initialize(computeController, entries, farMultiMesh, numVertexElements, numVaryingElements, batchIndex, requireFVarData);
if (not batch->initialize(computeController, entries, farMultiMesh,
numVertexElements, numVaryingElements,
batchIndex, requireFVarData)) {
delete batch;
batch = NULL;
}
delete farMultiMesh;
@ -450,7 +471,12 @@ OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, COMPUTE_CONTROLLER>::Create(FarPat
OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, COMPUTE_CONTROLLER> *batch =
new OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, COMPUTE_CONTROLLER>();
batch->initialize(patchTables, entries, numVertices, numPtexFaces, numVertexElements, numVaryingElements, batchIndex, requireFVarData);
if (not batch->initialize(patchTables, entries, numVertices, numPtexFaces,
numVertexElements, numVaryingElements,
batchIndex, requireFVarData)) {
delete batch;
batch = NULL;
}
return batch;
}

View File

@ -161,8 +161,15 @@ OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, OsdCLComputeController>::initializ
FarPatchTables const * patchTables = farMultiMesh->GetPatchTables();
_vertexBuffer = numVertexElements ? VertexBuffer::Create(numVertexElements, Base::GetNumVertices(), _computeController->GetContext()) : NULL;
_varyingBuffer = numVaryingElements ? VertexBuffer::Create(numVaryingElements, Base::GetNumVertices(), _computeController->GetContext()) : NULL;
if (numVertexElements) {
_vertexBuffer = VertexBuffer::Create(numVertexElements, Base::GetNumVertices(), _computeController->GetContext());
if (not _vertexBuffer) return false;
}
if (numVaryingElements) {
_varyingBuffer = VertexBuffer::Create(numVaryingElements, Base::GetNumVertices(), _computeController->GetContext());
if (not _varyingBuffer) return false;
}
_drawContext = DrawContext::Create(patchTables, requireFVarData);
@ -183,8 +190,15 @@ OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, OsdCLComputeController>::initializ
bool requireFVarData) {
Base::initialize(numVertices, numPtexFaces, numVertexElements, batchIndex);
_vertexBuffer = numVertexElements ? VertexBuffer::Create(numVertexElements, Base::GetNumVertices(), _computeController->GetContext()) : NULL;
_varyingBuffer = numVaryingElements ? VertexBuffer::Create(numVaryingElements, Base::GetNumVertices(), _computeController->GetContext()) : NULL;
if (numVertexElements) {
_vertexBuffer = VertexBuffer::Create(numVertexElements, Base::GetNumVertices(), _computeController->GetContext());
if (not _vertexBuffer) return false;
}
if (numVaryingElements) {
_varyingBuffer = VertexBuffer::Create(numVaryingElements, Base::GetNumVertices(), _computeController->GetContext());
if (not _varyingBuffer) return false;
}
_drawContext = DrawContext::Create(patchTables, requireFVarData);
@ -225,7 +239,12 @@ OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, OsdCLComputeController>::Create(Co
OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, OsdCLComputeController> *batch =
new OsdUtilMeshBatch<VERTEX_BUFFER, DRAW_CONTEXT, OsdCLComputeController>();
batch->initialize(computeController, entries, farMultiMesh, numVertexElements, numVaryingElements, batchIndex, requireFVarData);
if (not batch->initialize(computeController, entries, farMultiMesh,
numVertexElements, numVaryingElements,
batchIndex, requireFVarData)) {
delete batch;
batch = NULL;
}
delete farMultiMesh;