vc4: Add support for texture border color.
[mesa.git] / src / gallium / drivers / freedreno / freedreno_draw.c
index 1289bb4b8f2a71cadf0356330375a21c6bb4f85f..eb4637db1a5c5128502bb57fba752f319416d684 100644 (file)
@@ -71,7 +71,7 @@ fd_draw_emit(struct fd_context *ctx, struct fd_ringbuffer *ring,
                idx_bo = fd_resource(idx->buffer)->bo;
                idx_type = size2indextype(idx->index_size);
                idx_size = idx->index_size * info->count;
-               idx_offset = idx->offset;
+               idx_offset = idx->offset + (info->start * idx->index_size);
                src_sel = DI_SRC_SEL_DMA;
        } else {
                idx_bo = NULL;
@@ -157,8 +157,25 @@ fd_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
        /* and any buffers used, need to be resolved: */
        ctx->resolve |= buffers;
 
+       DBG("%x num_draws=%u (%s/%s)", buffers, ctx->num_draws,
+               util_format_short_name(pipe_surface_format(pfb->cbufs[0])),
+               util_format_short_name(pipe_surface_format(pfb->zsbuf)));
+
        fd_hw_query_set_stage(ctx, ctx->ring, FD_STAGE_DRAW);
        ctx->draw(ctx, info);
+
+       /* if an app (or, well, piglit test) does many thousands of draws
+        * without flush (or anything which implicitly flushes, like
+        * changing render targets), we can exceed the ringbuffer size.
+        * Since we don't currently have a sane way to wrapparound, and
+        * we use the same buffer for both draw and tiling commands, for
+        * now we need to do this hack and trigger flush if we are running
+        * low on remaining space for cmds:
+        */
+       if (((ctx->ring->cur - ctx->ring->start) >
+                               (ctx->ring->size/4 - FD_TILING_COMMANDS_DWORDS)) ||
+                       (fd_mesa_debug & FD_DBG_FLUSH))
+               fd_context_render(pctx);
 }
 
 /* TODO figure out how to make better use of existing state mechanism