gallium: add async debug message forwarding helper
[mesa.git] / src / gallium / auxiliary / util / u_vbuf.h
index 1c0562903f298ab3bba9821b7412ff7dfbb832d8..d07045245617e15d25d251cd4cd39c265124e9ac 100644 (file)
  *
  **************************************************************************/
 
-#ifndef U_VBUF_MGR_H
-#define U_VBUF_MGR_H
+#ifndef U_VBUF_H
+#define U_VBUF_H
 
-/* This module builds upon u_upload_mgr and translate_cache and takes care of
- * user buffer uploads and vertex format fallbacks. It's designed
- * for the drivers which don't always use the Draw module. (e.g. for HWTCL)
+/* This module takes care of user buffer uploads and vertex format fallbacks.
+ * It's designed for the drivers which don't want to use the Draw module.
+ * There is a more detailed description at the beginning of the .c file.
  */
 
 #include "pipe/p_context.h"
 #include "pipe/p_state.h"
+#include "pipe/p_format.h"
+
+struct cso_context;
+struct u_vbuf;
+
+#define U_VBUF_FLAG_NO_USER_VBOS (1 << 0)
 
 /* Hardware vertex fetcher limitations can be described by this structure. */
 struct u_vbuf_caps {
-   /* Vertex format CAPs. */
-   /* TRUE if hardware supports it. */
-   unsigned format_fixed32:1;    /* PIPE_FORMAT_*32*_FIXED */
-   unsigned format_float16:1;    /* PIPE_FORMAT_*16*_FLOAT */
-   unsigned format_float64:1;    /* PIPE_FORMAT_*64*_FLOAT */
-   unsigned format_norm32:1;     /* PIPE_FORMAT_*32*NORM */
-   unsigned format_scaled32:1;   /* PIPE_FORMAT_*32*SCALED */
+   enum pipe_format format_translation[PIPE_FORMAT_COUNT];
 
-   /* Whether vertex fetches don't have to be dword-aligned. */
+   /* Whether vertex fetches don't have to be 4-byte-aligned. */
    /* TRUE if hardware supports it. */
-   unsigned fetch_dword_unaligned:1;
+   unsigned buffer_offset_unaligned:1;
+   unsigned buffer_stride_unaligned:1;
+   unsigned velem_src_offset_unaligned:1;
 
    /* Whether the driver supports user vertex buffers. */
    unsigned user_vertex_buffers:1;
 };
 
-/* The manager.
- * This structure should also be used to access vertex buffers
- * from a driver. */
-struct u_vbuf {
-   /* This is what was set in set_vertex_buffers.
-    * May contain user buffers. */
-   struct pipe_vertex_buffer vertex_buffer[PIPE_MAX_ATTRIBS];
-   unsigned nr_vertex_buffers;
-
-   /* This uploader can optionally be used by the driver.
-    *
-    * Allowed functions:
-    * - u_upload_alloc
-    * - u_upload_data
-    * - u_upload_buffer
-    * - u_upload_flush */
-   struct u_upload_mgr *uploader;
-
-   /* Vertex elements state as created by u_vbuf.
-    * This is used when saving the state into u_blitter, there's no other
-    * usage. */
-   void *vertex_elements;
-};
-
 
-void u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps);
+boolean u_vbuf_get_caps(struct pipe_screen *screen, struct u_vbuf_caps *caps,
+                        unsigned flags);
 
 struct u_vbuf *
 u_vbuf_create(struct pipe_context *pipe,
-              struct u_vbuf_caps *caps,
-              unsigned upload_buffer_size,
-              unsigned upload_buffer_alignment,
-              unsigned upload_buffer_bind);
+              struct u_vbuf_caps *caps, unsigned aux_vertex_buffer_index);
 
 void u_vbuf_destroy(struct u_vbuf *mgr);
 
-unsigned u_vbuf_draw_max_vertex_count(struct u_vbuf *mgr);
+/* State and draw functions. */
+void u_vbuf_set_vertex_elements(struct u_vbuf *mgr, unsigned count,
+                                const struct pipe_vertex_element *states);
+void u_vbuf_set_vertex_buffers(struct u_vbuf *mgr,
+                               unsigned start_slot, unsigned count,
+                               const struct pipe_vertex_buffer *bufs);
+void u_vbuf_draw_vbo(struct u_vbuf *mgr, const struct pipe_draw_info *info);
+
+/* Save/restore functionality. */
+void u_vbuf_save_vertex_elements(struct u_vbuf *mgr);
+void u_vbuf_restore_vertex_elements(struct u_vbuf *mgr);
+void u_vbuf_save_aux_vertex_buffer_slot(struct u_vbuf *mgr);
+void u_vbuf_restore_aux_vertex_buffer_slot(struct u_vbuf *mgr);
 
 #endif