gallium/u_threaded: increase batch size to increase performance
[mesa.git] / src / gallium / auxiliary / util / u_blitter.h
index 868f1da5c9c5394e5593e798c2f86021546b890b..c1f1ae4744394ee4f50840fe87460402e12c6374 100644 (file)
@@ -53,11 +53,20 @@ union blitter_attrib {
    } texcoord;
 };
 
+struct blitter_context;
+
+typedef void *(*blitter_get_vs_func)(struct blitter_context *blitter);
+
 struct blitter_context
 {
    /**
     * Draw a rectangle.
     *
+    * \param get_vs  Callback for obtaining the vertex shader for the draw call.
+    *                It might invoke the shader compiler. The driver is
+    *                responsible for setting the vertex shader, and the callback
+    *                allows the driver to query the vertex shader CSO if it
+    *                wants to use the default one.
     * \param x1      An X coordinate of the top-left corner.
     * \param y1      A Y coordinate of the top-left corner.
     * \param x2      An X coordinate of the bottom-right corner.
@@ -82,6 +91,7 @@ struct blitter_context
     */
    void (*draw_rectangle)(struct blitter_context *blitter,
                           void *vertex_elements_cso,
+                          blitter_get_vs_func get_vs,
                           int x1, int y1, int x2, int y2,
                           float depth, unsigned num_instances,
                           enum blitter_attrib_type type,
@@ -90,6 +100,8 @@ struct blitter_context
    /* Whether the blitter is running. */
    bool running;
 
+   bool use_index_buffer;
+
    /* Private members, really. */
    struct pipe_context *pipe; /**< pipe context */
 
@@ -103,6 +115,7 @@ struct blitter_context
    struct pipe_stencil_ref saved_stencil_ref;     /**< stencil ref */
    struct pipe_viewport_state saved_viewport;
    struct pipe_scissor_state saved_scissor;
+   bool skip_viewport_restore;
    bool is_sample_mask_saved;
    unsigned saved_sample_mask;
 
@@ -124,6 +137,10 @@ struct blitter_context
    struct pipe_query *saved_render_cond_query;
    uint saved_render_cond_mode;
    bool saved_render_cond_cond;
+
+   boolean saved_window_rectangles_include;
+   unsigned saved_num_window_rectangles;
+   struct pipe_scissor_state saved_window_rectangles[PIPE_MAX_WINDOW_RECTANGLES];
 };
 
 /**
@@ -157,6 +174,7 @@ void util_blitter_set_texture_multisample(struct blitter_context *blitter,
  * inside of the draw_rectangle callback if the driver overrides it. */
 void util_blitter_draw_rectangle(struct blitter_context *blitter,
                                  void *vertex_elements_cso,
+                                 blitter_get_vs_func get_vs,
                                  int x1, int y1, int x2, int y2,
                                  float depth, unsigned num_instances,
                                  enum blitter_attrib_type type,
@@ -372,6 +390,11 @@ void util_blitter_custom_resolve_color(struct blitter_context *blitter,
                                        void *custom_blend,
                                        enum pipe_format format);
 
+/* Used by vc4 for 8/16-bit linear-to-tiled blits */
+void util_blitter_custom_shader(struct blitter_context *blitter,
+                                struct pipe_surface *dstsurf,
+                                void *custom_vs, void *custom_fs);
+
 /* The functions below should be used to save currently bound constant state
  * objects inside a driver. The objects are automatically restored at the end
  * of the util_blitter_{clear, copy_region, fill_region} functions and then
@@ -544,6 +567,21 @@ util_blitter_save_render_condition(struct blitter_context *blitter,
    blitter->saved_render_cond_cond = condition;
 }
 
+static inline void
+util_blitter_save_window_rectangles(struct blitter_context *blitter,
+                                    boolean include,
+                                    unsigned num_rectangles,
+                                    const struct pipe_scissor_state *rects)
+{
+   blitter->saved_window_rectangles_include = include;
+   blitter->saved_num_window_rectangles = num_rectangles;
+   if (num_rectangles > 0) {
+      assert(num_rectangles < ARRAY_SIZE(blitter->saved_window_rectangles));
+      memcpy(blitter->saved_window_rectangles, rects,
+             sizeof(*rects) * num_rectangles);
+   }
+}
+
 void util_blitter_common_clear_setup(struct blitter_context *blitter,
                                      unsigned width, unsigned height,
                                      unsigned clear_buffers,