diff options
author | Andreas Müller <schnitzeltony@gmail.com> | 2021-04-07 22:00:18 +0200 |
---|---|---|
committer | Otavio Salvador <otavio@ossystems.com.br> | 2021-04-20 12:10:12 -0300 |
commit | bfb9e6990f896772a8109818ff06a89325b4f484 (patch) | |
tree | feb56533e0f7eed403982b94673e20e36fb460c4 /recipes-graphics/mesa/mesa/0006-etnaviv-flush-used-render-buffers-on-context-flush-w.patch | |
parent | a8ee8f6d2703025a0549cf705e31d616d54fb5fb (diff) | |
download | meta-freescale-bfb9e6990f896772a8109818ff06a89325b4f484.tar.gz |
mesa/etnaviv: Add patches to fix redraw
Without this series mouse pointer was not visible and screen was updated only
when mouse was moved.
Patch series was suggested in [1]
[1] https://gitlab.freedesktop.org/mesa/mesa/-/issues/4584
Signed-off-by: Andreas Müller <schnitzeltony@gmail.com>
Diffstat (limited to 'recipes-graphics/mesa/mesa/0006-etnaviv-flush-used-render-buffers-on-context-flush-w.patch')
-rw-r--r-- | recipes-graphics/mesa/mesa/0006-etnaviv-flush-used-render-buffers-on-context-flush-w.patch | 166 |
1 files changed, 166 insertions, 0 deletions
diff --git a/recipes-graphics/mesa/mesa/0006-etnaviv-flush-used-render-buffers-on-context-flush-w.patch b/recipes-graphics/mesa/mesa/0006-etnaviv-flush-used-render-buffers-on-context-flush-w.patch new file mode 100644 index 00000000..ea658a03 --- /dev/null +++ b/recipes-graphics/mesa/mesa/0006-etnaviv-flush-used-render-buffers-on-context-flush-w.patch | |||
@@ -0,0 +1,166 @@ | |||
1 | From 537c7a6ea3fd2e5a6433e52b406ba39b89f520d9 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 6/6] 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 | |||
20 | Upstream-Status: Submitted [https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7603] | ||
21 | --- | ||
22 | src/gallium/drivers/etnaviv/etnaviv_context.c | 16 ++++++++++++++++ | ||
23 | src/gallium/drivers/etnaviv/etnaviv_context.h | 3 +++ | ||
24 | src/gallium/drivers/etnaviv/etnaviv_resource.c | 7 +++++++ | ||
25 | src/gallium/drivers/etnaviv/etnaviv_resource.h | 2 ++ | ||
26 | src/gallium/drivers/etnaviv/etnaviv_state.c | 17 +++++++++++++++++ | ||
27 | 5 files changed, 45 insertions(+) | ||
28 | |||
29 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.c b/src/gallium/drivers/etnaviv/etnaviv_context.c | ||
30 | index 9c334a450c6..80c5d430419 100644 | ||
31 | --- a/src/gallium/drivers/etnaviv/etnaviv_context.c | ||
32 | +++ b/src/gallium/drivers/etnaviv/etnaviv_context.c | ||
33 | @@ -128,6 +128,9 @@ etna_context_destroy(struct pipe_context *pctx) | ||
34 | _mesa_set_destroy(ctx->used_resources_write, NULL); | ||
35 | |||
36 | } | ||
37 | + if (ctx->flush_resources) | ||
38 | + _mesa_set_destroy(ctx->flush_resources, NULL); | ||
39 | + | ||
40 | mtx_unlock(&ctx->lock); | ||
41 | |||
42 | if (ctx->dummy_desc_bo) | ||
43 | @@ -475,6 +478,14 @@ etna_flush(struct pipe_context *pctx, struct pipe_fence_handle **fence, | ||
44 | list_for_each_entry(struct etna_acc_query, aq, &ctx->active_acc_queries, node) | ||
45 | etna_acc_query_suspend(aq, ctx); | ||
46 | |||
47 | + /* flush all resources that need an implicit flush */ | ||
48 | + set_foreach(ctx->flush_resources, entry) { | ||
49 | + struct pipe_resource *prsc = (struct pipe_resource *)entry->key; | ||
50 | + | ||
51 | + pctx->flush_resource(pctx, prsc); | ||
52 | + } | ||
53 | + _mesa_set_clear(ctx->flush_resources, NULL); | ||
54 | + | ||
55 | etna_cmd_stream_flush(ctx->stream, ctx->in_fence_fd, | ||
56 | (flags & PIPE_FLUSH_FENCE_FD) ? &out_fence_fd : NULL); | ||
57 | |||
58 | @@ -581,6 +592,11 @@ etna_context_create(struct pipe_screen *pscreen, void *priv, unsigned flags) | ||
59 | if (!ctx->used_resources_write) | ||
60 | goto fail; | ||
61 | |||
62 | + ctx->flush_resources = _mesa_set_create(NULL, _mesa_hash_pointer, | ||
63 | + _mesa_key_pointer_equal); | ||
64 | + if (!ctx->flush_resources) | ||
65 | + goto fail; | ||
66 | + | ||
67 | mtx_init(&ctx->lock, mtx_recursive); | ||
68 | |||
69 | /* context ctxate setup */ | ||
70 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_context.h b/src/gallium/drivers/etnaviv/etnaviv_context.h | ||
71 | index dd6af3d93e6..112902aac8a 100644 | ||
72 | --- a/src/gallium/drivers/etnaviv/etnaviv_context.h | ||
73 | +++ b/src/gallium/drivers/etnaviv/etnaviv_context.h | ||
74 | @@ -206,6 +206,9 @@ struct etna_context { | ||
75 | struct set *used_resources_read; | ||
76 | struct set *used_resources_write; | ||
77 | |||
78 | + /* resources that must be flushed implicitly at the context flush time */ | ||
79 | + struct set *flush_resources; | ||
80 | + | ||
81 | mtx_t lock; | ||
82 | }; | ||
83 | |||
84 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c b/src/gallium/drivers/etnaviv/etnaviv_resource.c | ||
85 | index ae4f24b9b44..0c8c28e66aa 100644 | ||
86 | --- a/src/gallium/drivers/etnaviv/etnaviv_resource.c | ||
87 | +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c | ||
88 | @@ -265,6 +265,7 @@ etna_resource_alloc(struct pipe_screen *pscreen, unsigned layout, | ||
89 | rsc->base.nr_samples = nr_samples; | ||
90 | rsc->layout = layout; | ||
91 | rsc->halign = halign; | ||
92 | + rsc->explicit_flush = true; | ||
93 | |||
94 | pipe_reference_init(&rsc->base.reference, 1); | ||
95 | util_range_init(&rsc->valid_buffer_range); | ||
96 | @@ -519,6 +520,9 @@ etna_resource_from_handle(struct pipe_screen *pscreen, | ||
97 | rsc->layout = modifier_to_layout(handle->modifier); | ||
98 | rsc->halign = TEXTURE_HALIGN_FOUR; | ||
99 | |||
100 | + if (usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH) | ||
101 | + rsc->explicit_flush = true; | ||
102 | + | ||
103 | level->width = tmpl->width0; | ||
104 | level->height = tmpl->height0; | ||
105 | level->depth = tmpl->depth0; | ||
106 | @@ -584,6 +588,9 @@ etna_resource_get_handle(struct pipe_screen *pscreen, | ||
107 | handle->offset = rsc->levels[0].offset; | ||
108 | handle->modifier = layout_to_modifier(rsc->layout); | ||
109 | |||
110 | + if (!(usage & PIPE_HANDLE_USAGE_EXPLICIT_FLUSH)) | ||
111 | + rsc->explicit_flush = false; | ||
112 | + | ||
113 | if (handle->type == WINSYS_HANDLE_TYPE_SHARED) { | ||
114 | return etna_bo_get_name(rsc->bo, &handle->handle) == 0; | ||
115 | } else if (handle->type == WINSYS_HANDLE_TYPE_KMS) { | ||
116 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.h b/src/gallium/drivers/etnaviv/etnaviv_resource.h | ||
117 | index cb83e891d34..167cf4ed069 100644 | ||
118 | --- a/src/gallium/drivers/etnaviv/etnaviv_resource.h | ||
119 | +++ b/src/gallium/drivers/etnaviv/etnaviv_resource.h | ||
120 | @@ -93,6 +93,8 @@ struct etna_resource { | ||
121 | struct pipe_resource *texture; | ||
122 | /* for when PE doesn't support the base layout */ | ||
123 | struct pipe_resource *render; | ||
124 | + /* frontend flushes resource via an explicit call to flush_resource */ | ||
125 | + bool explicit_flush; | ||
126 | |||
127 | enum etna_resource_status status; | ||
128 | |||
129 | diff --git a/src/gallium/drivers/etnaviv/etnaviv_state.c b/src/gallium/drivers/etnaviv/etnaviv_state.c | ||
130 | index 84fea58ecb5..5848735ab14 100644 | ||
131 | --- a/src/gallium/drivers/etnaviv/etnaviv_state.c | ||
132 | +++ b/src/gallium/drivers/etnaviv/etnaviv_state.c | ||
133 | @@ -741,6 +741,21 @@ etna_update_zsa(struct etna_context *ctx) | ||
134 | return true; | ||
135 | } | ||
136 | |||
137 | +static bool | ||
138 | +etna_record_flush_resources(struct etna_context *ctx) | ||
139 | +{ | ||
140 | + struct pipe_framebuffer_state *fb = &ctx->framebuffer_s; | ||
141 | + | ||
142 | + if (fb->nr_cbufs > 0) { | ||
143 | + struct etna_surface *surf = etna_surface(fb->cbufs[0]); | ||
144 | + | ||
145 | + if (!etna_resource(surf->prsc)->explicit_flush) | ||
146 | + _mesa_set_add(ctx->flush_resources, surf->prsc); | ||
147 | + } | ||
148 | + | ||
149 | + return true; | ||
150 | +} | ||
151 | + | ||
152 | struct etna_state_updater { | ||
153 | bool (*update)(struct etna_context *ctx); | ||
154 | uint32_t dirty; | ||
155 | @@ -762,6 +777,8 @@ static const struct etna_state_updater etna_state_updates[] = { | ||
156 | ETNA_DIRTY_RASTERIZER | ETNA_DIRTY_VIEWPORT, | ||
157 | }, { | ||
158 | etna_update_zsa, ETNA_DIRTY_ZSA | ETNA_DIRTY_SHADER, | ||
159 | + }, { | ||
160 | + etna_record_flush_resources, ETNA_DIRTY_FRAMEBUFFER, | ||
161 | } | ||
162 | }; | ||
163 | |||
164 | -- | ||
165 | 2.26.2 | ||
166 | |||