aboutsummaryrefslogtreecommitdiff
path: root/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
diff options
context:
space:
mode:
authorGeoff Lang <geofflang@chromium.org>2014-09-08 16:06:25 -0400
committerGeoff Lang <geofflang@chromium.org>2014-09-10 18:19:13 +0000
commitc9e69b1941522095a3878d9e1501511ab4722139 (patch)
tree94f4377e7f93da6908377475ed944db23c28fb16 /src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
parent1c134e6c1fe515b44afd7edf40cc19eceb54de5f (diff)
downloadangle-c9e69b1941522095a3878d9e1501511ab4722139.tar.gz
Updated the index buffer classes to use Error objects.
BUG=angle:520 Change-Id: Ifc249058a3ed3ffffe163a9e3ec21d6fc8c75bd0 Reviewed-on: https://chromium-review.googlesource.com/217101 Reviewed-by: Jamie Madill <jmadill@chromium.org> Tested-by: Geoff Lang <geofflang@chromium.org>
Diffstat (limited to 'src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp')
-rw-r--r--src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp71
1 files changed, 41 insertions, 30 deletions
diff --git a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
index c267fca6..c7913424 100644
--- a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
+++ b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp
@@ -1269,25 +1269,26 @@ GLenum Renderer9::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::
}
// Applies the indices and element array bindings to the Direct3D 9 device
-GLenum Renderer9::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo)
+gl::Error Renderer9::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo)
{
- GLenum err = mIndexDataManager->prepareIndexData(type, count, elementArrayBuffer, indices, indexInfo);
-
- if (err == GL_NO_ERROR)
+ gl::Error error = mIndexDataManager->prepareIndexData(type, count, elementArrayBuffer, indices, indexInfo);
+ if (error.isError())
{
- // Directly binding the storage buffer is not supported for d3d9
- ASSERT(indexInfo->storage == NULL);
+ return error;
+ }
- if (indexInfo->serial != mAppliedIBSerial)
- {
- IndexBuffer9* indexBuffer = IndexBuffer9::makeIndexBuffer9(indexInfo->indexBuffer);
+ // Directly binding the storage buffer is not supported for d3d9
+ ASSERT(indexInfo->storage == NULL);
- mDevice->SetIndices(indexBuffer->getBuffer());
- mAppliedIBSerial = indexInfo->serial;
- }
+ if (indexInfo->serial != mAppliedIBSerial)
+ {
+ IndexBuffer9* indexBuffer = IndexBuffer9::makeIndexBuffer9(indexInfo->indexBuffer);
+
+ mDevice->SetIndices(indexBuffer->getBuffer());
+ mAppliedIBSerial = indexInfo->serial;
}
- return err;
+ return gl::Error(GL_NO_ERROR);
}
void Renderer9::applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[])
@@ -1375,10 +1376,10 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
if (!mLineLoopIB)
{
mLineLoopIB = new StreamingIndexBufferInterface(this);
- if (!mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT))
+ gl::Error error = mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT);
+ if (error.isError())
{
- delete mLineLoopIB;
- mLineLoopIB = NULL;
+ SafeDelete(mLineLoopIB);
ERR("Could not create a 32-bit looping index buffer for GL_LINE_LOOP.");
return gl::error(GL_OUT_OF_MEMORY);
@@ -1394,8 +1395,9 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
return gl::error(GL_OUT_OF_MEMORY);
}
- const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned int);
- if (!mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT))
+ const unsigned int spaceNeeded = (static_cast<unsigned int>(count)+1) * sizeof(unsigned int);
+ gl::Error error = mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT);
+ if (error.isError())
{
ERR("Could not reserve enough space in looping index buffer for GL_LINE_LOOP.");
return gl::error(GL_OUT_OF_MEMORY);
@@ -1403,7 +1405,8 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
void* mappedMemory = NULL;
unsigned int offset = 0;
- if (!mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset))
+ error = mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset);
+ if (error.isError())
{
ERR("Could not map index buffer for GL_LINE_LOOP.");
return gl::error(GL_OUT_OF_MEMORY);
@@ -1445,7 +1448,8 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
default: UNREACHABLE();
}
- if (!mLineLoopIB->unmapBuffer())
+ error = mLineLoopIB->unmapBuffer();
+ if (error.isError())
{
ERR("Could not unmap index buffer for GL_LINE_LOOP.");
return gl::error(GL_OUT_OF_MEMORY);
@@ -1456,10 +1460,10 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
if (!mLineLoopIB)
{
mLineLoopIB = new StreamingIndexBufferInterface(this);
- if (!mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT))
+ gl::Error error = mLineLoopIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT);
+ if (error.isError())
{
- delete mLineLoopIB;
- mLineLoopIB = NULL;
+ SafeDelete(mLineLoopIB);
ERR("Could not create a 16-bit looping index buffer for GL_LINE_LOOP.");
return gl::error(GL_OUT_OF_MEMORY);
@@ -1476,7 +1480,8 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
}
const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned short);
- if (!mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_SHORT))
+ gl::Error error = mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_SHORT);
+ if (error.isError())
{
ERR("Could not reserve enough space in looping index buffer for GL_LINE_LOOP.");
return gl::error(GL_OUT_OF_MEMORY);
@@ -1484,7 +1489,8 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
void* mappedMemory = NULL;
unsigned int offset;
- if (mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset))
+ error = mLineLoopIB->mapBuffer(spaceNeeded, &mappedMemory, &offset);
+ if (error.isError())
{
ERR("Could not map index buffer for GL_LINE_LOOP.");
return gl::error(GL_OUT_OF_MEMORY);
@@ -1526,7 +1532,8 @@ void Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices,
default: UNREACHABLE();
}
- if (!mLineLoopIB->unmapBuffer())
+ error = mLineLoopIB->unmapBuffer();
+ if (error.isError())
{
ERR("Could not unmap index buffer for GL_LINE_LOOP.");
return gl::error(GL_OUT_OF_MEMORY);
@@ -1589,7 +1596,8 @@ StaticIndexBufferInterface *Renderer9::getCountingIB(size_t count)
mCountingIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_SHORT);
void *mappedMemory = NULL;
- if (!mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, NULL))
+ gl::Error error = mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, NULL);
+ if (error.isError())
{
ERR("Failed to map counting buffer.");
return NULL;
@@ -1601,7 +1609,8 @@ StaticIndexBufferInterface *Renderer9::getCountingIB(size_t count)
data[i] = i;
}
- if (!mCountingIB->unmapBuffer())
+ error = mCountingIB->unmapBuffer();
+ if (error.isError())
{
ERR("Failed to unmap counting buffer.");
return NULL;
@@ -1621,7 +1630,8 @@ StaticIndexBufferInterface *Renderer9::getCountingIB(size_t count)
mCountingIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT);
void *mappedMemory = NULL;
- if (!mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, NULL))
+ gl::Error error = mCountingIB->mapBuffer(spaceNeeded, &mappedMemory, NULL);
+ if (error.isError())
{
ERR("Failed to map counting buffer.");
return NULL;
@@ -1633,7 +1643,8 @@ StaticIndexBufferInterface *Renderer9::getCountingIB(size_t count)
data[i] = i;
}
- if (!mCountingIB->unmapBuffer())
+ error = mCountingIB->unmapBuffer();
+ if (error.isError())
{
ERR("Failed to unmap counting buffer.");
return NULL;