diff options
author | Alyssa Rosenzweig <alyssa@collabora.com> | 2021-05-12 10:41:09 -0400 |
---|---|---|
committer | Marge Bot <eric+marge@anholt.net> | 2021-05-12 19:46:59 +0000 |
commit | 55959da24aecd96d637ca7da4ff827c218015057 (patch) | |
tree | 8a7987ea91111ac25571a73e07910afc3d93e483 /src/gallium/drivers | |
parent | 65a00b519935a335e6bc812b981f2973919bb8bf (diff) |
panfrost: Don't translate compare funcs
Matches Gallium.
Signed-off-by: Alyssa Rosenzweig <alyssa@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10774>
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r-- | src/gallium/drivers/panfrost/pan_cmdstream.c | 30 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_cmdstream.h | 16 | ||||
-rw-r--r-- | src/gallium/drivers/panfrost/pan_context.c | 5 |
3 files changed, 25 insertions, 26 deletions
diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.c b/src/gallium/drivers/panfrost/pan_cmdstream.c index 35cb02d62ab..6b6dee73a42 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.c +++ b/src/gallium/drivers/panfrost/pan_cmdstream.c @@ -1,6 +1,7 @@ /* * Copyright (C) 2018 Alyssa Rosenzweig * Copyright (C) 2020 Collabora Ltd. + * Copyright © 2017 Intel Corporation * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -37,6 +38,25 @@ #include "pan_shader.h" #include "pan_texture.h" +/* Statically assert that PIPE_* enums match the hardware enums. + * (As long as they match, we don't need to translate them.) + */ +UNUSED static void +pan_pipe_asserts() +{ +#define PIPE_ASSERT(x) STATIC_ASSERT((int)x) + + /* Compare functions are natural in both Gallium and Mali */ + PIPE_ASSERT(PIPE_FUNC_NEVER == MALI_FUNC_NEVER); + PIPE_ASSERT(PIPE_FUNC_LESS == MALI_FUNC_LESS); + PIPE_ASSERT(PIPE_FUNC_EQUAL == MALI_FUNC_EQUAL); + PIPE_ASSERT(PIPE_FUNC_LEQUAL == MALI_FUNC_LEQUAL); + PIPE_ASSERT(PIPE_FUNC_GREATER == MALI_FUNC_GREATER); + PIPE_ASSERT(PIPE_FUNC_NOTEQUAL == MALI_FUNC_NOT_EQUAL); + PIPE_ASSERT(PIPE_FUNC_GEQUAL == MALI_FUNC_GEQUAL); + PIPE_ASSERT(PIPE_FUNC_ALWAYS == MALI_FUNC_ALWAYS); +} + /* If a BO is accessed for a particular shader stage, will it be in the primary * batch (vertex/tiler) or the secondary batch (fragment)? Anything but * fragment will be primary, e.g. compute jobs will be considered @@ -149,11 +169,8 @@ translate_tex_wrap(enum pipe_tex_wrap w, bool supports_clamp, bool using_nearest static enum mali_func panfrost_sampler_compare_func(const struct pipe_sampler_state *cso) { - if (!cso->compare_mode) - return MALI_FUNC_NEVER; - - enum mali_func f = panfrost_translate_compare_func(cso->compare_func); - return panfrost_flip_compare_func(f); + return !cso->compare_mode ? MALI_FUNC_NEVER : + panfrost_flip_compare_func((enum mali_func) cso->compare_func); } static enum mali_mipmap_mode @@ -599,8 +616,7 @@ panfrost_prepare_fs_state(struct panfrost_context *ctx, msaa && (ctx->min_samples > 1 || fs->info.fs.sample_shading); state->multisample_misc.depth_function = zsa->base.depth_enabled ? - panfrost_translate_compare_func(zsa->base.depth_func) : - MALI_FUNC_ALWAYS; + (enum mali_func) zsa->base.depth_func : MALI_FUNC_ALWAYS; state->multisample_misc.depth_write_mask = zsa->base.depth_writemask; state->multisample_misc.fixed_function_near_discard = rast->depth_clip_near; diff --git a/src/gallium/drivers/panfrost/pan_cmdstream.h b/src/gallium/drivers/panfrost/pan_cmdstream.h index b09c427eb98..4fca581f823 100644 --- a/src/gallium/drivers/panfrost/pan_cmdstream.h +++ b/src/gallium/drivers/panfrost/pan_cmdstream.h @@ -107,22 +107,6 @@ void panfrost_emit_tile_map(struct panfrost_batch *batch, struct pan_fb_info *fb); -static inline unsigned -panfrost_translate_compare_func(enum pipe_compare_func in) -{ - switch (in) { - case PIPE_FUNC_NEVER: return MALI_FUNC_NEVER; - case PIPE_FUNC_LESS: return MALI_FUNC_LESS; - case PIPE_FUNC_EQUAL: return MALI_FUNC_EQUAL; - case PIPE_FUNC_LEQUAL: return MALI_FUNC_LEQUAL; - case PIPE_FUNC_GREATER: return MALI_FUNC_GREATER; - case PIPE_FUNC_NOTEQUAL: return MALI_FUNC_NOT_EQUAL; - case PIPE_FUNC_GEQUAL: return MALI_FUNC_GEQUAL; - case PIPE_FUNC_ALWAYS: return MALI_FUNC_ALWAYS; - default: unreachable("Invalid func"); - } -} - static inline enum mali_sample_pattern panfrost_sample_pattern(unsigned samples) { diff --git a/src/gallium/drivers/panfrost/pan_context.c b/src/gallium/drivers/panfrost/pan_context.c index 04e9452ed4b..29d533355d7 100644 --- a/src/gallium/drivers/panfrost/pan_context.c +++ b/src/gallium/drivers/panfrost/pan_context.c @@ -1402,7 +1402,7 @@ pan_pipe_to_stencil(const struct pipe_stencil_state *in, struct MALI_STENCIL *ou { pan_prepare(out, STENCIL); out->mask = in->valuemask; - out->compare_function = panfrost_translate_compare_func(in->func); + out->compare_function = (enum mali_func) in->func; out->stencil_fail = pan_pipe_to_stencil_op(in->fail_op); out->depth_fail = pan_pipe_to_stencil_op(in->zfail_op); out->depth_pass = pan_pipe_to_stencil_op(in->zpass_op); @@ -1427,8 +1427,7 @@ panfrost_create_depth_stencil_state(struct pipe_context *pipe, } so->alpha_func = zsa->alpha_enabled ? - panfrost_translate_compare_func(zsa->alpha_func) : - MALI_FUNC_ALWAYS; + (enum mali_func) zsa->alpha_func : MALI_FUNC_ALWAYS; /* TODO: Bounds test should be easy */ assert(!zsa->depth_bounds_test); |