From 3335f047258f19c27faf6fc6394d3e9d8de8eefa Mon Sep 17 00:00:00 2001
From: Niklas Haas <git@haasn.xyz>
Date: Mon, 25 May 2020 12:49:57 +0200
Subject: [PATCH] dispatch: silently upgrade fragment->compute

Whenever PL_GPU_CAP_PARALLEL_COMPUTE is set. In this case, it's assumed
that dispatching multiple compute shaders can take advantage of
parallel execution of the compute queues.
---
 src/dispatch.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/dispatch.c b/src/dispatch.c
index e6be1f99a..c069ad7c6 100644
--- a/src/dispatch.c
+++ b/src/dispatch.c
@@ -854,6 +854,9 @@ bool pl_dispatch_finish(struct pl_dispatch *dp, const struct pl_dispatch_params
         PL_ERR(dp, "Trying to dispatch using a compute shader with a "
                "non-storable target texture.");
         goto error;
+    } else if (tpars->storable && (dp->gpu->caps & PL_GPU_CAP_PARALLEL_COMPUTE)) {
+        if (sh_try_compute(sh, 16, 16, true, 0))
+            PL_TRACE(dp, "Upgrading fragment shader to compute shader.");
     }
 
     struct pl_rect2d rc = params->rect;
-- 
GitLab