aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorIcecream95 <[email protected]>2020-02-14 20:22:38 +1300
committerMarge Bot <[email protected]>2020-02-14 12:53:36 +0000
commitf3490a141c8d562fc29e714c3735f2ae8e3c0512 (patch)
tree00a48949a663868ff23809b2c0e8e275ce27fa87 /src
parentefda2cfcf96b1071c18800ff3f878fe627359e8a (diff)
panfrost: Inline panfrost_get_default_swizzle
This commit replaces panfrost_get_default_swizzle with an inlined implementation where the returned values can be determined at compile time. According to perf, this previously used about 2% CPU for Openarena. Reviewed-by: Alyssa Rosenzweig <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3824>
Diffstat (limited to 'src')
-rw-r--r--src/gallium/drivers/panfrost/pan_assemble.c1
-rw-r--r--src/gallium/drivers/panfrost/pan_context.h3
-rw-r--r--src/gallium/drivers/panfrost/pan_format.c14
-rw-r--r--src/gallium/drivers/panfrost/pan_format.h24
-rw-r--r--src/gallium/drivers/panfrost/pan_varyings.c1
5 files changed, 23 insertions, 20 deletions
diff --git a/src/gallium/drivers/panfrost/pan_assemble.c b/src/gallium/drivers/panfrost/pan_assemble.c
index 03ca63ccc32..6f84248b2f1 100644
--- a/src/gallium/drivers/panfrost/pan_assemble.c
+++ b/src/gallium/drivers/panfrost/pan_assemble.c
@@ -27,6 +27,7 @@
#include <string.h>
#include "pan_bo.h"
#include "pan_context.h"
+#include "pan_format.h"
#include "pan_util.h"
#include "compiler/nir/nir.h"
diff --git a/src/gallium/drivers/panfrost/pan_context.h b/src/gallium/drivers/panfrost/pan_context.h
index 79d082da11f..fcfcafb135a 100644
--- a/src/gallium/drivers/panfrost/pan_context.h
+++ b/src/gallium/drivers/panfrost/pan_context.h
@@ -297,9 +297,6 @@ panfrost_emit_for_draw(struct panfrost_context *ctx, bool with_vertex_data);
struct panfrost_transfer
panfrost_vertex_tiler_job(struct panfrost_context *ctx, bool is_tiler);
-unsigned
-panfrost_get_default_swizzle(unsigned components);
-
void
panfrost_flush(
struct pipe_context *pipe,
diff --git a/src/gallium/drivers/panfrost/pan_format.c b/src/gallium/drivers/panfrost/pan_format.c
index 4f138ca4027..f8e3277150f 100644
--- a/src/gallium/drivers/panfrost/pan_format.c
+++ b/src/gallium/drivers/panfrost/pan_format.c
@@ -72,20 +72,6 @@ panfrost_translate_swizzle_4(const unsigned char swizzle[4])
return out;
}
-unsigned
-panfrost_get_default_swizzle(unsigned components)
-{
- unsigned char default_swizzles[4][4] = {
- {PIPE_SWIZZLE_X, PIPE_SWIZZLE_0, PIPE_SWIZZLE_0, PIPE_SWIZZLE_1},
- {PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_0, PIPE_SWIZZLE_1},
- {PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_1},
- {PIPE_SWIZZLE_X, PIPE_SWIZZLE_Y, PIPE_SWIZZLE_Z, PIPE_SWIZZLE_W},
- };
-
- assert(components >= 1 && components <= 4);
- return panfrost_translate_swizzle_4(default_swizzles[components - 1]);
-}
-
static unsigned
panfrost_translate_channel_width(unsigned size)
{
diff --git a/src/gallium/drivers/panfrost/pan_format.h b/src/gallium/drivers/panfrost/pan_format.h
index 8468904da23..b82493df425 100644
--- a/src/gallium/drivers/panfrost/pan_format.h
+++ b/src/gallium/drivers/panfrost/pan_format.h
@@ -31,9 +31,6 @@
unsigned
panfrost_translate_swizzle_4(const unsigned char swizzle[4]);
-unsigned
-panfrost_get_default_swizzle(unsigned components);
-
enum mali_format
panfrost_find_format(const struct util_format_description *desc);
@@ -43,6 +40,27 @@ panfrost_invert_swizzle(const unsigned char *in, unsigned char *out);
bool
panfrost_is_z24s8_variant(enum pipe_format fmt);
+static inline unsigned
+panfrost_get_default_swizzle(unsigned components)
+{
+ switch (components) {
+ case 1:
+ return (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_ZERO << 3) |
+ (MALI_CHANNEL_ZERO << 6) | (MALI_CHANNEL_ONE << 9);
+ case 2:
+ return (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) |
+ (MALI_CHANNEL_ZERO << 6) | (MALI_CHANNEL_ONE << 9);
+ case 3:
+ return (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) |
+ (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ONE << 9);
+ case 4:
+ return (MALI_CHANNEL_RED << 0) | (MALI_CHANNEL_GREEN << 3) |
+ (MALI_CHANNEL_BLUE << 6) | (MALI_CHANNEL_ALPHA << 9);
+ default:
+ unreachable("Invalid number of components");
+ }
+}
+
#endif
diff --git a/src/gallium/drivers/panfrost/pan_varyings.c b/src/gallium/drivers/panfrost/pan_varyings.c
index 0ec4d5633d2..52496aa26d7 100644
--- a/src/gallium/drivers/panfrost/pan_varyings.c
+++ b/src/gallium/drivers/panfrost/pan_varyings.c
@@ -25,6 +25,7 @@
#include "pan_bo.h"
#include "pan_context.h"
+#include "pan_format.h"
#include "util/u_prim.h"
static mali_ptr