Commit 79f7104a by Geoff Lang Committed by Commit Bot

Validate that transform feedback buffers are not mapped.

Mapping a buffer that is bound for active transform feedback or starting transform feedback on a mapped buffer is undefined behaviour under section 2.10.3.2 of the ES 3.0 spec "Effects of Mapping Buffers on Other GL Commands". The spec suggests that an error is generated in this case. TEST=ES3MapBufferRangeTest.TransformFeedback BUG=754000 Change-Id: I613defd07cc1a4348682d992cda61cc898936720 Reviewed-on: https://chromium-review.googlesource.com/614483Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org> Commit-Queue: Geoff Lang <geofflang@chromium.org>
parent 78ed6cd9
......@@ -3936,7 +3936,8 @@ bool ValidateMapBufferRangeBase(Context *context,
<< "The explicit flushing bit may only be set if the buffer is mapped for writing.");
return false;
}
return true;
return ValidateMapBufferBase(context, target);
}
bool ValidateFlushMappedBufferRangeBase(Context *context,
......
......@@ -2777,7 +2777,7 @@ bool ValidateMapBufferOES(Context *context, GLenum target, GLenum access)
return false;
}
return true;
return ValidateMapBufferBase(context, target);
}
bool ValidateUnmapBufferOES(Context *context, GLenum target)
......@@ -2806,6 +2806,30 @@ bool ValidateMapBufferRangeEXT(Context *context,
return ValidateMapBufferRangeBase(context, target, offset, length, access);
}
bool ValidateMapBufferBase(Context *context, GLenum target)
{
Buffer *buffer = context->getGLState().getTargetBuffer(target);
ASSERT(buffer != nullptr);
// Check if this buffer is currently being used as a transform feedback output buffer
TransformFeedback *transformFeedback = context->getGLState().getCurrentTransformFeedback();
if (transformFeedback != nullptr && transformFeedback->isActive())
{
for (size_t i = 0; i < transformFeedback->getIndexedBufferCount(); i++)
{
const auto &transformFeedbackBuffer = transformFeedback->getIndexedBuffer(i);
if (transformFeedbackBuffer.get() == buffer)
{
context->handleError(InvalidOperation()
<< "Buffer is currently bound for transform feedback.");
return false;
}
}
}
return true;
}
bool ValidateFlushMappedBufferRangeEXT(Context *context,
GLenum target,
GLintptr offset,
......
......@@ -208,6 +208,7 @@ bool ValidateMapBufferRangeEXT(Context *context,
GLintptr offset,
GLsizeiptr length,
GLbitfield access);
bool ValidateMapBufferBase(Context *context, GLenum target);
bool ValidateFlushMappedBufferRangeEXT(Context *context,
GLenum target,
GLintptr offset,
......
......@@ -2089,6 +2089,17 @@ bool ValidateBeginTransformFeedback(Context *context, GLenum primitiveMode)
context->handleError(InvalidOperation() << "Transform feedback is already active.");
return false;
}
for (size_t i = 0; i < transformFeedback->getIndexedBufferCount(); i++)
{
const auto &buffer = transformFeedback->getIndexedBuffer(i);
if (buffer.get() && buffer->isMapped())
{
context->handleError(InvalidOperation() << "Transform feedback has a mapped buffer.");
return false;
}
}
return true;
}
......
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