gallium: add pipe cap for scissored clears and pass scissor state to clear() hook
[mesa.git] / src / gallium / drivers / v3d / v3d_blit.c
index 7662c63d8fe9b21413321216c09562a81f3f8e2a..d1e895688bc9f15dcbb5c408e8172773065f3d19 100644 (file)
@@ -21,7 +21,7 @@
  * IN THE SOFTWARE.
  */
 
-#include "util/u_format.h"
+#include "util/format/u_format.h"
 #include "util/u_surface.h"
 #include "util/u_blitter.h"
 #include "v3d_context.h"
@@ -128,7 +128,7 @@ v3d_tile_blit(struct pipe_context *pctx, const struct pipe_blit_info *info)
         struct pipe_surface *src_surf =
                 v3d_get_blit_surface(pctx, info->src.resource, info->src.level);
 
-        v3d_flush_jobs_reading_resource(v3d, info->src.resource);
+        v3d_flush_jobs_reading_resource(v3d, info->src.resource, false);
 
         struct v3d_job *job = v3d_get_job(v3d, dst_surf, NULL);
         pipe_surface_reference(&job->color_read, src_surf);
@@ -172,6 +172,7 @@ v3d_blitter_save(struct v3d_context *v3d)
         util_blitter_save_vertex_buffer_slot(v3d->blitter, v3d->vertexbuf.vb);
         util_blitter_save_vertex_elements(v3d->blitter, v3d->vtx);
         util_blitter_save_vertex_shader(v3d->blitter, v3d->prog.bind_vs);
+        util_blitter_save_geometry_shader(v3d->blitter, v3d->prog.bind_gs);
         util_blitter_save_so_targets(v3d->blitter, v3d->streamout.num_targets,
                                      v3d->streamout.targets);
         util_blitter_save_rasterizer(v3d->blitter, v3d->rasterizer);
@@ -380,8 +381,8 @@ v3d_tfu(struct pipe_context *pctx,
         if (dst_base_slice->tiling == VC5_TILING_RASTER)
                 return false;
 
-        v3d_flush_jobs_writing_resource(v3d, psrc);
-        v3d_flush_jobs_reading_resource(v3d, pdst);
+        v3d_flush_jobs_writing_resource(v3d, psrc, V3D_FLUSH_DEFAULT, false);
+        v3d_flush_jobs_reading_resource(v3d, pdst, V3D_FLUSH_DEFAULT, false);
 
         struct drm_v3d_submit_tfu tfu = {
                 .ios = (height << 16) | width,
@@ -457,7 +458,7 @@ v3d_tfu(struct pipe_context *pctx,
         return true;
 }
 
-boolean
+bool
 v3d_generate_mipmap(struct pipe_context *pctx,
                     struct pipe_resource *prsc,
                     enum pipe_format format,
@@ -491,7 +492,8 @@ v3d_tfu_blit(struct pipe_context *pctx, const struct pipe_blit_info *info)
         if ((info->mask & PIPE_MASK_RGBA) == 0)
                 return false;
 
-        if (info->dst.box.x != 0 ||
+        if (info->scissor_enable ||
+            info->dst.box.x != 0 ||
             info->dst.box.y != 0 ||
             info->dst.box.width != dst_width ||
             info->dst.box.height != dst_height ||
@@ -517,6 +519,7 @@ v3d_tfu_blit(struct pipe_context *pctx, const struct pipe_blit_info *info)
 void
 v3d_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info)
 {
+        struct v3d_context *v3d = v3d_context(pctx);
         struct pipe_blit_info info = *blit_info;
 
         if (info.mask & PIPE_MASK_S) {
@@ -529,4 +532,12 @@ v3d_blit(struct pipe_context *pctx, const struct pipe_blit_info *blit_info)
 
         if (info.mask)
                 v3d_render_blit(pctx, &info);
+
+        /* Flush our blit jobs immediately.  They're unlikely to get reused by
+         * normal drawing or other blits, and without flushing we can easily
+         * run into unexpected OOMs when blits are used for a large series of
+         * texture uploads before using the textures.
+         */
+        v3d_flush_jobs_writing_resource(v3d, info.dst.resource,
+                                        V3D_FLUSH_DEFAULT, false);
 }