diff options
Diffstat (limited to 'recipes-graphics/mesa/mesa/0009-etnaviv-flush-used-render-buffers-on-context-flush-w.patch')
-rw-r--r-- | recipes-graphics/mesa/mesa/0009-etnaviv-flush-used-render-buffers-on-context-flush-w.patch | 168 |
1 files changed, 168 insertions, 0 deletions
diff --git a/recipes-graphics/mesa/mesa/0009-etnaviv-flush-used-render-buffers-on-context-flush-w.patch b/recipes-graphics/mesa/mesa/0009-etnaviv-flush-used-render-buffers-on-context-flush-w.patch new file mode 100644 index 00000000..4534cd5a --- /dev/null +++ b/recipes-graphics/mesa/mesa/0009-etnaviv-flush-used-render-buffers-on-context-flush-w.patch | |||
@@ -0,0 +1,168 @@ | |||
1 | From 7b9d8d1936d72af6fd1bfd30afed354bb76b4c0c Mon Sep 17 00:00:00 2001 | ||
2 | From: Lucas Stach <l.stach@pengutronix.de> | ||
3 | Date: Fri, 13 Nov 2020 15:05:55 +0100 | ||
4 | Subject: [PATCH] etnaviv: flush used render buffers on context flush when | ||
5 | neccessary | ||
6 | |||
7 | Some resources like backbuffers are explicitly flushed by the frontend | ||
8 | at the appropriate time, others however won't get flushed explicitly. | ||
9 | Remember those resources when they get emitted as a render buffer and | ||
10 | flush them on a context flush to make their content visible to other | ||
11 | entities sharing the buffer. | ||
12 | |||
13 | We still keep the optimized path for most resources where the frontend | ||
14 | promises to do the flushing for us and only enable implicit flushing | ||
15 | when a buffer handle is exported/imported without the | ||
16 | PIPE_HANDLE_USAGE_EXPLICIT_FLUSH flag set. | ||
17 | |||
18 | Signed-off-by: Lucas Stach <l.stach@pengutronix.de> | ||
19 | Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com> | ||
20 | Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7603> | ||
21 | Upstream-Status: Applied [https://gitlab.freedesktop.org/mesa/mesa/-/commit/7b9d8d1936d72af6fd1bfd30afed354bb76b4c0c] | ||
22 | --- | ||
23 | src/gallium/drivers/etnaviv/etnaviv_context.c | 16 ++++++++++++++++ | ||
24 | src/gallium/drivers/etnaviv/etnaviv_context.h | 3 +++ | ||
25 | src/gallium/drivers/etnaviv/etnaviv_resource.c | 7 +++++++ | ||
26 | src/gallium/drivers/etnaviv/etnaviv_resource.h | 2 ++ | ||
27 | src/gallium/drivers/etnaviv/etnaviv_state.c | 18 ++++++++++++++++++ | ||
28 | 5 files changed, 46 insertions(+) | ||
29 | |||
30 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c | ||
31 | index 4dd9e427ea1..581edc78d2f 100644 | ||
32 | --- a/src/gallium/drivers/etnaviv/etnaviv_context.c | ||
33 | +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c | ||
34 | @@ -129,6 +129,9 @@ etna_context_destroy(struct pipe_context *pctx) | ||
35 | _mesa_set_destroy(ctx->used_resources_write, NULL); | ||
36 | |||
37 | } | ||
38 | + if (ctx->flush_resources) | ||
39 | + _mesa_set_destroy(ctx->flush_resources, NULL); | ||
40 | + | ||
41 | mtx_unlock(&ctx->lock); | ||
42 | |||
43 | if (ctx->dummy_desc_bo) | ||
44 | @@ -490,6 +493,14 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, | ||
45 | list_for_each_entry(struct etna_acc_query, aq, &ctx->active_acc_queries, node) | ||
46 | etna_acc_query_suspend(aq, ctx); | ||
47 | |||
48 | + /* flush all resources that need an implicit flush */ | ||
49 | + set_foreach(ctx->flush_resources, entry) { | ||
50 | + struct pipe_resource *prsc = (struct pipe_resource *)entry->key; | ||
51 | + | ||
52 | + pctx->flush_resource(pctx, prsc); | ||
53 | + } | ||
54 | + _mesa_set_clear(ctx->flush_resources, NULL); | ||
55 | + | ||
56 | etna_cmd_stream_flush(ctx->stream, ctx->in_fence_fd, | ||
57 | (flags & PIPE_FLUSH_FENCE_FD) ? &out_fence_fd : NULL); | ||
58 | |||
59 | @@ -596,6 +607,11 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) | ||
60 | if (!ctx->used_resources_write) | ||
61 | goto fail; | ||
62 | |||
63 | + ctx->flush_resources = _mesa_set_create(NULL, _mesa_hash_pointer, | ||
64 | + _mesa_key_pointer_equal); | ||
65 | + if (!ctx->flush_resources) | ||
66 | + goto fail; | ||
67 | + | ||
68 | mtx_init(&ctx->lock, mtx_recursive); | ||
69 | |||
70 | /* context ctxate setup */ | ||
71 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h b/src/gallium/drivers/etnaviv/etnaviv_context.h | ||
72 | index 72000f2122b..21e4d3f33ca 100644 | ||
73 | --- a/src/gallium/drivers/etnaviv/etnaviv_context.h | ||
74 | +++ b/src/gallium/drivers/etnaviv/etnaviv_context.h | ||
75 | @@ -206,6 +206,9 @@ struct etna_context { | ||
76 | struct set *used_resources_read; | ||
77 | struct set *used_resources_write; | ||
78 | |||
79 | + /* resources that must be flushed implicitly at the context flush time */ | ||
80 | + struct set *flush_resources; | ||
81 | + | ||
82 | mtx_t lock; | ||
83 | }; | ||
84 | |||
85 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c | ||
86 | index ae4f24b9b44..0c8c28e66aa 100644 | ||
87 | --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c | ||
88 | +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c | ||
89 | @@ -265,6 +265,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout, | ||
90 | rsc->base.nr_samples = nr_samples; | ||
91 | rsc->layout = layout; | ||
92 | rsc->halign = halign; | ||
93 | + rsc->explicit_flush = true; | ||
94 | |||
95 | pipe_reference_init(&rsc->base.reference, 1); | ||
96 | util_range_init(&rsc->valid_buffer_range); | ||
97 | @@ -519,6 +520,9 @@ etna_resource_from_handle(struct pipe_screen *pscreen, | ||
98 | rsc->layout = modifier_to_layout(handle->modifier); | ||
99 | rsc->halign = TEXTURE_HALIGN_FOUR; | ||
100 | |||
101 | + if (usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH) | ||
102 | + rsc->explicit_flush = true; | ||
103 | + | ||
104 | level->width = tmpl->width0; | ||
105 | level->height = tmpl->height0; | ||
106 | level->depth = tmpl->depth0; | ||
107 | @@ -584,6 +588,9 @@ etna_resource_get_handle(struct pipe_screen *pscreen, | ||
108 | handle->offset = rsc->levels[0].offset; | ||
109 | handle->modifier = layout_to_modifier(rsc->layout); | ||
110 | |||
111 | + if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH)) | ||
112 | + rsc->explicit_flush = false; | ||
113 | + | ||
114 | if (handle->type == WINSYS_HANDLE_TYPE_SHARED) { | ||
115 | return etna_bo_get_name(rsc->bo, &handle->handle) == 0; | ||
116 | } else if (handle->type == WINSYS_HANDLE_TYPE_KMS) { | ||
117 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h b/src/gallium/drivers/etnaviv/etnaviv_resource.h | ||
118 | index cb83e891d34..167cf4ed069 100644 | ||
119 | --- a/src/gallium/drivers/etnaviv/etnaviv_resource.h | ||
120 | +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h | ||
121 | @@ -93,6 +93,8 @@ struct etna_resource { | ||
122 | struct pipe_resource *texture; | ||
123 | /* for when PE doesn't support the base layout */ | ||
124 | struct pipe_resource *render; | ||
125 | + /* frontend flushes resource via an explicit call to flush_resource */ | ||
126 | + bool explicit_flush; | ||
127 | |||
128 | enum etna_resource_status status; | ||
129 | |||
130 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c | ||
131 | index 44b1c4f8fab..1ad839799f2 100644 | ||
132 | --- a/src/gallium/drivers/etnaviv/etnaviv_state.c | ||
133 | +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c | ||
134 | @@ -753,6 +753,21 @@ etna_update_zsa(struct etna_context *ctx) | ||
135 | return true; | ||
136 | } | ||
137 | |||
138 | +static bool | ||
139 | +etna_record_flush_resources(struct etna_context *ctx) | ||
140 | +{ | ||
141 | + struct pipe_framebuffer_state *fb = &ctx->framebuffer_s; | ||
142 | + | ||
143 | + if (fb->nr_cbufs > 0) { | ||
144 | + struct etna_surface *surf = etna_surface(fb->cbufs[0]); | ||
145 | + | ||
146 | + if (!etna_resource(surf->prsc)->explicit_flush) | ||
147 | + _mesa_set_add(ctx->flush_resources, surf->prsc); | ||
148 | + } | ||
149 | + | ||
150 | + return true; | ||
151 | +} | ||
152 | + | ||
153 | struct etna_state_updater { | ||
154 | bool (*update)(struct etna_context *ctx); | ||
155 | uint32_t dirty; | ||
156 | @@ -780,6 +795,9 @@ static const struct etna_state_updater etna_state_updates[] = { | ||
157 | }, | ||
158 | { | ||
159 | etna_update_zsa, ETNA_DIRTY_ZSA | ETNA_DIRTY_SHADER, | ||
160 | + }, | ||
161 | + { | ||
162 | + etna_record_flush_resources, ETNA_DIRTY_FRAMEBUFFER, | ||
163 | } | ||
164 | }; | ||
165 | |||
166 | -- | ||
167 | 2.31.1 | ||
168 | |||