mesa: optimize draw time validation of primitive types, shaders, and states to almost nothing
General idea (but there is more than this):
- Most of draw validation is moved from draw calls into state calls.
- In
CreateContext
, the context computes thegl_context::MaxValidPrimMask
constant containing the bitmask of primitive types that are valid for the context's GL version and extensions. - During state changes, the context updates
gl_context::ValidPrimMask
, which is a reduced version ofMaxValidPrimMask
based on current states. - If a primitive type is in
MaxValidPrimMask
but not inValidPrimMask
, draw calls reportGL_INVALID_OPERATION
or other errors instead ofGL_INVALID_ENUM
. This is the trick. - Some of draw validation is micro-optimized for lower overhead.
- A lot of functions are moved into draw.c to allow the compiler to inline them (e.g. most of draw_validate.c).
piglit/drawoverhead
improvement with back-to-back glDrawElements:
- Before:
1, DrawElements ( 1 VBO| 0 UBO| 0 ) w/ no state change, 26854
- After :
1, DrawElements ( 1 VBO| 0 UBO| 0 ) w/ no state change, 47217
piglit/drawoverhead
with mesa_no_error=true
showing that the current "error" case is faster that the previous "no_error" case and both "error" and "no_error" seem to be equally fast:
- Before:
1, DrawElements ( 1 VBO| 0 UBO| 0 ) w/ no state change, 42902
- After :
1, DrawElements ( 1 VBO| 0 UBO| 0 ) w/ no state change, 47300