Commit c8d297a4 by Geoff Lang

Remove last uses of gl::error in the Buffer classes.

BUG=angle:520 Change-Id: Id18e93b440da64360a6845a42a2664ae531b06f9 Reviewed-on: https://chromium-review.googlesource.com/218769Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org> Tested-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent f9004131
...@@ -12,6 +12,8 @@ ...@@ -12,6 +12,8 @@
#include "common/angleutils.h" #include "common/angleutils.h"
#include "libGLESv2/Buffer.h" #include "libGLESv2/Buffer.h"
#include <cstdint>
namespace rx namespace rx
{ {
...@@ -21,7 +23,7 @@ class BufferImpl ...@@ -21,7 +23,7 @@ class BufferImpl
virtual ~BufferImpl() { } virtual ~BufferImpl() { }
virtual gl::Error setData(const void* data, size_t size, GLenum usage) = 0; virtual gl::Error setData(const void* data, size_t size, GLenum usage) = 0;
virtual void *getData() = 0; virtual gl::Error getData(const uint8_t **outData) = 0;
virtual gl::Error setSubData(const void* data, size_t size, size_t offset) = 0; virtual gl::Error setSubData(const void* data, size_t size, size_t offset) = 0;
virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) = 0; virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size) = 0;
virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) = 0; virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr) = 0;
......
...@@ -97,7 +97,14 @@ gl::Error IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buf ...@@ -97,7 +97,14 @@ gl::Error IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buf
ASSERT(typeInfo.bytes * static_cast<unsigned int>(count) + offset <= storage->getSize()); ASSERT(typeInfo.bytes * static_cast<unsigned int>(count) + offset <= storage->getSize());
indices = static_cast<const GLubyte*>(storage->getData()) + offset; const uint8_t *bufferData = NULL;
gl::Error error = storage->getData(&bufferData);
if (error.isError())
{
return error;
}
indices = bufferData + offset;
} }
StaticIndexBufferInterface *staticBuffer = storage ? storage->getStaticIndexBuffer() : NULL; StaticIndexBufferInterface *staticBuffer = storage ? storage->getStaticIndexBuffer() : NULL;
...@@ -183,7 +190,16 @@ gl::Error IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buf ...@@ -183,7 +190,16 @@ gl::Error IndexDataManager::prepareIndexData(GLenum type, GLsizei count, gl::Buf
return error; return error;
} }
ConvertIndices(type, destinationIndexType, staticBuffer ? storage->getData() : indices, convertCount, output); const uint8_t *dataPointer = reinterpret_cast<const uint8_t*>(indices);
if (staticBuffer)
{
error = storage->getData(&dataPointer);
if (error.isError())
{
return error;
}
}
ConvertIndices(type, destinationIndexType, dataPointer, convertCount, output);
error = indexBuffer->unmapBuffer(); error = indexBuffer->unmapBuffer();
if (error.isError()) if (error.isError())
......
...@@ -132,8 +132,13 @@ gl::Error TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type, ...@@ -132,8 +132,13 @@ gl::Error TextureD3D::setImage(const gl::PixelUnpackState &unpack, GLenum type,
ptrdiff_t offset = reinterpret_cast<ptrdiff_t>(pixels); ptrdiff_t offset = reinterpret_cast<ptrdiff_t>(pixels);
// TODO: setImage/subImage is the only place outside of renderer that asks for a buffers raw data. // TODO: setImage/subImage is the only place outside of renderer that asks for a buffers raw data.
// This functionality should be moved into renderer and the getData method of BufferImpl removed. // This functionality should be moved into renderer and the getData method of BufferImpl removed.
const void *bufferData = pixelBuffer->getImplementation()->getData(); const uint8_t *bufferData = NULL;
pixelData = static_cast<const uint8_t *>(bufferData) + offset; gl::Error error = pixelBuffer->getImplementation()->getData(&bufferData);
if (error.isError())
{
return error;
}
pixelData = bufferData + offset;
} }
else else
{ {
...@@ -176,8 +181,13 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi ...@@ -176,8 +181,13 @@ gl::Error TextureD3D::subImage(GLint xoffset, GLint yoffset, GLint zoffset, GLsi
uintptr_t offset = reinterpret_cast<uintptr_t>(pixels); uintptr_t offset = reinterpret_cast<uintptr_t>(pixels);
// TODO: setImage/subImage is the only place outside of renderer that asks for a buffers raw data. // TODO: setImage/subImage is the only place outside of renderer that asks for a buffers raw data.
// This functionality should be moved into renderer and the getData method of BufferImpl removed. // This functionality should be moved into renderer and the getData method of BufferImpl removed.
const void *bufferData = pixelBuffer->getImplementation()->getData(); const uint8_t *bufferData = NULL;
pixelData = static_cast<const uint8_t *>(bufferData)+offset; gl::Error error = pixelBuffer->getImplementation()->getData(&bufferData);
if (error.isError())
{
return error;
}
pixelData = bufferData + offset;
} }
if (pixelData != NULL) if (pixelData != NULL)
......
...@@ -86,7 +86,7 @@ class Buffer11::BufferStorage11 ...@@ -86,7 +86,7 @@ class Buffer11::BufferStorage11
virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset, virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset,
size_t size, size_t destOffset) = 0; size_t size, size_t destOffset) = 0;
virtual bool resize(size_t size, bool preserveData) = 0; virtual gl::Error resize(size_t size, bool preserveData) = 0;
virtual void *map(size_t offset, size_t length, GLbitfield access) = 0; virtual void *map(size_t offset, size_t length, GLbitfield access) = 0;
virtual void unmap() = 0; virtual void unmap() = 0;
...@@ -112,12 +112,12 @@ class Buffer11::NativeBuffer11 : public Buffer11::BufferStorage11 ...@@ -112,12 +112,12 @@ class Buffer11::NativeBuffer11 : public Buffer11::BufferStorage11
virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset, virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset,
size_t size, size_t destOffset); size_t size, size_t destOffset);
virtual bool resize(size_t size, bool preserveData); virtual gl::Error resize(size_t size, bool preserveData);
virtual void *map(size_t offset, size_t length, GLbitfield access); virtual void *map(size_t offset, size_t length, GLbitfield access);
virtual void unmap(); virtual void unmap();
bool setData(D3D11_MAP mapMode, const uint8_t *data, size_t size, size_t offset); gl::Error setData(D3D11_MAP mapMode, const uint8_t *data, size_t size, size_t offset);
private: private:
ID3D11Buffer *mNativeBuffer; ID3D11Buffer *mNativeBuffer;
...@@ -135,7 +135,7 @@ class Buffer11::PackStorage11 : public Buffer11::BufferStorage11 ...@@ -135,7 +135,7 @@ class Buffer11::PackStorage11 : public Buffer11::BufferStorage11
virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset, virtual bool copyFromStorage(BufferStorage11 *source, size_t sourceOffset,
size_t size, size_t destOffset); size_t size, size_t destOffset);
virtual bool resize(size_t size, bool preserveData); virtual gl::Error resize(size_t size, bool preserveData);
virtual void *map(size_t offset, size_t length, GLbitfield access); virtual void *map(size_t offset, size_t length, GLbitfield access);
virtual void unmap(); virtual void unmap();
...@@ -195,14 +195,14 @@ gl::Error Buffer11::setData(const void *data, size_t size, GLenum usage) ...@@ -195,14 +195,14 @@ gl::Error Buffer11::setData(const void *data, size_t size, GLenum usage)
return error; return error;
} }
void *Buffer11::getData() gl::Error Buffer11::getData(const uint8_t **outData)
{ {
NativeBuffer11 *stagingBuffer = getStagingBuffer(); NativeBuffer11 *stagingBuffer = getStagingBuffer();
if (!stagingBuffer) if (!stagingBuffer)
{ {
// Out-of-memory // Out-of-memory
return NULL; return gl::Error(GL_OUT_OF_MEMORY, "Failed to get internal staging buffer.");
} }
if (stagingBuffer->getDataRevision() > mResolvedDataRevision) if (stagingBuffer->getDataRevision() > mResolvedDataRevision)
...@@ -211,7 +211,7 @@ void *Buffer11::getData() ...@@ -211,7 +211,7 @@ void *Buffer11::getData()
{ {
if (!mResolvedData.resize(stagingBuffer->getSize())) if (!mResolvedData.resize(stagingBuffer->getSize()))
{ {
return gl::error(GL_OUT_OF_MEMORY, (void*)NULL); return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize data resolve buffer.");
} }
} }
...@@ -221,7 +221,7 @@ void *Buffer11::getData() ...@@ -221,7 +221,7 @@ void *Buffer11::getData()
HRESULT result = context->Map(stagingBuffer->getNativeBuffer(), 0, D3D11_MAP_READ, 0, &mappedResource); HRESULT result = context->Map(stagingBuffer->getNativeBuffer(), 0, D3D11_MAP_READ, 0, &mappedResource);
if (FAILED(result)) if (FAILED(result))
{ {
return gl::error(GL_OUT_OF_MEMORY, (void*)NULL); return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal buffer, result: 0x%X.", result);
} }
memcpy(mResolvedData.data(), mappedResource.pData, stagingBuffer->getSize()); memcpy(mResolvedData.data(), mappedResource.pData, stagingBuffer->getSize());
...@@ -238,13 +238,14 @@ void *Buffer11::getData() ...@@ -238,13 +238,14 @@ void *Buffer11::getData()
{ {
if (!mResolvedData.resize(mSize)) if (!mResolvedData.resize(mSize))
{ {
return gl::error(GL_OUT_OF_MEMORY, (void*)NULL); return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize data resolve buffer.");
} }
} }
ASSERT(mResolvedData.size() >= mSize); ASSERT(mResolvedData.size() >= mSize);
return mResolvedData.data(); *outData = mResolvedData.data();
return gl::Error(GL_NO_ERROR);
} }
gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset) gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset)
...@@ -265,15 +266,17 @@ gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset) ...@@ -265,15 +266,17 @@ gl::Error Buffer11::setSubData(const void *data, size_t size, size_t offset)
if (stagingBuffer->getSize() < requiredSize) if (stagingBuffer->getSize() < requiredSize)
{ {
bool preserveData = (offset > 0); bool preserveData = (offset > 0);
if (!stagingBuffer->resize(requiredSize, preserveData)) gl::Error error = stagingBuffer->resize(requiredSize, preserveData);
if (error.isError())
{ {
return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize internal staging buffer."); return error;
} }
} }
if (!stagingBuffer->setData(D3D11_MAP_WRITE, reinterpret_cast<const uint8_t *>(data), size, offset)) gl::Error error = stagingBuffer->setData(D3D11_MAP_WRITE, reinterpret_cast<const uint8_t *>(data), size, offset);
if (error.isError())
{ {
return gl::Error(GL_OUT_OF_MEMORY, "Failed to set data on internal staging buffer."); return error;
} }
stagingBuffer->setDataRevision(stagingBuffer->getDataRevision() + 1); stagingBuffer->setDataRevision(stagingBuffer->getDataRevision() + 1);
...@@ -527,7 +530,7 @@ Buffer11::BufferStorage11 *Buffer11::getBufferStorage(BufferUsage usage) ...@@ -527,7 +530,7 @@ Buffer11::BufferStorage11 *Buffer11::getBufferStorage(BufferUsage usage)
// resize buffer // resize buffer
if (directBuffer->getSize() < mSize) if (directBuffer->getSize() < mSize)
{ {
if (!directBuffer->resize(mSize, true)) if (directBuffer->resize(mSize, true).isError())
{ {
// Out of memory error // Out of memory error
return NULL; return NULL;
...@@ -692,7 +695,7 @@ bool Buffer11::NativeBuffer11::copyFromStorage(BufferStorage11 *source, size_t s ...@@ -692,7 +695,7 @@ bool Buffer11::NativeBuffer11::copyFromStorage(BufferStorage11 *source, size_t s
return createBuffer; return createBuffer;
} }
bool Buffer11::NativeBuffer11::resize(size_t size, bool preserveData) gl::Error Buffer11::NativeBuffer11::resize(size_t size, bool preserveData)
{ {
ID3D11Device *device = mRenderer->getDevice(); ID3D11Device *device = mRenderer->getDevice();
ID3D11DeviceContext *context = mRenderer->getDeviceContext(); ID3D11DeviceContext *context = mRenderer->getDeviceContext();
...@@ -705,7 +708,7 @@ bool Buffer11::NativeBuffer11::resize(size_t size, bool preserveData) ...@@ -705,7 +708,7 @@ bool Buffer11::NativeBuffer11::resize(size_t size, bool preserveData)
if (FAILED(result)) if (FAILED(result))
{ {
return gl::error(GL_OUT_OF_MEMORY, false); return gl::Error(GL_OUT_OF_MEMORY, "Failed to create internal buffer, result: 0x%X.", result);
} }
if (mNativeBuffer && preserveData) if (mNativeBuffer && preserveData)
...@@ -730,7 +733,7 @@ bool Buffer11::NativeBuffer11::resize(size_t size, bool preserveData) ...@@ -730,7 +733,7 @@ bool Buffer11::NativeBuffer11::resize(size_t size, bool preserveData)
mBufferSize = bufferDesc.ByteWidth; mBufferSize = bufferDesc.ByteWidth;
return true; return gl::Error(GL_NO_ERROR);
} }
void Buffer11::NativeBuffer11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer, void Buffer11::NativeBuffer11::fillBufferDesc(D3D11_BUFFER_DESC* bufferDesc, Renderer *renderer,
...@@ -798,7 +801,7 @@ void *Buffer11::NativeBuffer11::map(size_t offset, size_t length, GLbitfield acc ...@@ -798,7 +801,7 @@ void *Buffer11::NativeBuffer11::map(size_t offset, size_t length, GLbitfield acc
return static_cast<GLubyte*>(mappedResource.pData) + offset; return static_cast<GLubyte*>(mappedResource.pData) + offset;
} }
bool Buffer11::NativeBuffer11::setData(D3D11_MAP mapMode, const uint8_t *data, size_t size, size_t offset) gl::Error Buffer11::NativeBuffer11::setData(D3D11_MAP mapMode, const uint8_t *data, size_t size, size_t offset)
{ {
ID3D11DeviceContext *context = mRenderer->getDeviceContext(); ID3D11DeviceContext *context = mRenderer->getDeviceContext();
...@@ -806,7 +809,7 @@ bool Buffer11::NativeBuffer11::setData(D3D11_MAP mapMode, const uint8_t *data, s ...@@ -806,7 +809,7 @@ bool Buffer11::NativeBuffer11::setData(D3D11_MAP mapMode, const uint8_t *data, s
HRESULT result = context->Map(mNativeBuffer, 0, mapMode, 0, &mappedResource); HRESULT result = context->Map(mNativeBuffer, 0, mapMode, 0, &mappedResource);
if (FAILED(result)) if (FAILED(result))
{ {
return gl::error(GL_OUT_OF_MEMORY, false); return gl::Error(GL_OUT_OF_MEMORY, "Failed to map internal buffer, result: 0x%X.", result);
} }
uint8_t *offsetBufferPointer = reinterpret_cast<uint8_t *>(mappedResource.pData) + offset; uint8_t *offsetBufferPointer = reinterpret_cast<uint8_t *>(mappedResource.pData) + offset;
...@@ -814,7 +817,7 @@ bool Buffer11::NativeBuffer11::setData(D3D11_MAP mapMode, const uint8_t *data, s ...@@ -814,7 +817,7 @@ bool Buffer11::NativeBuffer11::setData(D3D11_MAP mapMode, const uint8_t *data, s
context->Unmap(mNativeBuffer, 0); context->Unmap(mNativeBuffer, 0);
return true; return gl::Error(GL_NO_ERROR);
} }
void Buffer11::NativeBuffer11::unmap() void Buffer11::NativeBuffer11::unmap()
...@@ -848,18 +851,18 @@ bool Buffer11::PackStorage11::copyFromStorage(BufferStorage11 *source, size_t so ...@@ -848,18 +851,18 @@ bool Buffer11::PackStorage11::copyFromStorage(BufferStorage11 *source, size_t so
return false; return false;
} }
bool Buffer11::PackStorage11::resize(size_t size, bool preserveData) gl::Error Buffer11::PackStorage11::resize(size_t size, bool preserveData)
{ {
if (size != mBufferSize) if (size != mBufferSize)
{ {
if (!mMemoryBuffer.resize(size)) if (!mMemoryBuffer.resize(size))
{ {
return false; return gl::Error(GL_OUT_OF_MEMORY, "Failed to resize internal buffer storage.");
} }
mBufferSize = size; mBufferSize = size;
} }
return true; return gl::Error(GL_NO_ERROR);
} }
void *Buffer11::PackStorage11::map(size_t offset, size_t length, GLbitfield access) void *Buffer11::PackStorage11::map(size_t offset, size_t length, GLbitfield access)
......
...@@ -64,7 +64,7 @@ class Buffer11 : public BufferD3D ...@@ -64,7 +64,7 @@ class Buffer11 : public BufferD3D
// BufferImpl implementation // BufferImpl implementation
virtual gl::Error setData(const void* data, size_t size, GLenum usage); virtual gl::Error setData(const void* data, size_t size, GLenum usage);
virtual void *getData(); virtual gl::Error getData(const uint8_t **outData);
virtual gl::Error setSubData(const void* data, size_t size, size_t offset); virtual gl::Error setSubData(const void* data, size_t size, size_t offset);
virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr); virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr);
......
...@@ -1197,7 +1197,15 @@ gl::Error Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *ind ...@@ -1197,7 +1197,15 @@ gl::Error Renderer11::drawLineLoop(GLsizei count, GLenum type, const GLvoid *ind
gl::Buffer *indexBuffer = elementArrayBuffer; gl::Buffer *indexBuffer = elementArrayBuffer;
BufferImpl *storage = indexBuffer->getImplementation(); BufferImpl *storage = indexBuffer->getImplementation();
intptr_t offset = reinterpret_cast<intptr_t>(indices); intptr_t offset = reinterpret_cast<intptr_t>(indices);
indices = static_cast<const GLubyte*>(storage->getData()) + offset;
const uint8_t *bufferData = NULL;
gl::Error error = storage->getData(&bufferData);
if (error.isError())
{
return error;
}
indices = bufferData + offset;
} }
if (!mLineLoopIB) if (!mLineLoopIB)
...@@ -1301,7 +1309,15 @@ gl::Error Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid * ...@@ -1301,7 +1309,15 @@ gl::Error Renderer11::drawTriangleFan(GLsizei count, GLenum type, const GLvoid *
gl::Buffer *indexBuffer = elementArrayBuffer; gl::Buffer *indexBuffer = elementArrayBuffer;
BufferImpl *storage = indexBuffer->getImplementation(); BufferImpl *storage = indexBuffer->getImplementation();
intptr_t offset = reinterpret_cast<intptr_t>(indices); intptr_t offset = reinterpret_cast<intptr_t>(indices);
indices = static_cast<const GLubyte*>(storage->getData()) + offset;
const uint8_t *bufferData = NULL;
gl::Error error = storage->getData(&bufferData);
if (error.isError())
{
return error;
}
indices = bufferData + offset;
} }
if (!mTriangleFanIB) if (!mTriangleFanIB)
......
...@@ -91,8 +91,13 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri ...@@ -91,8 +91,13 @@ gl::Error VertexBuffer11::storeVertexAttributes(const gl::VertexAttribute &attri
{ {
if (buffer) if (buffer)
{ {
Buffer11 *storage = Buffer11::makeBuffer11(buffer->getImplementation()); BufferImpl *storage = buffer->getImplementation();
input = static_cast<const uint8_t*>(storage->getData()) + static_cast<int>(attrib.offset); gl::Error error = storage->getData(&input);
if (error.isError())
{
return error;
}
input += static_cast<int>(attrib.offset);
} }
else else
{ {
......
...@@ -56,9 +56,10 @@ gl::Error Buffer9::setData(const void* data, size_t size, GLenum usage) ...@@ -56,9 +56,10 @@ gl::Error Buffer9::setData(const void* data, size_t size, GLenum usage)
return gl::Error(GL_NO_ERROR); return gl::Error(GL_NO_ERROR);
} }
void *Buffer9::getData() gl::Error Buffer9::getData(const uint8_t **outData)
{ {
return mMemory.data(); *outData = mMemory.data();
return gl::Error(GL_NO_ERROR);
} }
gl::Error Buffer9::setSubData(const void* data, size_t size, size_t offset) gl::Error Buffer9::setSubData(const void* data, size_t size, size_t offset)
......
...@@ -32,7 +32,7 @@ class Buffer9 : public BufferD3D ...@@ -32,7 +32,7 @@ class Buffer9 : public BufferD3D
// BufferImpl implementation // BufferImpl implementation
virtual gl::Error setData(const void* data, size_t size, GLenum usage); virtual gl::Error setData(const void* data, size_t size, GLenum usage);
virtual void *getData(); virtual gl::Error getData(const uint8_t **outData);
virtual gl::Error setSubData(const void* data, size_t size, size_t offset); virtual gl::Error setSubData(const void* data, size_t size, size_t offset);
virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size); virtual gl::Error copySubData(BufferImpl* source, GLintptr sourceOffset, GLintptr destOffset, GLsizeiptr size);
virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr); virtual gl::Error map(size_t offset, size_t length, GLbitfield access, GLvoid **mapPtr);
......
...@@ -1415,7 +1415,13 @@ gl::Error Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indi ...@@ -1415,7 +1415,13 @@ gl::Error Renderer9::drawLineLoop(GLsizei count, GLenum type, const GLvoid *indi
gl::Buffer *indexBuffer = elementArrayBuffer; gl::Buffer *indexBuffer = elementArrayBuffer;
BufferImpl *storage = indexBuffer->getImplementation(); BufferImpl *storage = indexBuffer->getImplementation();
intptr_t offset = reinterpret_cast<intptr_t>(indices); intptr_t offset = reinterpret_cast<intptr_t>(indices);
indices = static_cast<const GLubyte*>(storage->getData()) + offset; const uint8_t *bufferData = NULL;
gl::Error error = storage->getData(&bufferData);
if (error.isError())
{
return error;
}
indices = bufferData + offset;
} }
unsigned int startIndex = 0; unsigned int startIndex = 0;
...@@ -1611,7 +1617,15 @@ gl::Error Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid ...@@ -1611,7 +1617,15 @@ gl::Error Renderer9::drawIndexedPoints(GLsizei count, GLenum type, const GLvoid
{ {
BufferImpl *storage = elementArrayBuffer->getImplementation(); BufferImpl *storage = elementArrayBuffer->getImplementation();
intptr_t offset = reinterpret_cast<intptr_t>(indices); intptr_t offset = reinterpret_cast<intptr_t>(indices);
indices = static_cast<const GLubyte*>(storage->getData()) + offset;
const uint8_t *bufferData = NULL;
gl::Error error = storage->getData(&bufferData);
if (error.isError())
{
return error;
}
indices = bufferData + offset;
} }
switch (type) switch (type)
......
...@@ -98,7 +98,12 @@ gl::Error VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib ...@@ -98,7 +98,12 @@ gl::Error VertexBuffer9::storeVertexAttributes(const gl::VertexAttribute &attrib
if (buffer) if (buffer)
{ {
BufferImpl *storage = buffer->getImplementation(); BufferImpl *storage = buffer->getImplementation();
input = static_cast<const uint8_t*>(storage->getData()) + static_cast<int>(attrib.offset); gl::Error error = storage->getData(&input);
if (error.isError())
{
return error;
}
input += static_cast<int>(attrib.offset);
} }
else else
{ {
......
...@@ -1671,8 +1671,15 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t ...@@ -1671,8 +1671,15 @@ bool ValidateDrawElements(Context *context, GLenum mode, GLsizei count, GLenum t
uintptr_t offset = reinterpret_cast<uintptr_t>(indices); uintptr_t offset = reinterpret_cast<uintptr_t>(indices);
if (!elementArrayBuffer->getIndexRangeCache()->findRange(type, offset, count, indexRangeOut, NULL)) if (!elementArrayBuffer->getIndexRangeCache()->findRange(type, offset, count, indexRangeOut, NULL))
{ {
const void *dataPointer = elementArrayBuffer->getImplementation()->getData(); const uint8_t *dataPointer = NULL;
const uint8_t *offsetPointer = static_cast<const uint8_t *>(dataPointer) + offset; Error error = elementArrayBuffer->getImplementation()->getData(&dataPointer);
if (error.isError())
{
context->recordError(error);
return false;
}
const uint8_t *offsetPointer = dataPointer + offset;
*indexRangeOut = rx::IndexRangeCache::ComputeRange(type, offsetPointer, count); *indexRangeOut = rx::IndexRangeCache::ComputeRange(type, offsetPointer, count);
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment