Implement robust buffer initialization.
This uses the most simple implementation: on BufferData calls without
explicit data arguments, it will initialize the buffer data store to
zero. This could be improved by deferring the init until needed, and
skipping it if the buffer store is cleared through other API calls,
but it is not a regression from current Chromium implementation.
BUG=angleproject:1635
Change-Id: I2fb1594851c5050dc2578736c3f74761555da267
Reviewed-on: https://chromium-review.googlesource.com/450921
Reviewed-by: Jamie Madill <jmadill@chromium.org>
Reviewed-by: Geoff Lang <geofflang@chromium.org>
Commit-Queue: Jamie Madill <jmadill@chromium.org>
diff --git a/src/libANGLE/Context.cpp b/src/libANGLE/Context.cpp
index 507618d..f5680b8 100644
--- a/src/libANGLE/Context.cpp
+++ b/src/libANGLE/Context.cpp
@@ -272,7 +272,8 @@
mRobustAccess(GetRobustAccess(attribs)),
mCurrentSurface(nullptr),
mSurfacelessFramebuffer(nullptr),
- mWebGLContext(GetWebGLContext(attribs))
+ mWebGLContext(GetWebGLContext(attribs)),
+ mScratchBuffer(1000u)
{
if (mRobustAccess)
{
@@ -3941,4 +3942,13 @@
SetFramebufferParameteri(framebuffer, pname, param);
}
+Error Context::getScratchBuffer(size_t requestedSize, angle::MemoryBuffer **scratchBufferOut) const
+{
+ if (!mScratchBuffer.get(requestedSize, scratchBufferOut))
+ {
+ return gl::OutOfMemory() << "Failed to allocate internal buffer.";
+ }
+ return gl::NoError();
+}
+
} // namespace gl