Commit 3ef06a9f by Jiawei Shao Committed by Commit Bot

Skip hasMappedBuffer check in draw validations in WebGL contexts

MapBufferRange, FlushMappedBufferRange, and UnmapBuffer entry points are removed from the WebGL 2.0 API[1], so we don't need to validate if a vertex array buffer or an index buffer is mapped or not in draw validations (ValidateDrawBase and ValidateDrawElementsCommon) in a WebGL context. According to profiling data, hasMappedBuffer weights over 1% (1.12%) CPU times in WebGL Acquarium benchmark (10K fishes, Intel HD630). With this patch, this hot spot has disappeared and no new hot spots are introduced. This optimization can also slightly improve FPS on WebGL benchmarks, or keep the same at least. [1] https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.14 BUG=angleproject:1671 Change-Id: I96e770b19b691e81774cc8e0c1b66b65dcc3cc83 Reviewed-on: https://chromium-review.googlesource.com/753281 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCorentin Wallez <cwallez@chromium.org>
parent 0e883134
...@@ -2527,17 +2527,25 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count) ...@@ -2527,17 +2527,25 @@ bool ValidateDrawBase(ValidationContext *context, GLenum mode, GLsizei count)
const State &state = context->getGLState(); const State &state = context->getGLState();
// Check for mapped buffers const Extensions &extensions = context->getExtensions();
if (state.hasMappedBuffer(GL_ARRAY_BUFFER))
// WebGL buffers cannot be mapped/unmapped because the MapBufferRange, FlushMappedBufferRange,
// and UnmapBuffer entry points are removed from the WebGL 2.0 API.
// https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.14
if (!extensions.webglCompatibility)
{ {
context->handleError(InvalidOperation()); // Check for mapped buffers
return false; // TODO(jmadill): Optimize this check for non - WebGL contexts.
if (state.hasMappedBuffer(GL_ARRAY_BUFFER))
{
context->handleError(InvalidOperation());
return false;
}
} }
// Note: these separate values are not supported in WebGL, due to D3D's limitations. See // Note: these separate values are not supported in WebGL, due to D3D's limitations. See
// Section 6.10 of the WebGL 1.0 spec. // Section 6.10 of the WebGL 1.0 spec.
Framebuffer *framebuffer = state.getDrawFramebuffer(); Framebuffer *framebuffer = state.getDrawFramebuffer();
const Extensions &extensions = context->getExtensions();
if (context->getLimitations().noSeparateStencilRefsAndMasks || extensions.webglCompatibility) if (context->getLimitations().noSeparateStencilRefsAndMasks || extensions.webglCompatibility)
{ {
const FramebufferAttachment *dsAttachment = const FramebufferAttachment *dsAttachment =
...@@ -2801,11 +2809,18 @@ bool ValidateDrawElementsCommon(ValidationContext *context, ...@@ -2801,11 +2809,18 @@ bool ValidateDrawElementsCommon(ValidationContext *context,
return false; return false;
} }
// Check for mapped buffers // WebGL buffers cannot be mapped/unmapped because the MapBufferRange, FlushMappedBufferRange,
if (state.hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER)) // and UnmapBuffer entry points are removed from the WebGL 2.0 API.
// https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.14
if (!context->getExtensions().webglCompatibility)
{ {
context->handleError(InvalidOperation() << "Index buffer is mapped."); // Check for mapped buffers
return false; // TODO(jmadill): Optimize this check for non - WebGL contexts.
if (state.hasMappedBuffer(GL_ELEMENT_ARRAY_BUFFER))
{
context->handleError(InvalidOperation() << "Index buffer is mapped.");
return false;
}
} }
const gl::VertexArray *vao = state.getVertexArray(); const gl::VertexArray *vao = state.getVertexArray();
......
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