[Mesa-dev] [PATCH 7/9] gallium: add a way to store query result into buffer
Nicolai Hähnle
nhaehnle at gmail.com
Mon Jan 11 10:53:24 PST 2016
On 10.01.2016 00:14, Ilia Mirkin wrote:
> Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
> ---
> src/gallium/docs/source/context.rst | 5 +++++
> src/gallium/include/pipe/p_context.h | 24 ++++++++++++++++++++++++
> src/gallium/include/pipe/p_defines.h | 2 ++
> 3 files changed, 31 insertions(+)
>
> diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
> index 9a32716..a97308a 100644
> --- a/src/gallium/docs/source/context.rst
> +++ b/src/gallium/docs/source/context.rst
> @@ -325,6 +325,11 @@ returned). Otherwise, if the ``wait`` parameter is FALSE, the call
> will not block and the return value will be TRUE if the query has
> completed or FALSE otherwise.
>
> +``get_query_result_resource`` is used to store the result of a query into
> +a resource without synchronizing with the CPU. This write will optionally
> +wait for the query to complete, and will optionally write whether the value
> +is available instead of the value itself.
> +
> The interface currently includes the following types of queries:
>
> ``PIPE_QUERY_OCCLUSION_COUNTER`` counts the number of fragments which
> diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
> index be7447d..4f21d37 100644
> --- a/src/gallium/include/pipe/p_context.h
> +++ b/src/gallium/include/pipe/p_context.h
> @@ -150,6 +150,30 @@ struct pipe_context {
> struct pipe_query *q,
> boolean wait,
> union pipe_query_result *result);
> +
> + /**
> + * Get results of a query, storing into resource.
> + * \param wait if true, this query will block until the result is ready
> + * \param result_type the type of the value being stored:
> + * 0 - i32
> + * 1 - u32
> + * 2 - i64
> + * 3 - u64
Magic numbers :(
Maybe use an enum? Or maybe the signed vs. unsigned distinction isn't
really needed and you can go with the pipe_index_buffer precedence of
using result_size instead (4 for i32, 8 for i64).
Cheers,
Nicolai
> + * \param index for queries that return multiple pieces of data, which
> + * item of that data to store (e.g. for
> + * PIPE_QUERY_PIPELINE_STATISTICS).
> + * When the index is -1, instead of the value of the query
> + * the driver should instead write a 1/0 to the appropriate
> + * location with 1 meaning that the query result is available.
> + */
> + void (*get_query_result_resource)(struct pipe_context *pipe,
> + struct pipe_query *q,
> + boolean wait,
> + unsigned result_type,
> + int index,
> + struct pipe_resource *resource,
> + unsigned offset);
> +
> /*@}*/
>
> /**
> diff --git a/src/gallium/include/pipe/p_defines.h b/src/gallium/include/pipe/p_defines.h
> index dd76fe5..012c098 100644
> --- a/src/gallium/include/pipe/p_defines.h
> +++ b/src/gallium/include/pipe/p_defines.h
> @@ -352,6 +352,7 @@ enum pipe_flush_flags
> * Flags for pipe_context::memory_barrier.
> */
> #define PIPE_BARRIER_MAPPED_BUFFER (1 << 0)
> +#define PIPE_BARRIER_QUERY_BUFFER (1 << 1)
>
> /**
> * Resource binding flags -- state tracker must specify in advance all
> @@ -375,6 +376,7 @@ enum pipe_flush_flags
> #define PIPE_BIND_SHADER_IMAGE (1 << 15) /* set_shader_images */
> #define PIPE_BIND_COMPUTE_RESOURCE (1 << 16) /* set_compute_resources */
> #define PIPE_BIND_COMMAND_ARGS_BUFFER (1 << 17) /* pipe_draw_info.indirect */
> +#define PIPE_BIND_QUERY_BUFFER (1 << 18) /* get_query_result_resource */
>
> /**
> * The first two flags above were previously part of the amorphous
>
More information about the mesa-dev
mailing list