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.
CreateContext, the context computes the
gl_context::MaxValidPrimMaskconstant 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 of
MaxValidPrimMaskbased on current states.
- If a primitive type is in
MaxValidPrimMaskbut not in
ValidPrimMask, draw calls report
GL_INVALID_OPERATIONor other errors instead of
GL_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:
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
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:
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