diff options
author | Geoff Lang <geofflang@chromium.org> | 2014-09-08 16:06:25 -0400 |
---|---|---|
committer | Geoff Lang <geofflang@chromium.org> | 2014-09-10 18:19:13 +0000 |
commit | c9e69b1941522095a3878d9e1501511ab4722139 (patch) | |
tree | 94f4377e7f93da6908377475ed944db23c28fb16 /src/libGLESv2/renderer/d3d | |
parent | 1c134e6c1fe515b44afd7edf40cc19eceb54de5f (diff) | |
download | angle-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')
-rw-r--r-- | src/libGLESv2/renderer/d3d/IndexBuffer.cpp | 40 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/IndexBuffer.h | 27 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/IndexDataManager.cpp | 54 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/IndexDataManager.h | 5 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp | 98 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h | 10 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp | 79 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/d3d11/Renderer11.h | 2 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp | 119 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h | 10 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/d3d9/Renderer9.cpp | 71 | ||||
-rw-r--r-- | src/libGLESv2/renderer/d3d/d3d9/Renderer9.h | 2 |
12 files changed, 250 insertions, 267 deletions
diff --git a/src/libGLESv2/renderer/d3d/IndexBuffer.cpp b/src/libGLESv2/renderer/d3d/IndexBuffer.cpp index 8bf9f2a1..1dce1270 100644 --- a/src/libGLESv2/renderer/d3d/IndexBuffer.cpp +++ b/src/libGLESv2/renderer/d3d/IndexBuffer.cpp @@ -66,21 +66,22 @@ unsigned int IndexBufferInterface::getSerial() const return mIndexBuffer->getSerial(); } -bool IndexBufferInterface::mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset) +gl::Error IndexBufferInterface::mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset) { // Protect against integer overflow if (mWritePosition + size < mWritePosition) { - return false; + return gl::Error(GL_OUT_OF_MEMORY, "Mapping of internal index buffer would cause an integer overflow."); } - if (!mIndexBuffer->mapBuffer(mWritePosition, size, outMappedMemory)) + gl::Error error = mIndexBuffer->mapBuffer(mWritePosition, size, outMappedMemory); + if (error.isError()) { if (outMappedMemory) { *outMappedMemory = NULL; } - return false; + return error; } if (streamOffset) @@ -89,10 +90,10 @@ bool IndexBufferInterface::mapBuffer(unsigned int size, void** outMappedMemory, } mWritePosition += size; - return true; + return gl::Error(GL_NO_ERROR); } -bool IndexBufferInterface::unmapBuffer() +gl::Error IndexBufferInterface::unmapBuffer() { return mIndexBuffer->unmapBuffer(); } @@ -112,12 +113,12 @@ void IndexBufferInterface::setWritePosition(unsigned int writePosition) mWritePosition = writePosition; } -bool IndexBufferInterface::discard() +gl::Error IndexBufferInterface::discard() { return mIndexBuffer->discard(); } -bool IndexBufferInterface::setBufferSize(unsigned int bufferSize, GLenum indexType) +gl::Error IndexBufferInterface::setBufferSize(unsigned int bufferSize, GLenum indexType) { if (mIndexBuffer->getBufferSize() == 0) { @@ -137,26 +138,30 @@ StreamingIndexBufferInterface::~StreamingIndexBufferInterface() { } -bool StreamingIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType) +gl::Error StreamingIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType) { - bool result = true; unsigned int curBufferSize = getBufferSize(); unsigned int writePos = getWritePosition(); if (size > curBufferSize) { - result = setBufferSize(std::max(size, 2 * curBufferSize), indexType); + gl::Error error = setBufferSize(std::max(size, 2 * curBufferSize), indexType); + if (error.isError()) + { + return error; + } setWritePosition(0); } else if (writePos + size > curBufferSize || writePos + size < writePos) { - if (!discard()) + gl::Error error = discard(); + if (error.isError()) { - return false; + return error; } setWritePosition(0); } - return result; + return gl::Error(GL_NO_ERROR); } @@ -168,7 +173,7 @@ StaticIndexBufferInterface::~StaticIndexBufferInterface() { } -bool StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType) +gl::Error StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum indexType) { unsigned int curSize = getBufferSize(); if (curSize == 0) @@ -177,13 +182,12 @@ bool StaticIndexBufferInterface::reserveBufferSpace(unsigned int size, GLenum in } else if (curSize >= size && indexType == getIndexType()) { - return true; + return gl::Error(GL_NO_ERROR); } else { - ERR("Static index buffers can't be resized"); UNREACHABLE(); - return false; + return gl::Error(GL_INVALID_OPERATION, "Internal static index buffers can't be resized"); } } diff --git a/src/libGLESv2/renderer/d3d/IndexBuffer.h b/src/libGLESv2/renderer/d3d/IndexBuffer.h index 6fb885a1..1bb5ae2c 100644 --- a/src/libGLESv2/renderer/d3d/IndexBuffer.h +++ b/src/libGLESv2/renderer/d3d/IndexBuffer.h @@ -11,6 +11,7 @@ #define LIBGLESV2_RENDERER_INDEXBUFFER_H_ #include "common/angleutils.h" +#include "libGLESv2/Error.h" #include "libGLESv2/renderer/IndexRangeCache.h" namespace rx @@ -23,16 +24,16 @@ class IndexBuffer IndexBuffer(); virtual ~IndexBuffer(); - virtual bool initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) = 0; + virtual gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) = 0; - virtual bool mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) = 0; - virtual bool unmapBuffer() = 0; + virtual gl::Error mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) = 0; + virtual gl::Error unmapBuffer() = 0; - virtual bool discard() = 0; + virtual gl::Error discard() = 0; virtual GLenum getIndexType() const = 0; virtual unsigned int getBufferSize() const = 0; - virtual bool setSize(unsigned int bufferSize, GLenum indexType) = 0; + virtual gl::Error setSize(unsigned int bufferSize, GLenum indexType) = 0; unsigned int getSerial() const; @@ -52,15 +53,15 @@ class IndexBufferInterface IndexBufferInterface(Renderer *renderer, bool dynamic); virtual ~IndexBufferInterface(); - virtual bool reserveBufferSpace(unsigned int size, GLenum indexType) = 0; + virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType) = 0; GLenum getIndexType() const; unsigned int getBufferSize() const; unsigned int getSerial() const; - bool mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset); - bool unmapBuffer(); + gl::Error mapBuffer(unsigned int size, void** outMappedMemory, unsigned int *streamOffset); + gl::Error unmapBuffer(); IndexBuffer *getIndexBuffer() const; @@ -68,9 +69,9 @@ class IndexBufferInterface unsigned int getWritePosition() const; void setWritePosition(unsigned int writePosition); - bool discard(); + gl::Error discard(); - bool setBufferSize(unsigned int bufferSize, GLenum indexType); + gl::Error setBufferSize(unsigned int bufferSize, GLenum indexType); private: DISALLOW_COPY_AND_ASSIGN(IndexBufferInterface); @@ -89,7 +90,7 @@ class StreamingIndexBufferInterface : public IndexBufferInterface StreamingIndexBufferInterface(Renderer *renderer); ~StreamingIndexBufferInterface(); - virtual bool reserveBufferSpace(unsigned int size, GLenum indexType); + virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType); }; class StaticIndexBufferInterface : public IndexBufferInterface @@ -98,7 +99,7 @@ class StaticIndexBufferInterface : public IndexBufferInterface explicit StaticIndexBufferInterface(Renderer *renderer); ~StaticIndexBufferInterface(); - virtual bool reserveBufferSpace(unsigned int size, GLenum indexType); + virtual gl::Error reserveBufferSpace(unsigned int size, GLenum indexType); IndexRangeCache *getIndexRangeCache(); @@ -108,4 +109,4 @@ class StaticIndexBufferInterface : public IndexBufferInterface } -#endif // LIBGLESV2_RENDERER_INDEXBUFFER_H_
\ No newline at end of file +#endif // LIBGLESV2_RENDERER_INDEXBUFFER_H_ diff --git a/src/libGLESv2/renderer/d3d/IndexDataManager.cpp b/src/libGLESv2/renderer/d3d/IndexDataManager.cpp index cd775c19..8d455b4b 100644 --- a/src/libGLESv2/renderer/d3d/IndexDataManager.cpp +++ b/src/libGLESv2/renderer/d3d/IndexDataManager.cpp @@ -70,7 +70,7 @@ IndexDataManager::~IndexDataManager() SafeDelete(mStreamingBufferInt); } -GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer *buffer, const GLvoid *indices, TranslatedIndexData *translated) +gl::Error IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer *buffer, const GLvoid *indices, TranslatedIndexData *translated) { const gl::Type &typeInfo = gl::GetTypeInfo(type); @@ -83,10 +83,6 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer if (buffer != NULL) { - if (reinterpret_cast<uintptr_t>(indices) > std::numeric_limits<unsigned int>::max()) - { - return GL_OUT_OF_MEMORY; - } offset = static_cast<unsigned int>(reinterpret_cast<uintptr_t>(indices)); storage = BufferD3D::makeBufferD3D(buffer->getImplementation()); @@ -143,10 +139,10 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer if (!directStorage && !indexBuffer) { - GLenum err = getStreamingIndexBuffer(destinationIndexType, &indexBuffer); - if (err != GL_NO_ERROR) + gl::Error error = getStreamingIndexBuffer(destinationIndexType, &indexBuffer); + if (error.isError()) { - return err; + return error; } unsigned int convertCount = count; @@ -169,30 +165,30 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer if (convertCount > std::numeric_limits<unsigned int>::max() / destTypeInfo.bytes) { - ERR("Reserving %u indicies of %u bytes each exceeds the maximum buffer size.", convertCount, destTypeInfo.bytes); - return GL_OUT_OF_MEMORY; + return gl::Error(GL_OUT_OF_MEMORY, "Reserving %u indices of %u bytes each exceeds the maximum buffer size.", + convertCount, destTypeInfo.bytes); } unsigned int bufferSizeRequired = convertCount * destTypeInfo.bytes; - if (!indexBuffer->reserveBufferSpace(bufferSizeRequired, type)) + error = indexBuffer->reserveBufferSpace(bufferSizeRequired, type); + if (error.isError()) { - ERR("Failed to reserve %u bytes in an index buffer.", bufferSizeRequired); - return GL_OUT_OF_MEMORY; + return error; } void* output = NULL; - if (!indexBuffer->mapBuffer(bufferSizeRequired, &output, &streamOffset)) + error = indexBuffer->mapBuffer(bufferSizeRequired, &output, &streamOffset); + if (error.isError()) { - ERR("Failed to map index buffer."); - return GL_OUT_OF_MEMORY; + return error; } ConvertIndices(type, destinationIndexType, staticBuffer ? storage->getData() : indices, convertCount, output); - if (!indexBuffer->unmapBuffer()) + error = indexBuffer->unmapBuffer(); + if (error.isError()) { - ERR("Failed to unmap index buffer."); - return GL_OUT_OF_MEMORY; + return error; } if (staticBuffer) @@ -214,10 +210,10 @@ GLenum IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buffer storage->promoteStaticUsage(count * typeInfo.bytes); } - return GL_NO_ERROR; + return gl::Error(GL_NO_ERROR); } -GLenum IndexDataManager::getStreamingIndexBuffer(GLenum destinationIndexType, IndexBufferInterface **outBuffer) +gl::Error IndexDataManager::getStreamingIndexBuffer(GLenum destinationIndexType, IndexBufferInterface **outBuffer) { ASSERT(outBuffer); if (destinationIndexType == GL_UNSIGNED_INT) @@ -225,16 +221,16 @@ GLenum IndexDataManager::getStreamingIndexBuffer(GLenum destinationIndexType, In if (!mStreamingBufferInt) { mStreamingBufferInt = new StreamingIndexBufferInterface(mRenderer); - if (!mStreamingBufferInt->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT)) + gl::Error error = mStreamingBufferInt->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT); + if (error.isError()) { SafeDelete(mStreamingBufferInt); - ERR("Failed to allocate the streaming GL_UNSIGNED_INT index buffer."); - return GL_OUT_OF_MEMORY; + return error; } } *outBuffer = mStreamingBufferInt; - return GL_NO_ERROR; + return gl::Error(GL_NO_ERROR); } else { @@ -243,16 +239,16 @@ GLenum IndexDataManager::getStreamingIndexBuffer(GLenum destinationIndexType, In if (!mStreamingBufferShort) { mStreamingBufferShort = new StreamingIndexBufferInterface(mRenderer); - if (!mStreamingBufferShort->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT)) + gl::Error error = mStreamingBufferShort->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_SHORT); + if (error.isError()) { SafeDelete(mStreamingBufferShort); - ERR("Failed to allocate the streaming GL_UNSIGNED_SHORT index buffer."); - return GL_OUT_OF_MEMORY; + return error; } } *outBuffer = mStreamingBufferShort; - return GL_NO_ERROR; + return gl::Error(GL_NO_ERROR); } } diff --git a/src/libGLESv2/renderer/d3d/IndexDataManager.h b/src/libGLESv2/renderer/d3d/IndexDataManager.h index fef7f322..6d0b89e6 100644 --- a/src/libGLESv2/renderer/d3d/IndexDataManager.h +++ b/src/libGLESv2/renderer/d3d/IndexDataManager.h @@ -12,6 +12,7 @@ #include "common/angleutils.h" #include "common/mathutil.h" +#include "libGLESv2/Error.h" #include <GLES2/gl2.h> @@ -52,10 +53,10 @@ class IndexDataManager explicit IndexDataManager(Renderer *renderer); virtual ~IndexDataManager(); - GLenum prepareIndexData(GLenum type, GLsizei count, gl::Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated); + gl::Error prepareIndexData(GLenum type, GLsizei count, gl::Buffer *arrayElementBuffer, const GLvoid *indices, TranslatedIndexData *translated); private: - GLenum getStreamingIndexBuffer(GLenum destinationIndexType, IndexBufferInterface **outBuffer); + gl::Error getStreamingIndexBuffer(GLenum destinationIndexType, IndexBufferInterface **outBuffer); DISALLOW_COPY_AND_ASSIGN(IndexDataManager); diff --git a/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp b/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp index f2dd5052..9a61182e 100644 --- a/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp +++ b/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.cpp @@ -24,7 +24,7 @@ IndexBuffer11::~IndexBuffer11() SafeRelease(mBuffer); } -bool IndexBuffer11::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) +gl::Error IndexBuffer11::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) { SafeRelease(mBuffer); @@ -45,7 +45,7 @@ bool IndexBuffer11::initialize(unsigned int bufferSize, GLenum indexType, bool d HRESULT result = dxDevice->CreateBuffer(&bufferDesc, NULL, &mBuffer); if (FAILED(result)) { - return false; + return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal index buffer of size, %lu.", bufferSize); } } @@ -53,7 +53,7 @@ bool IndexBuffer11::initialize(unsigned int bufferSize, GLenum indexType, bool d mIndexType = indexType; mDynamicUsage = dynamic; - return true; + return gl::Error(GL_NO_ERROR); } IndexBuffer11 *IndexBuffer11::makeIndexBuffer11(IndexBuffer *indexBuffer) @@ -62,50 +62,42 @@ IndexBuffer11 *IndexBuffer11::makeIndexBuffer11(IndexBuffer *indexBuffer) return static_cast<IndexBuffer11*>(indexBuffer); } -bool IndexBuffer11::mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) +gl::Error IndexBuffer11::mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) { - if (mBuffer) + if (!mBuffer) { - // Check for integer overflows and out-out-bounds map requests - if (offset + size < offset || offset + size > mBufferSize) - { - ERR("Index buffer map range is not inside the buffer."); - return false; - } + return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized."); + } - ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext(); + // Check for integer overflows and out-out-bounds map requests + if (offset + size < offset || offset + size > mBufferSize) + { + return gl::Error(GL_OUT_OF_MEMORY, "Index buffer map range is not inside the buffer."); + } - D3D11_MAPPED_SUBRESOURCE mappedResource; - HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource); - if (FAILED(result)) - { - ERR("Index buffer map failed with error 0x%08x", result); - return false; - } + ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext(); - *outMappedMemory = reinterpret_cast<char*>(mappedResource.pData) + offset; - return true; - } - else + D3D11_MAPPED_SUBRESOURCE mappedResource; + HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_NO_OVERWRITE, 0, &mappedResource); + if (FAILED(result)) { - ERR("Index buffer not initialized."); - return false; + return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal index buffer, HRESULT: 0x%08x.", result); } + + *outMappedMemory = reinterpret_cast<char*>(mappedResource.pData) + offset; + return gl::Error(GL_NO_ERROR); } -bool IndexBuffer11::unmapBuffer() +gl::Error IndexBuffer11::unmapBuffer() { - if (mBuffer) + if (!mBuffer) { - ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext(); - dxContext->Unmap(mBuffer, 0); - return true; - } - else - { - ERR("Index buffer not initialized."); - return false; + return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized."); } + + ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext(); + dxContext->Unmap(mBuffer, 0); + return gl::Error(GL_NO_ERROR); } GLenum IndexBuffer11::getIndexType() const @@ -118,7 +110,7 @@ unsigned int IndexBuffer11::getBufferSize() const return mBufferSize; } -bool IndexBuffer11::setSize(unsigned int bufferSize, GLenum indexType) +gl::Error IndexBuffer11::setSize(unsigned int bufferSize, GLenum indexType) { if (bufferSize > mBufferSize || indexType != mIndexType) { @@ -126,33 +118,29 @@ bool IndexBuffer11::setSize(unsigned int bufferSize, GLenum indexType) } else { - return true; + return gl::Error(GL_NO_ERROR); } } -bool IndexBuffer11::discard() +gl::Error IndexBuffer11::discard() { - if (mBuffer) + if (!mBuffer) { - ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext(); - - D3D11_MAPPED_SUBRESOURCE mappedResource; - HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); - if (FAILED(result)) - { - ERR("Index buffer map failed with error 0x%08x", result); - return false; - } + return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized."); + } - dxContext->Unmap(mBuffer, 0); + ID3D11DeviceContext *dxContext = mRenderer->getDeviceContext(); - return true; - } - else + D3D11_MAPPED_SUBRESOURCE mappedResource; + HRESULT result = dxContext->Map(mBuffer, 0, D3D11_MAP_WRITE_DISCARD, 0, &mappedResource); + if (FAILED(result)) { - ERR("Index buffer not initialized."); - return false; + return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal index buffer, HRESULT: 0x%08x.", result); } + + dxContext->Unmap(mBuffer, 0); + + return gl::Error(GL_NO_ERROR); } DXGI_FORMAT IndexBuffer11::getIndexFormat() const @@ -171,4 +159,4 @@ ID3D11Buffer *IndexBuffer11::getBuffer() const return mBuffer; } -}
\ No newline at end of file +} diff --git a/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h b/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h index e821b7f3..f7c2b38e 100644 --- a/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h +++ b/src/libGLESv2/renderer/d3d/d3d11/IndexBuffer11.h @@ -21,18 +21,18 @@ class IndexBuffer11 : public IndexBuffer explicit IndexBuffer11(Renderer11 *const renderer); virtual ~IndexBuffer11(); - virtual bool initialize(unsigned int bufferSize, GLenum indexType, bool dynamic); + virtual gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic); static IndexBuffer11 *makeIndexBuffer11(IndexBuffer *indexBuffer); - virtual bool mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory); - virtual bool unmapBuffer(); + virtual gl::Error mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory); + virtual gl::Error unmapBuffer(); virtual GLenum getIndexType() const; virtual unsigned int getBufferSize() const; - virtual bool setSize(unsigned int bufferSize, GLenum indexType); + virtual gl::Error setSize(unsigned int bufferSize, GLenum indexType); - virtual bool discard(); + virtual gl::Error discard(); DXGI_FORMAT getIndexFormat() const; ID3D11Buffer *getBuffer() const; diff --git a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp index 9bb2c5c4..de850719 100644 --- a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp +++ b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.cpp @@ -941,37 +941,38 @@ GLenum Renderer11::applyVertexBuffer(gl::ProgramBinary *programBinary, const gl: return mInputLayoutCache.applyVertexBuffers(attributes, programBinary); } -GLenum Renderer11::applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo) +gl::Error Renderer11::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()) { - ID3D11Buffer *buffer = NULL; - DXGI_FORMAT bufferFormat = (indexInfo->indexType == GL_UNSIGNED_INT) ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT; + return error; + } - if (indexInfo->storage) - { - Buffer11 *storage = Buffer11::makeBuffer11(indexInfo->storage); - buffer = storage->getBuffer(BUFFER_USAGE_INDEX); - } - else - { - IndexBuffer11* indexBuffer = IndexBuffer11::makeIndexBuffer11(indexInfo->indexBuffer); - buffer = indexBuffer->getBuffer(); - } + ID3D11Buffer *buffer = NULL; + DXGI_FORMAT bufferFormat = (indexInfo->indexType == GL_UNSIGNED_INT) ? DXGI_FORMAT_R32_UINT : DXGI_FORMAT_R16_UINT; - if (buffer != mAppliedIB || bufferFormat != mAppliedIBFormat || indexInfo->startOffset != mAppliedIBOffset) - { - mDeviceContext->IASetIndexBuffer(buffer, bufferFormat, indexInfo->startOffset); + if (indexInfo->storage) + { + Buffer11 *storage = Buffer11::makeBuffer11(indexInfo->storage); + buffer = storage->getBuffer(BUFFER_USAGE_INDEX); + } + else + { + IndexBuffer11* indexBuffer = IndexBuffer11::makeIndexBuffer11(indexInfo->indexBuffer); + buffer = indexBuffer->getBuffer(); + } - mAppliedIB = buffer; - mAppliedIBFormat = bufferFormat; - mAppliedIBOffset = indexInfo->startOffset; - } + if (buffer != mAppliedIB || bufferFormat != mAppliedIBFormat || indexInfo->startOffset != mAppliedIBOffset) + { + mDeviceContext->IASetIndexBuffer(buffer, bufferFormat, indexInfo->startOffset); + + mAppliedIB = buffer; + mAppliedIBFormat = bufferFormat; + mAppliedIBOffset = indexInfo->startOffset; } - return err; + return gl::Error(GL_NO_ERROR); } void Renderer11::applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]) @@ -1101,10 +1102,10 @@ void Renderer11::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); @@ -1121,7 +1122,8 @@ void Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indices, } const unsigned int spaceNeeded = (static_cast<unsigned int>(count) + 1) * sizeof(unsigned int); - if (!mLineLoopIB->reserveBufferSpace(spaceNeeded, GL_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); @@ -1129,7 +1131,8 @@ void Renderer11::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); @@ -1171,7 +1174,8 @@ void Renderer11::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); @@ -1206,10 +1210,10 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic if (!mTriangleFanIB) { mTriangleFanIB = new StreamingIndexBufferInterface(this); - if (!mTriangleFanIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT)) + gl::Error error = mTriangleFanIB->reserveBufferSpace(INITIAL_INDEX_BUFFER_SIZE, GL_UNSIGNED_INT); + if (error.isError()) { - delete mTriangleFanIB; - mTriangleFanIB = NULL; + SafeDelete(mTriangleFanIB); ERR("Could not create a scratch index buffer for GL_TRIANGLE_FAN."); return gl::error(GL_OUT_OF_MEMORY); @@ -1228,7 +1232,8 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic } const unsigned int spaceNeeded = (numTris * 3) * sizeof(unsigned int); - if (!mTriangleFanIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT)) + gl::Error error = mTriangleFanIB->reserveBufferSpace(spaceNeeded, GL_UNSIGNED_INT); + if (error.isError()) { ERR("Could not reserve enough space in scratch index buffer for GL_TRIANGLE_FAN."); return gl::error(GL_OUT_OF_MEMORY); @@ -1236,7 +1241,8 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic void* mappedMemory = NULL; unsigned int offset; - if (!mTriangleFanIB->mapBuffer(spaceNeeded, &mappedMemory, &offset)) + error = mTriangleFanIB->mapBuffer(spaceNeeded, &mappedMemory, &offset); + if (error.isError()) { ERR("Could not map scratch index buffer for GL_TRIANGLE_FAN."); return gl::error(GL_OUT_OF_MEMORY); @@ -1282,7 +1288,8 @@ void Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *indic default: UNREACHABLE(); } - if (!mTriangleFanIB->unmapBuffer()) + error = mTriangleFanIB->unmapBuffer(); + if (error.isError()) { ERR("Could not unmap scratch index buffer for GL_TRIANGLE_FAN."); return gl::error(GL_OUT_OF_MEMORY); diff --git a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h index 64de7b03..ae6d2845 100644 --- a/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h +++ b/src/libGLESv2/renderer/d3d/d3d11/Renderer11.h @@ -82,7 +82,7 @@ class Renderer11 : public Renderer virtual void applyUniforms(const gl::ProgramBinary &programBinary); virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[], GLint first, GLsizei count, GLsizei instances); - virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); + virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]); virtual void drawArrays(GLenum mode, GLsizei count, GLsizei instances, bool transformFeedbackActive); diff --git a/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp b/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp index 451ede4c..1c51b9e9 100644 --- a/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp +++ b/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.cpp @@ -25,7 +25,7 @@ IndexBuffer9::~IndexBuffer9() SafeRelease(mIndexBuffer); } -bool IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) +gl::Error IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bool dynamic) { SafeRelease(mIndexBuffer); @@ -33,28 +33,17 @@ bool IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bool dy if (bufferSize > 0) { - D3DFORMAT format; + D3DFORMAT format = D3DFMT_UNKNOWN; if (indexType == GL_UNSIGNED_SHORT || indexType == GL_UNSIGNED_BYTE) { format = D3DFMT_INDEX16; } else if (indexType == GL_UNSIGNED_INT) { - if (mRenderer->getRendererExtensions().elementIndexUint) - { - format = D3DFMT_INDEX32; - } - else - { - ERR("Attempted to create a 32-bit index buffer but renderer does not support 32-bit indices."); - return false; - } - } - else - { - ERR("Invalid index type %u.", indexType); - return false; + ASSERT(mRenderer->getRendererExtensions().elementIndexUint); + format = D3DFMT_INDEX32; } + else UNREACHABLE(); DWORD usageFlags = D3DUSAGE_WRITEONLY; if (dynamic) @@ -65,8 +54,7 @@ bool IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bool dy HRESULT result = mRenderer->createIndexBuffer(bufferSize, usageFlags, format, &mIndexBuffer); if (FAILED(result)) { - ERR("Failed to create an index buffer of size %u, result: 0x%08x.", mBufferSize, result); - return false; + return gl::Error(GL_OUT_OF_MEMORY, "Failed to allocate internal index buffer of size, %lu.", bufferSize); } } @@ -74,7 +62,7 @@ bool IndexBuffer9::initialize(unsigned int bufferSize, GLenum indexType, bool dy mIndexType = indexType; mDynamic = dynamic; - return true; + return gl::Error(GL_NO_ERROR); } IndexBuffer9 *IndexBuffer9::makeIndexBuffer9(IndexBuffer *indexBuffer) @@ -83,48 +71,40 @@ IndexBuffer9 *IndexBuffer9::makeIndexBuffer9(IndexBuffer *indexBuffer) return static_cast<IndexBuffer9*>(indexBuffer); } -bool IndexBuffer9::mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) +gl::Error IndexBuffer9::mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory) { - if (mIndexBuffer) + if (!mIndexBuffer) { - DWORD lockFlags = mDynamic ? D3DLOCK_NOOVERWRITE : 0; + return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized."); + } - void *mapPtr = NULL; - HRESULT result = mIndexBuffer->Lock(offset, size, &mapPtr, lockFlags); - if (FAILED(result)) - { - ERR("Index buffer lock failed with error 0x%08x", result); - return false; - } + DWORD lockFlags = mDynamic ? D3DLOCK_NOOVERWRITE : 0; - *outMappedMemory = mapPtr; - return true; - } - else + void *mapPtr = NULL; + HRESULT result = mIndexBuffer->Lock(offset, size, &mapPtr, lockFlags); + if (FAILED(result)) { - ERR("Index buffer not initialized."); - return false; + return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal index buffer, HRESULT: 0x%08x.", result); } + + *outMappedMemory = mapPtr; + return gl::Error(GL_NO_ERROR); } -bool IndexBuffer9::unmapBuffer() +gl::Error IndexBuffer9::unmapBuffer() { - if (mIndexBuffer) + if (!mIndexBuffer) { - HRESULT result = mIndexBuffer->Unlock(); - if (FAILED(result)) - { - ERR("Index buffer unlock failed with error 0x%08x", result); - return false; - } - - return true; + return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized."); } - else + + HRESULT result = mIndexBuffer->Unlock(); + if (FAILED(result)) { - ERR("Index buffer not initialized."); - return false; + return gl::Error(GL_OUT_OF_MEMORY, "Failed to unlock internal index buffer, HRESULT: 0x%08x.", result); } + + return gl::Error(GL_NO_ERROR); } GLenum IndexBuffer9::getIndexType() const @@ -137,7 +117,7 @@ unsigned int IndexBuffer9::getBufferSize() const return mBufferSize; } -bool IndexBuffer9::setSize(unsigned int bufferSize, GLenum indexType) +gl::Error IndexBuffer9::setSize(unsigned int bufferSize, GLenum indexType) { if (bufferSize > mBufferSize || indexType != mIndexType) { @@ -145,38 +125,33 @@ bool IndexBuffer9::setSize(unsigned int bufferSize, GLenum indexType) } else { - return true; + return gl::Error(GL_NO_ERROR); } } -bool IndexBuffer9::discard() +gl::Error IndexBuffer9::discard() { - if (mIndexBuffer) + if (!mIndexBuffer) { - void *dummy; - HRESULT result; - - result = mIndexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD); - if (FAILED(result)) - { - ERR("Discard lock failed with error 0x%08x", result); - return false; - } + return gl::Error(GL_OUT_OF_MEMORY, "Internal index buffer is not initialized."); + } - result = mIndexBuffer->Unlock(); - if (FAILED(result)) - { - ERR("Discard unlock failed with error 0x%08x", result); - return false; - } + void *dummy; + HRESULT result; - return true; + result = mIndexBuffer->Lock(0, 1, &dummy, D3DLOCK_DISCARD); + if (FAILED(result)) + { + return gl::Error(GL_OUT_OF_MEMORY, "Failed to lock internal index buffer, HRESULT: 0x%08x.", result); } - else + + result = mIndexBuffer->Unlock(); + if (FAILED(result)) { - ERR("Index buffer not initialized."); - return false; + return gl::Error(GL_OUT_OF_MEMORY, "Failed to unlock internal index buffer, HRESULT: 0x%08x.", result); } + + return gl::Error(GL_NO_ERROR); } D3DFORMAT IndexBuffer9::getIndexFormat() const @@ -195,4 +170,4 @@ IDirect3DIndexBuffer9 * IndexBuffer9::getBuffer() const return mIndexBuffer; } -}
\ No newline at end of file +} diff --git a/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h b/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h index cfc20e1c..d0970d6a 100644 --- a/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h +++ b/src/libGLESv2/renderer/d3d/d3d9/IndexBuffer9.h @@ -21,18 +21,18 @@ class IndexBuffer9 : public IndexBuffer explicit IndexBuffer9(Renderer9 *const renderer); virtual ~IndexBuffer9(); - virtual bool initialize(unsigned int bufferSize, GLenum indexType, bool dynamic); + virtual gl::Error initialize(unsigned int bufferSize, GLenum indexType, bool dynamic); static IndexBuffer9 *makeIndexBuffer9(IndexBuffer *indexBuffer); - virtual bool mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory); - virtual bool unmapBuffer(); + virtual gl::Error mapBuffer(unsigned int offset, unsigned int size, void** outMappedMemory); + virtual gl::Error unmapBuffer(); virtual GLenum getIndexType() const; virtual unsigned int getBufferSize() const; - virtual bool setSize(unsigned int bufferSize, GLenum indexType); + virtual gl::Error setSize(unsigned int bufferSize, GLenum indexType); - virtual bool discard(); + virtual gl::Error discard(); D3DFORMAT getIndexFormat() const; IDirect3DIndexBuffer9 *getBuffer() const; 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; diff --git a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h index d6a41b61..6dfad26f 100644 --- a/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h +++ b/src/libGLESv2/renderer/d3d/d3d9/Renderer9.h @@ -83,7 +83,7 @@ class Renderer9 : public Renderer virtual bool applyPrimitiveType(GLenum primitiveType, GLsizei elementCount); virtual GLenum applyVertexBuffer(gl::ProgramBinary *programBinary, const gl::VertexAttribute vertexAttributes[], const gl::VertexAttribCurrentValueData currentValues[], GLint first, GLsizei count, GLsizei instances); - virtual GLenum applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); + virtual gl::Error applyIndexBuffer(const GLvoid *indices, gl::Buffer *elementArrayBuffer, GLsizei count, GLenum mode, GLenum type, TranslatedIndexData *indexInfo); virtual void applyTransformFeedbackBuffers(gl::Buffer *transformFeedbackBuffers[], GLintptr offsets[]); |