/* map from lima_submit_key to lima_submit */
struct hash_table *submits;
+ /* map from pipe_resource to lima_submit which write to it */
+ struct hash_table *write_submits;
+
int in_sync_fd;
uint32_t in_sync[2];
uint32_t out_sync[2];
void lima_flush(struct lima_context *ctx);
void lima_flush_submit_accessing_bo(
struct lima_context *ctx, struct lima_bo *bo, bool write);
+void lima_flush_previous_submit_writing_resource(
+ struct lima_context *ctx, struct pipe_resource *prsc);
#endif
#include "util/u_upload_mgr.h"
#include "util/u_prim.h"
#include "util/u_vbuf.h"
+#include "util/hash_table.h"
#include "lima_context.h"
#include "lima_screen.h"
!(ctx->resolve & PIPE_CLEAR_COLOR0)) {
struct lima_resource *res = lima_resource(fb->base.cbufs[0]->texture);
lima_flush_submit_accessing_bo(ctx, res->bo, true);
+ _mesa_hash_table_insert(ctx->write_submits, &res->base, submit);
lima_submit_add_bo(submit, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
}
!(ctx->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL))) {
struct lima_resource *res = lima_resource(fb->base.zsbuf->texture);
lima_flush_submit_accessing_bo(ctx, res->bo, true);
+ _mesa_hash_table_insert(ctx->write_submits, &res->base, submit);
lima_submit_add_bo(submit, LIMA_PIPE_PP, res->bo, LIMA_SUBMIT_BO_WRITE);
}
_mesa_hash_table_remove_key(ctx->submits, &submit->key);
+ if (submit->key.cbuf && (ctx->resolve & PIPE_CLEAR_COLOR0))
+ _mesa_hash_table_remove_key(ctx->write_submits, submit->key.cbuf->texture);
+ if (submit->key.zsbuf && (ctx->resolve & (PIPE_CLEAR_DEPTH | PIPE_CLEAR_STENCIL)))
+ _mesa_hash_table_remove_key(ctx->write_submits, submit->key.zsbuf->texture);
+
pipe_surface_reference(&submit->key.cbuf, NULL);
pipe_surface_reference(&submit->key.zsbuf, NULL);
ctx->damage_rect.minx = ctx->damage_rect.miny = 0xffff;
ctx->damage_rect.maxx = ctx->damage_rect.maxy = 0;
- ctx->resolve = 0;
-
lima_dump_file_next();
if (ctx->submit == submit)
ctx->submit = NULL;
lima_submit_free(submit);
+
+ /* lima_submit_free still need this */
+ ctx->resolve = 0;
}
void
}
}
+/*
+ * This is for current submit flush previous submit which write to the resource it wants
+ * to read. Tipical usage is flush the FBO which is used as current task's texture.
+ */
+void
+lima_flush_previous_submit_writing_resource(
+ struct lima_context *ctx, struct pipe_resource *prsc)
+{
+ struct hash_entry *entry = _mesa_hash_table_search(ctx->write_submits, prsc);
+
+ if (entry) {
+ struct lima_submit *submit = entry->data;
+
+ /* do not flush current submit */
+ if (submit != ctx->submit)
+ lima_do_submit(submit);
+ }
+}
+
static void
lima_pipe_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence,
unsigned flags)
if (!ctx->submits)
return false;
+ ctx->write_submits = _mesa_hash_table_create(
+ ctx, _mesa_hash_pointer, _mesa_key_pointer_equal);
+ if (!ctx->write_submits)
+ return false;
+
ctx->in_sync_fd = -1;
for (int i = 0; i < 2; i++) {
for (int i = 0; i < lima_tex->num_samplers; i++) {
struct lima_sampler_view *texture = lima_sampler_view(lima_tex->textures[i]);
struct lima_resource *rsc = lima_resource(texture->base.texture);
+ lima_flush_previous_submit_writing_resource(ctx, texture->base.texture);
lima_submit_add_bo(submit, LIMA_PIPE_PP, rsc->bo, LIMA_SUBMIT_BO_READ);
}