Commit 7620c739 by Olli Etuaho Committed by Commit Bot

Prevent crash in robust access mode when buffer has no data

This fixes a crash appearing in robust access mode when a buffer has no data by stopping the draw call. A better fix would be to ensure that fetches from an empty buffer result in zero, but this fix requires a lot more effort. This is not necessarily warranted since the client is either way doing something incorrect in this case. BUG=angleproject:2840 TEST=angle_end2end_tests Change-Id: Ie4ef5b1ca7c0091d7d26f91678d6e4768cc0c650 Reviewed-on: https://chromium-review.googlesource.com/1238622Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Olli Etuaho <oetuaho@nvidia.com>
parent 85c4b43e
...@@ -348,6 +348,14 @@ gl::Error Buffer11::setData(const gl::Context *context, ...@@ -348,6 +348,14 @@ gl::Error Buffer11::setData(const gl::Context *context,
angle::Result Buffer11::getData(const gl::Context *context, const uint8_t **outData) angle::Result Buffer11::getData(const gl::Context *context, const uint8_t **outData)
{ {
if (mSize == 0)
{
// TODO(http://anglebug.com/2840): This ensures that we don't crash or assert in robust
// buffer access behavior mode if there are buffers without any data. However, technically
// it should still be possible to draw, with fetches from this buffer returning zero.
return angle::Result::Stop();
}
SystemMemoryStorage *systemMemoryStorage = nullptr; SystemMemoryStorage *systemMemoryStorage = nullptr;
ANGLE_TRY(getBufferStorage(context, BUFFER_USAGE_SYSTEM_MEMORY, &systemMemoryStorage)); ANGLE_TRY(getBufferStorage(context, BUFFER_USAGE_SYSTEM_MEMORY, &systemMemoryStorage));
......
...@@ -302,6 +302,25 @@ TEST_P(RobustBufferAccessBehaviorTest, VeryLargeVertexCountWithDynamicVertexData ...@@ -302,6 +302,25 @@ TEST_P(RobustBufferAccessBehaviorTest, VeryLargeVertexCountWithDynamicVertexData
// This may or may not generate an error, but it should not crash. // This may or may not generate an error, but it should not crash.
} }
// Test that robust access works even if there's no data uploaded to the vertex buffer at all.
TEST_P(RobustBufferAccessBehaviorTest, NoBufferData)
{
ANGLE_SKIP_TEST_IF(!initExtension());
ANGLE_GL_PROGRAM(program, essl1_shaders::vs::Simple(), essl1_shaders::fs::Red());
glUseProgram(program);
glEnableVertexAttribArray(0);
GLBuffer buf;
glBindBuffer(GL_ARRAY_BUFFER, buf);
glVertexAttribPointer(0, 1, GL_FLOAT, false, 0, nullptr);
ASSERT_GL_NO_ERROR();
std::array<GLubyte, 1u> indices = {0};
glDrawElements(GL_POINTS, indices.size(), GL_UNSIGNED_BYTE, indices.data());
ASSERT_GL_NO_ERROR();
}
ANGLE_INSTANTIATE_TEST(RobustBufferAccessBehaviorTest, ANGLE_INSTANTIATE_TEST(RobustBufferAccessBehaviorTest,
ES2_D3D9(), ES2_D3D9(),
ES2_D3D11_FL9_3(), ES2_D3D11_FL9_3(),
......
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