Commit afa40f7d by Jamie Madill

Fix buffer bugs affecting transform feedback.

Running dEQP-GLES3.functional.transform_feedback would trigger a few assertion failures because of some regressions that crept into our code. Among the regressions is assuming we can't map a buffer that has no underlying storage object. This is valid since we sometimes allow setData without creating a native storage. Additionally we should free our existing data store on a new call to SetData, to prevent old but "new" data revisions from complicating our storage. BUG=angle:679 Change-Id: Icd96a8a55a2b957d29382d8b8bbd7e8a7ab0cf65 Reviewed-on: https://chromium-review.googlesource.com/204342Tested-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarGeoff Lang <geofflang@chromium.org>
parent 9c074a39
......@@ -166,10 +166,7 @@ BufferStorage11::BufferStorage11(Renderer11 *renderer)
BufferStorage11::~BufferStorage11()
{
for (auto it = mTypedBuffers.begin(); it != mTypedBuffers.end(); it++)
{
SafeDelete(it->second);
}
clear();
}
BufferStorage11 *BufferStorage11::makeBufferStorage11(BufferStorage *bufferStorage)
......@@ -296,6 +293,13 @@ void BufferStorage11::copyData(BufferStorage* sourceStorage, size_t size, size_t
void BufferStorage11::clear()
{
for (auto it = mTypedBuffers.begin(); it != mTypedBuffers.end(); it++)
{
SafeDelete(it->second);
}
mTypedBuffers.clear();
mSize = 0;
mResolvedDataRevision = 0;
}
......@@ -499,15 +503,17 @@ void *BufferStorage11::map(GLbitfield access)
ASSERT(!mMappedStorage);
TypedBufferStorage11 *latestStorage = getLatestStorage();
ASSERT(latestStorage);
if (latestStorage->getUsage() == BUFFER_USAGE_PIXEL_PACK ||
latestStorage->getUsage() == BUFFER_USAGE_STAGING)
if (latestStorage &&
(latestStorage->getUsage() == BUFFER_USAGE_PIXEL_PACK ||
latestStorage->getUsage() == BUFFER_USAGE_STAGING))
{
// Latest storage is mappable.
mMappedStorage = latestStorage;
}
else
{
// Fall back to using the staging buffer if the latest storage does
// not exist or is not CPU-accessible.
mMappedStorage = getStagingBuffer();
}
......@@ -517,6 +523,12 @@ void *BufferStorage11::map(GLbitfield access)
return NULL;
}
if ((access & GL_MAP_WRITE_BIT) > 0)
{
// Update the data revision immediately, since the data might be changed at any time
mMappedStorage->setDataRevision(mMappedStorage->getDataRevision() + 1);
}
return mMappedStorage->map(access);
}
......
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