configure: Cygwin requires _XOPEN_SOURCE >= 700 to prototype strndup()

Adjust definition of _XOPEN_SOURCE appropriately for use of strndup() added with
commit da3a47d6

Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
Add build_mesa.sh script
gallium: add pipe_screen::get_driver_query_group_info v2

Driver queries are organized as a single hierarchy where queries
are categorized into groups. Each goup has a list of queries and
a maximum number of queries that can be sampled.

This will be used by GL_AMD_performance monitor.

V2:
 - add doc to src/gallium/docs/source/screen.rst
 - s/pipe_context/pipe_screen in the commit msg
 - rewrite commit message

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
gallium: add new fields to pipe_driver_query_info v2

According to the spec of GL_AMD_performance_monitor, valid type values
returned are UNSIGNED_INT, UNSIGNED_INT64_AMD, PERCENTAGE_AMD, FLOAT.
This also introduces the new field group_id in order to categorize
queries into groups.

V2:
 - add pipe_driver_query_type enum

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
gallium: add new numeric types to pipe_query_result v2

This will be used by GL_AMD_performance_monitor.

V2:
 - add 'uint32_t u32'
 - rename 'float f32' to 'float f'
 - add some comments

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
gallium: replace pipe_driver_query_info::max_value by a union v2

This will be used to return different numeric types for
driver queries.

V2:
 - use float instead of double
 - reorder pipe_numeric_type_union to avoid bad initializers
 - rename ui to u64 and i to u32 according to
   gl_perf_monitor_counter_value
 - use uint32_t instead of int64_t according to
   gl_perf_monitor_counter_value

Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
gallium: make pipe_context::begin_query return a boolean

This can be used to check if a query is unable to start.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
st/mesa: implement GL_AMD_performance_monitor v5

This is based on the original patch of Christoph Bumiller.
(source: http://people.freedesktop.org/~chrisbmr/perfmon.diff)

Drivers must implement get_driver_query_group_info and
get_driver_query_info in order to enable this extension.

V2: (Samuel Pitoiset)
 - fix compilation
 - improve the original code
 - rewrite some parts of the original code

V3:
 - do not use pipe_driver_query_info::min_value which is always set to 0

V4:
 - only enable AMD_performance_monitor if the driver implements
 pipe_screen::get_driver_query_group_info and get_driver_query_info
 - make use of PIPE_DRIVER_QUERY_TYPE_*
 - use of GL_UNSIGNED_INT in st_GetPerfMonitorResult()

V5:
 - use st/mesa instead of mesa/st
 - add comments to find_query_type() and reinitialize_perf_monitor()
 - change copyrights
 - do not wait for results in st_IsPerfMonitorResultAvailable which is
 not supposed to block
 - add st_destroy_perfmon() in order to free memory allocated by groups
 and counters (this fixes a memleak)

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
gallium: add util_get_driver_query_group_info v2

This generic function will be used to get groups of queries.

V2:
 - add some comments as request by Brian Paul
 - put the function name on the next line

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
svga: implement pipe_screen::get_driver_query_group_info v4

This enables GL_AMD_performance_monitor for svga.

V2:
 - s/pipe_context/pipe_screen in the commit msg

V3:
 - use util_get_driver_query_group_info

V4:
 - add SVGA_QUERY_COUNT in svga_context.h

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
freedreno: implement pipe_screen::get_driver_query_group_info v4

This enables GL_AMD_performance_monitor for freedreno.

V2:
 - s/pipe_context/pipe_screen in the commit msg

V3:
 - use util_get_driver_query_group_info

V4:
 - add FD_QUERY_COUNT in freedreno_query.h

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
radeon: implement pipe_screen::get_driver_query_group_info v4

This enables GL_AMD_performance_monitor for radeon.

V2:
 - s/pipe_context/pipe_screen in the commit msg

V3:
 - use util_get_driver_query_group_info

V4:
 - add R600_QUERY_COUNT in r600_pipe_common.h

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
nvc0: implement pipe_screen::get_driver_query_group_info v3

This enables GL_AMD_performance_monitor for nvc0.

V2:
 - use util_get_driver_query_group_info

V3:
 - use of NVC0_QUERY_DRV_STAT_COUNT instead of a magic number

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
docs: mark GL_AMD_performance_monitor for the 10.3 release v2

GL_AMD_performance_monitor is supported by nvc0, svga, freedreno,
r600 and radeonsi.

V2:
 - add radeonsi

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
nvc0: expose driver queries with two groups

This adds a new group for MP performance counters and requires
to write our own implementation of get_driver_query_group_info.

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
nvc0: make begin_query return false when all MP counters are used v2

V2:
 - do not return immediately after nvc0_mp_pm_query_end() in
 order to set the current state of the given query

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
nvc0: init all default values of pipe_driver_query_info

Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>