[Mesa-dev] [PATCH v2 07/11] gallium: add a way to store query result into buffer
Ilia Mirkin
imirkin at alum.mit.edu
Sun Jan 31 12:32:00 PST 2016
Signed-off-by: Ilia Mirkin <imirkin at alum.mit.edu>
---
src/gallium/docs/source/context.rst | 5 +++++
src/gallium/include/pipe/p_context.h | 22 ++++++++++++++++++++++
src/gallium/include/pipe/p_defines.h | 10 ++++++++++
3 files changed, 37 insertions(+)
diff --git a/src/gallium/docs/source/context.rst b/src/gallium/docs/source/context.rst
index 4c03e00..904e1ff 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 f69a75b..6c95b7b 100644
--- a/src/gallium/include/pipe/p_context.h
+++ b/src/gallium/include/pipe/p_context.h
@@ -150,6 +150,28 @@ struct pipe_context {
struct pipe_query *q,
boolean wait,
union pipe_query_result *result);
+
+ /**
+ * Get results of a query, storing into resource. Note that this may not
+ * be used with batch queries.
+ *
+ * \param wait if true, this query will block until the result is ready
+ * \param result_type the type of the value being stored:
+ * \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,
+ enum pipe_query_value_type 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 335f4e6..6cdb099 100644
--- a/src/gallium/include/pipe/p_defines.h
+++ b/src/gallium/include/pipe/p_defines.h
@@ -353,6 +353,7 @@ enum pipe_flush_flags
*/
#define PIPE_BARRIER_MAPPED_BUFFER (1 << 0)
#define PIPE_BARRIER_SHADER_BUFFER (1 << 1)
+#define PIPE_BARRIER_QUERY_BUFFER (1 << 2)
/**
* Resource binding flags -- state tracker must specify in advance all
@@ -376,6 +377,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
@@ -838,6 +840,14 @@ union pipe_query_result
union pipe_numeric_type_union batch[1];
};
+enum pipe_query_value_type
+{
+ QUERY_I32,
+ QUERY_U32,
+ QUERY_I64,
+ QUERY_U64,
+};
+
union pipe_color_union
{
float f[4];
--
2.4.10
More information about the mesa-dev
mailing list