gallium: make get_query_result return union* and not void*
authorMarek Olšák <maraeo@gmail.com>
Tue, 27 Mar 2012 19:51:50 +0000 (21:51 +0200)
committerMarek Olšák <maraeo@gmail.com>
Fri, 30 Mar 2012 15:12:51 +0000 (17:12 +0200)
This replaces the cryptic void* parameter with a union.
(based on union r600_query_result)

Users of this can still pass uint64* in it, but that cannot work for every
query type, obviously. Most importantly, the code now documents what should
be expected from get_query_result.

This also adds pipe_query_data_pipeline_statistics as per the D3D11 docs.

v2: fix indentation, add comments and use the doxygen style

Reviewed-by: Brian Paul <brianp@vmware.com>
src/gallium/include/pipe/p_context.h
src/gallium/include/pipe/p_defines.h

index aaeeb81851bec50ff526c7c7a14be6340f44ad43..8b4a1588b86c11e1492a342a676c6e957388520a 100644 (file)
@@ -64,6 +64,7 @@ struct pipe_video_buffer;
 struct pipe_video_decoder;
 struct pipe_viewport_state;
 union pipe_color_union;
+union pipe_query_result;
 
 /**
  * Gallium rendering context.  Basically:
@@ -117,7 +118,7 @@ struct pipe_context {
    boolean (*get_query_result)(struct pipe_context *pipe,
                                struct pipe_query *q,
                                boolean wait,
-                               void *result);
+                               union pipe_query_result *result);
    /*@}*/
 
    /**
index 889fc9961f4388b3f9c9015a685af798301d3038..e49d1922ea691f2ac504dce3730d361adcfae845 100644 (file)
@@ -523,17 +523,70 @@ enum pipe_shader_cap
 /**
  * Composite query types
  */
+
+/**
+ * Query result for PIPE_QUERY_SO_STATISTICS.
+ */
 struct pipe_query_data_so_statistics
 {
    uint64_t num_primitives_written;
    uint64_t primitives_storage_needed;
 };
+
+/**
+ * Query result for PIPE_QUERY_TIMESTAMP_DISJOINT.
+ */
 struct pipe_query_data_timestamp_disjoint
 {
    uint64_t frequency;
    boolean  disjoint;
 };
 
+/**
+ * Query result for PIPE_QUERY_PIPELINE_STATISTICS.
+ */
+struct pipe_query_data_pipeline_statistics
+{
+   uint64_t ia_vertices;    /**< Num vertices read by the vertex fetcher. */
+   uint64_t ia_primitives;  /**< Num primitives read by the vertex fetcher. */
+   uint64_t vs_invocations; /**< Num vertex shader invocations. */
+   uint64_t gs_invocations; /**< Num geometry shader invocations. */
+   uint64_t gs_primitives;  /**< Num primitives output by a geometry shader. */
+   uint64_t c_invocations;  /**< Num primitives sent to the rasterizer. */
+   uint64_t c_primitives;   /**< Num primitives that were rendered. */
+   uint64_t ps_invocations; /**< Num pixel shader invocations. */
+   uint64_t hs_invocations; /**< Num hull shader invocations. */
+   uint64_t ds_invocations; /**< Num domain shader invocations. */
+   uint64_t cs_invocations; /**< Num compute shader invocations. */
+};
+
+/**
+ * Query result (returned by pipe_context::get_query_result).
+ */
+union pipe_query_result
+{
+   /* PIPE_QUERY_OCCLUSION_PREDICATE */
+   /* PIPE_QUERY_SO_OVERFLOW_PREDICATE */
+   /* PIPE_QUERY_GPU_FINISHED */
+   boolean b;
+
+   /* PIPE_QUERY_OCCLUSION_COUNTER */
+   /* PIPE_QUERY_TIMESTAMP */
+   /* PIPE_QUERY_TIME_ELAPSED */
+   /* PIPE_QUERY_PRIMITIVES_GENERATED */
+   /* PIPE_QUERY_PRIMITIVES_EMITTED */
+   uint64_t u64;
+
+   /* PIPE_QUERY_SO_STATISTICS */
+   struct pipe_query_data_so_statistics so_statistics;
+
+   /* PIPE_QUERY_TIMESTAMP_DISJOINT */
+   struct pipe_query_data_timestamp_disjoint timestamp_disjoint;
+
+   /* PIPE_QUERY_PIPELINE_STATISTICS */
+   struct pipe_query_data_pipeline_statistics pipeline_statistics;
+};
+
 union pipe_color_union
 {
    float f[4];