mirror of
https://github.com/utmapp/angle.git
synced 2026-12-01 14:00:09 -10:00
Check that IDirect3DVertexBuffer9 and IDirect3DIndexBuffer9::Lock succeed.
I've been seeing crashes like this on Windows XP: 0x013319aa [libglesv2.dll - memcpy.asm:188] memcpy 0x0130989a [libglesv2.dll - vertexdatamanager.cpp:164] gl::VertexDataManager::preRenderValidate(int,int,gl::TranslatedAttribute *) 0x01304f66 [libglesv2.dll - context.cpp:1996] gl::Context::applyVertexBuffer(unsigned int,int,int,bool *,gl::TranslatedIndexData *) 0x013061a7 [libglesv2.dll - context.cpp:2648] gl::Context::drawArrays(unsigned int,int,int) 0x012f7721 [libglesv2.dll - libglesv2.cpp:1741] glDrawArrays 0x01c54f1e [chrome.dll - gles2_cmd_decoder.cc:3179] gpu::gles2::GLES2DecoderImpl::DoDrawArrays(unsigned int,int,int) 0x01c59122 [chrome.dll - gles2_cmd_decoder_autogen.h:640] gpu::gles2::GLES2DecoderImpl::HandleDrawArrays(unsigned int,gpu::gles2::DrawArrays const &) Review URL: http://codereview.appspot.com/3043042 git-svn-id: https://angleproject.googlecode.com/svn/trunk@480 736b8ea6-26fd-11df-bfd4-992fa37f6226
This commit is contained in:
1 parent
bdfb2e5015
commit
f99fbb77bb
4 files changed
+62
-9
No files matched your search
@@ -103,6 +103,11 @@ GLenum IndexDataManager::preRenderValidate(GLenum mode, GLenum type, GLsizei cou
|
||||
|
||||
size_t offset;
|
||||
void *output = streamIb->map(requiredSpace, &offset);
|
||||
if (output == NULL)
|
||||
{
|
||||
ERR(" failed to map index buffer.");
|
||||
return GL_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
translated->buffer = streamIb;
|
||||
translated->offset = offset;
|
||||
@@ -210,6 +215,11 @@ GLenum IndexDataManager::preRenderValidateUnindexed(GLenum mode, GLsizei count,
|
||||
mLineLoopBuffer = mBackend->createIndexBuffer((count+1) * sizeof(unsigned short), GL_UNSIGNED_SHORT);
|
||||
|
||||
unsigned short *indices = static_cast<unsigned short *>(mLineLoopBuffer->map());
|
||||
if (indices == NULL)
|
||||
{
|
||||
ERR(" failed to map index buffer.");
|
||||
return GL_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
@@ -232,6 +242,11 @@ GLenum IndexDataManager::preRenderValidateUnindexed(GLenum mode, GLsizei count,
|
||||
mCountingBuffer = mBackend->createIndexBuffer(count * sizeof(unsigned short), GL_UNSIGNED_SHORT);
|
||||
|
||||
unsigned short *indices = static_cast<unsigned short *>(mCountingBuffer->map());
|
||||
if (indices == NULL)
|
||||
{
|
||||
ERR(" failed to map index buffer.");
|
||||
return GL_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int i = 0; i < count; i++)
|
||||
{
|
||||
|
||||
@@ -65,6 +65,7 @@ std::bitset<MAX_VERTEX_ATTRIBS> VertexDataManager::getActiveAttribs() const
|
||||
GLenum VertexDataManager::preRenderValidate(GLint start, GLsizei count,
|
||||
TranslatedAttribute *translated)
|
||||
{
|
||||
GLenum error = GL_NO_ERROR;
|
||||
const AttributeState *attribs = mContext->getVertexAttribBlock();
|
||||
const std::bitset<MAX_VERTEX_ATTRIBS> activeAttribs = getActiveAttribs();
|
||||
|
||||
@@ -126,6 +127,11 @@ GLenum VertexDataManager::preRenderValidate(GLint start, GLsizei count,
|
||||
size_t elementSize = typeSize(attribs[i].mType) * attribs[i].mSize;
|
||||
|
||||
void *output = mStreamBuffer->map(spaceRequired(attribs[i], count), &translated[i].offset);
|
||||
if (output == NULL)
|
||||
{
|
||||
ERR(" failed to map vertex buffer.");
|
||||
return GL_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
const void *input;
|
||||
if (attribs[i].mBoundBuffer.get())
|
||||
@@ -174,10 +180,10 @@ GLenum VertexDataManager::preRenderValidate(GLint start, GLsizei count,
|
||||
|
||||
if (usesCurrentValues)
|
||||
{
|
||||
processNonArrayAttributes(attribs, activeAttribs, translated, count);
|
||||
error = processNonArrayAttributes(attribs, activeAttribs, translated, count);
|
||||
}
|
||||
|
||||
return GL_NO_ERROR;
|
||||
return error;
|
||||
}
|
||||
|
||||
std::size_t VertexDataManager::typeSize(GLenum type) const
|
||||
@@ -223,7 +229,7 @@ std::size_t VertexDataManager::spaceRequired(const AttributeState &attrib, std::
|
||||
return roundUp(size, 4 * sizeof(GLfloat));
|
||||
}
|
||||
|
||||
void VertexDataManager::processNonArrayAttributes(const AttributeState *attribs, const std::bitset<MAX_VERTEX_ATTRIBS> &activeAttribs, TranslatedAttribute *translated, std::size_t count)
|
||||
GLenum VertexDataManager::processNonArrayAttributes(const AttributeState *attribs, const std::bitset<MAX_VERTEX_ATTRIBS> &activeAttribs, TranslatedAttribute *translated, std::size_t count)
|
||||
{
|
||||
if (mDirtyCurrentValues)
|
||||
{
|
||||
@@ -232,6 +238,11 @@ void VertexDataManager::processNonArrayAttributes(const AttributeState *attribs,
|
||||
mCurrentValueBuffer->reserveSpace(totalSize);
|
||||
|
||||
float* currentValues = static_cast<float*>(mCurrentValueBuffer->map(totalSize, &mCurrentValueOffset));
|
||||
if (currentValues == NULL)
|
||||
{
|
||||
ERR(" failed to map vertex buffer.");
|
||||
return GL_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
for (int i = 0; i < MAX_VERTEX_ATTRIBS; i++)
|
||||
{
|
||||
@@ -260,6 +271,8 @@ void VertexDataManager::processNonArrayAttributes(const AttributeState *attribs,
|
||||
translated[i].offset = mCurrentValueOffset + 4 * sizeof(float) * i;
|
||||
}
|
||||
}
|
||||
|
||||
return GL_NO_ERROR;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -43,7 +43,7 @@ class VertexDataManager
|
||||
private:
|
||||
std::bitset<MAX_VERTEX_ATTRIBS> getActiveAttribs() const;
|
||||
|
||||
void processNonArrayAttributes(const AttributeState *attribs, const std::bitset<MAX_VERTEX_ATTRIBS> &activeAttribs, TranslatedAttribute *translated, std::size_t count);
|
||||
GLenum processNonArrayAttributes(const AttributeState *attribs, const std::bitset<MAX_VERTEX_ATTRIBS> &activeAttribs, TranslatedAttribute *translated, std::size_t count);
|
||||
|
||||
std::size_t typeSize(GLenum type) const;
|
||||
std::size_t interpretGlStride(const AttributeState &attrib) const;
|
||||
|
||||
@@ -516,7 +516,12 @@ void *Dx9BackEnd::Dx9VertexBuffer::map()
|
||||
{
|
||||
void *mapPtr;
|
||||
|
||||
mVertexBuffer->Lock(0, 0, &mapPtr, 0);
|
||||
HRESULT hr = mVertexBuffer->Lock(0, 0, &mapPtr, 0);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERR(" Lock failed with error 0x%08x", hr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mapPtr;
|
||||
}
|
||||
@@ -537,7 +542,12 @@ void *Dx9BackEnd::Dx9VertexBuffer::streamingMap(std::size_t offset, std::size_t
|
||||
{
|
||||
void *mapPtr;
|
||||
|
||||
mVertexBuffer->Lock(offset, size, &mapPtr, D3DLOCK_NOOVERWRITE);
|
||||
HRESULT hr = mVertexBuffer->Lock(offset, size, &mapPtr, D3DLOCK_NOOVERWRITE);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERR(" Lock failed with error 0x%08x", hr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mapPtr;
|
||||
}
|
||||
@@ -558,7 +568,12 @@ void *Dx9BackEnd::Dx9VertexBufferZeroStrideWorkaround::streamingMap(std::size_t
|
||||
{
|
||||
void *mapPtr;
|
||||
|
||||
getBuffer()->Lock(offset, size, &mapPtr, 0);
|
||||
HRESULT hr = getBuffer()->Lock(offset, size, &mapPtr, 0);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERR(" Lock failed with error 0x%08x", hr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mapPtr;
|
||||
}
|
||||
@@ -592,7 +607,12 @@ void *Dx9BackEnd::Dx9IndexBuffer::map()
|
||||
{
|
||||
void *mapPtr;
|
||||
|
||||
mIndexBuffer->Lock(0, 0, &mapPtr, 0);
|
||||
HRESULT hr = mIndexBuffer->Lock(0, 0, &mapPtr, 0);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERR(" Lock failed with error 0x%08x", hr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mapPtr;
|
||||
}
|
||||
@@ -613,7 +633,12 @@ void *Dx9BackEnd::Dx9IndexBuffer::streamingMap(std::size_t offset, std::size_t s
|
||||
{
|
||||
void *mapPtr;
|
||||
|
||||
mIndexBuffer->Lock(offset, size, &mapPtr, D3DLOCK_NOOVERWRITE);
|
||||
HRESULT hr = mIndexBuffer->Lock(offset, size, &mapPtr, D3DLOCK_NOOVERWRITE);
|
||||
if (FAILED(hr))
|
||||
{
|
||||
ERR(" Lock failed with error 0x%08x", hr);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return mapPtr;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user