broadcom/vc5: Use u_transfer_helper for MSAA mappings.
[mesa.git] / src / gallium / drivers / ddebug / dd_pipe.h
index deae1f5bc3d1ac4adefaed1d12943935f5d7ed8a..07c4d55017f7316aed9424ffcd0e8844255f09d2 100644 (file)
 #include "pipe/p_screen.h"
 #include "dd_util.h"
 #include "os/os_thread.h"
+#include "util/list.h"
+#include "util/u_log.h"
+#include "util/u_queue.h"
 
-enum dd_mode {
-   DD_DETECT_HANGS,
-   DD_DETECT_HANGS_PIPELINED,
+struct dd_context;
+
+enum dd_dump_mode {
+   DD_DUMP_ONLY_HANGS,
    DD_DUMP_ALL_CALLS,
    DD_DUMP_APITRACE_CALL,
 };
@@ -46,8 +50,9 @@ struct dd_screen
    struct pipe_screen base;
    struct pipe_screen *screen;
    unsigned timeout_ms;
-   enum dd_mode mode;
-   bool no_flush;
+   enum dd_dump_mode dump_mode;
+   bool flush_always;
+   bool transfers;
    bool verbose;
    unsigned skip_count;
    unsigned apitrace_dump_call;
@@ -66,6 +71,12 @@ enum call_type
    CALL_CLEAR_RENDER_TARGET,
    CALL_CLEAR_DEPTH_STENCIL,
    CALL_GENERATE_MIPMAP,
+   CALL_GET_QUERY_RESULT_RESOURCE,
+   CALL_TRANSFER_MAP,
+   CALL_TRANSFER_FLUSH_REGION,
+   CALL_TRANSFER_UNMAP,
+   CALL_BUFFER_SUBDATA,
+   CALL_TEXTURE_SUBDATA,
 };
 
 struct call_resource_copy_region
@@ -104,12 +115,62 @@ struct call_generate_mipmap {
    unsigned last_layer;
 };
 
+struct call_draw_info {
+   struct pipe_draw_info draw;
+   struct pipe_draw_indirect_info indirect;
+};
+
+struct call_get_query_result_resource {
+   struct pipe_query *query;
+   enum pipe_query_type query_type;
+   boolean wait;
+   enum pipe_query_value_type result_type;
+   int index;
+   struct pipe_resource *resource;
+   unsigned offset;
+};
+
+struct call_transfer_map {
+   struct pipe_transfer *transfer_ptr;
+   struct pipe_transfer transfer;
+   void *ptr;
+};
+
+struct call_transfer_flush_region {
+   struct pipe_transfer *transfer_ptr;
+   struct pipe_transfer transfer;
+   struct pipe_box box;
+};
+
+struct call_transfer_unmap {
+   struct pipe_transfer *transfer_ptr;
+   struct pipe_transfer transfer;
+};
+
+struct call_buffer_subdata {
+   struct pipe_resource *resource;
+   unsigned usage;
+   unsigned offset;
+   unsigned size;
+   const void *data;
+};
+
+struct call_texture_subdata {
+   struct pipe_resource *resource;
+   unsigned level;
+   unsigned usage;
+   struct pipe_box box;
+   const void *data;
+   unsigned stride;
+   unsigned layer_stride;
+};
+
 struct dd_call
 {
    enum call_type type;
 
    union {
-      struct pipe_draw_info draw_vbo;
+      struct call_draw_info draw_vbo;
       struct pipe_grid_info launch_grid;
       struct call_resource_copy_region resource_copy_region;
       struct pipe_blit_info blit;
@@ -117,6 +178,12 @@ struct dd_call
       struct call_clear clear;
       struct call_clear_buffer clear_buffer;
       struct call_generate_mipmap generate_mipmap;
+      struct call_get_query_result_resource get_query_result_resource;
+      struct call_transfer_map transfer_map;
+      struct call_transfer_flush_region transfer_flush_region;
+      struct call_transfer_unmap transfer_unmap;
+      struct call_buffer_subdata buffer_subdata;
+      struct call_texture_subdata texture_subdata;
    } info;
 };
 
@@ -151,7 +218,6 @@ struct dd_draw_state
       unsigned mode;
    } render_cond;
 
-   struct pipe_index_buffer index_buffer;
    struct pipe_vertex_buffer vertex_buffers[PIPE_MAX_ATTRIBS];
 
    unsigned num_so_targets;
@@ -201,14 +267,22 @@ struct dd_draw_state_copy
 };
 
 struct dd_draw_record {
-   struct dd_draw_record *next;
+   struct list_head list;
+   struct dd_context *dctx;
 
-   int64_t timestamp;
-   uint32_t sequence_no;
+   int64_t time_before;
+   int64_t time_after;
+   unsigned draw_call;
+
+   struct pipe_fence_handle *prev_bottom_of_pipe;
+   struct pipe_fence_handle *top_of_pipe;
+   struct pipe_fence_handle *bottom_of_pipe;
 
    struct dd_call call;
    struct dd_draw_state_copy draw_state;
-   char *driver_state_log;
+
+   struct util_queue_fence driver_finished;
+   struct u_log_page *log_page;
 };
 
 struct dd_context
@@ -219,6 +293,8 @@ struct dd_context
    struct dd_draw_state draw_state;
    unsigned num_draw_calls;
 
+   struct u_log_context log;
+
    /* Pipelined hang detection.
     *
     * This is without unnecessary flushes and waits. There is a memory-based
@@ -233,17 +309,16 @@ struct dd_context
     *
     * An independent, separate thread loops over the list of records and checks
     * their fences. Records with signalled fences are freed. On fence timeout,
-    * the thread dumps the record of the oldest unsignalled fence.
+    * the thread dumps the records of in-flight draws.
     */
    thrd_t thread;
    mtx_t mutex;
-   int kill_thread;
-   struct pipe_resource *fence;
-   struct pipe_transfer *fence_transfer;
-   uint32_t *mapped_fence;
-   uint32_t sequence_no;
-   struct dd_draw_record *records;
-   int max_log_buffer_size;
+   cnd_t cond;
+   struct dd_draw_record *record_pending; /* currently inside the driver */
+   struct list_head records; /* oldest record first */
+   unsigned num_records;
+   bool kill_thread;
+   bool api_stalled;
 };
 
 
@@ -252,9 +327,14 @@ dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe);
 
 void
 dd_init_draw_functions(struct dd_context *dctx);
+
+void
+dd_thread_join(struct dd_context *dctx);
 int
-dd_thread_pipelined_hang_detect(void *input);
+dd_thread_main(void *input);
 
+FILE *
+dd_get_file_stream(struct dd_screen *dscreen, unsigned apitrace_call_number);
 
 static inline struct dd_context *
 dd_context(struct pipe_context *pipe)
@@ -268,6 +348,22 @@ dd_screen(struct pipe_screen *screen)
    return (struct dd_screen*)screen;
 }
 
+static inline struct dd_query *
+dd_query(struct pipe_query *query)
+{
+   return (struct dd_query *)query;
+}
+
+static inline struct pipe_query *
+dd_query_unwrap(struct pipe_query *query)
+{
+   if (query) {
+      return dd_query(query)->query;
+   } else {
+      return NULL;
+   }
+}
+
 
 #define CTX_INIT(_member) \
    dctx->base._member = dctx->pipe->_member ? dd_context_##_member : NULL