Mesa (master): mesa: don' t check mapped buffers in every draw call if drivers allow it

Marek Olšák mareko at kemper.freedesktop.org
Wed May 17 18:48:16 UTC 2017


Module: Mesa
Branch: master
Commit: 4f50c91c329025dc73002e19f7679e4826bb12fa
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=4f50c91c329025dc73002e19f7679e4826bb12fa

Author: Marek Olšák <marek.olsak at amd.com>
Date:   Mon May 15 16:34:06 2017 +0200

mesa: don't check mapped buffers in every draw call if drivers allow it

Before: DrawElements (16 VBOs) w/ no state change: 4.34 million/s
After:  DrawElements (16 VBOs) w/ no state change: 8.80 million/s

This inefficiency was uncovered by Timothy Arceri's no_error work.

Reviewed-by: Nicolai Hähnle <nicolai.haehnle at amd.com>

---

 src/mesa/main/api_validate.c | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)

diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c
index 850dedae7a..7aa8f9e837 100644
--- a/src/mesa/main/api_validate.c
+++ b/src/mesa/main/api_validate.c
@@ -243,7 +243,20 @@ check_valid_to_render(struct gl_context *ctx, const char *function)
       return false;
    }
 
-   if (!_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) {
+   /* Section 6.3.2 from the GL 4.5:
+    * "Any GL command which attempts to read from, write to, or change
+    *  the state of a buffer object may generate an INVALID_OPERATION error if
+    *  all or part of the buffer object is mapped ... However, only commands
+    *  which explicitly describe this error are required to do so. If an error
+    *  is not generated, such commands will have undefined results and may
+    *  result in GL interruption or termination."
+    *
+    * Only some buffer API functions require INVALID_OPERATION with mapped
+    * buffers. No other functions list such an error, thus it's not required
+    * to report INVALID_OPERATION for draw calls with mapped buffers.
+    */
+   if (!ctx->Const.AllowMappedBuffersDuringExecution &&
+       !_mesa_all_buffers_are_unmapped(ctx->Array.VAO)) {
       _mesa_error(ctx, GL_INVALID_OPERATION,
                   "%s(vertex buffers are mapped)", function);
       return false;




More information about the mesa-commit mailing list