summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2018-06-18 15:53:47 -0400
committerDylan Baker <dylan@pnwbakers.com>2018-07-03 10:24:58 -0700
commitfde83d5f2bcc0408b5f4bbc60ba779f49f975c8c (patch)
tree35ca13234529485646411c25a5f96fc2b1d13969
parent45bea64814c6324ed03903a27792381a7b611953 (diff)
radeonsi: fix memory exhaustion issue with DCC statistics gathering with DRI2
Cc: 18.1 <mesa-stable@lists.freedesktop.org> (cherry picked from commit 41f80373b46604f585497086f971a43aeea7f0c1) Conflicts fixed by Dylan Conflicts: src/gallium/drivers/radeonsi/si_blit.c
-rw-r--r--src/gallium/drivers/radeonsi/si_blit.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/src/gallium/drivers/radeonsi/si_blit.c b/src/gallium/drivers/radeonsi/si_blit.c
index d6eab58b3a..7581d5bde3 100644
--- a/src/gallium/drivers/radeonsi/si_blit.c
+++ b/src/gallium/drivers/radeonsi/si_blit.c
@@ -1317,9 +1317,33 @@ static void si_flush_resource(struct pipe_context *ctx,
}
/* Always do the analysis even if DCC is disabled at the moment. */
- if (rtex->dcc_gather_statistics && rtex->separate_dcc_dirty) {
- rtex->separate_dcc_dirty = false;
- vi_separate_dcc_process_and_reset_stats(ctx, rtex);
+ if (rtex->dcc_gather_statistics) {
+ bool separate_dcc_dirty = rtex->separate_dcc_dirty;
+
+ /* If the color buffer hasn't been unbound and fast clear hasn't
+ * been used, separate_dcc_dirty is false, but there may have been
+ * new rendering. Check if the color buffer is bound and assume
+ * it's dirty.
+ *
+ * Note that DRI2 never unbinds window colorbuffers, which means
+ * the DCC pipeline statistics query would never be re-set and would
+ * keep adding new results until all free memory is exhausted if we
+ * didn't do this.
+ */
+ if (!separate_dcc_dirty) {
+ for (unsigned i = 0; i < sctx->framebuffer.state.nr_cbufs; i++) {
+ if (sctx->framebuffer.state.cbufs[i] &&
+ sctx->framebuffer.state.cbufs[i]->texture == res) {
+ separate_dcc_dirty = true;
+ break;
+ }
+ }
+ }
+
+ if (separate_dcc_dirty) {
+ rtex->separate_dcc_dirty = false;
+ vi_separate_dcc_process_and_reset_stats(ctx, rtex);
+ }
}
}