// // Copyright 2002 The ANGLE Project Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. //
// Buffer.cpp: Implements the gl::Buffer class, representing storage of vertex and/or // index data. Implements GL buffer objects and related functionality. // [OpenGL ES 2.0.24] section 2.9 page 21.
if (mState.isMapped())
{ // Per the OpenGL ES 3.0 spec, buffers are implicity unmapped when a call to // BufferData happens on a mapped buffer: // // If any portion of the buffer object is mapped in the current context or any context // current to another thread, it is as though UnmapBuffer (see section 2.10.3) is // executed in each such context prior to deleting the existing data store. //
GLboolean dontCare = GL_FALSE;
ANGLE_TRY(unmap(context, &dontCare));
}
// If we are using robust resource init, make sure the buffer starts cleared. // Note: the Context is checked for nullptr because of some testing code. // TODO(jmadill): Investigate lazier clearing. if (context && context->isRobustResourceInitEnabled() && !data && size > 0)
{
angle::MemoryBuffer *scratchBuffer = nullptr;
ANGLE_CHECK_GL_ALLOC(
context, context->getZeroFilledBuffer(static_cast<size_t>(size), &scratchBuffer));
dataForImpl = scratchBuffer->data();
}
if (mImpl->setDataWithUsageFlags(context, target, nullptr, dataForImpl, size, usage, flags) ==
angle::Result::Stop)
{ // If setData fails, the buffer contents are undefined. Set a zero size to indicate that.
mIndexRangeCache.clear();
mState.mSize = 0;
// Notify when storage changes.
onStateChange(angle::SubjectMessage::SubjectChanged);
// Notify when storage changes. if (wholeBuffer)
{
onContentsChange();
} else
{
onStateChange(angle::SubjectMessage::SubjectChanged);
}
return angle::Result::Continue;
}
angle::Result Buffer::bufferExternalDataImpl(Context *context,
BufferBinding target,
GLeglClientBufferEXT clientBuffer,
GLsizeiptr size,
GLbitfield flags)
{ if (mState.isMapped())
{ // Per the OpenGL ES 3.0 spec, buffers are implicitly unmapped when a call to // BufferData happens on a mapped buffer: // // If any portion of the buffer object is mapped in the current context or any context // current to another thread, it is as though UnmapBuffer (see section 2.10.3) is // executed in each such context prior to deleting the existing data store. //
GLboolean dontCare = GL_FALSE;
ANGLE_TRY(unmap(context, &dontCare));
}
if (mImpl->setDataWithUsageFlags(context, target, clientBuffer, nullptr, size,
BufferUsage::InvalidEnum, flags) == angle::Result::Stop)
{ // If setData fails, the buffer contents are undefined. Set a zero size to indicate that.
mIndexRangeCache.clear();
mState.mSize = 0;
// Notify when storage changes.
onStateChange(angle::SubjectMessage::SubjectChanged);
// The OES_mapbuffer extension states that GL_WRITE_ONLY_OES is the only valid // value for GL_BUFFER_ACCESS_OES because it was written against ES2. Since there is // no update for ES3 and the GL_READ_ONLY and GL_READ_WRITE enums don't exist for ES, // we cannot properly set GL_BUFFER_ACCESS_OES when glMapBufferRange is called.
if ((access & GL_MAP_WRITE_BIT) > 0)
{
mIndexRangeCache.invalidateRange(static_cast<unsignedint>(offset), static_cast<unsignedint>(length));
}
// Notify when state changes.
onStateChange(angle::SubjectMessage::SubjectMapped);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.