panfrost: Remove mali_alt_func

There's only one way to encode comparison functions in the command
stream, not two. It's just that the semantics for texture comparisons
are flipped from the semantics of stencil comparison. We can factor out
that flip to common Panfrost code, rather than tying it to a second
Gallium routine.

Signed-off-by: Alyssa Rosenzweig <alyssa.rosenzweig@collabora.com>
This commit is contained in:
Alyssa Rosenzweig 2019-12-27 12:56:03 -05:00
parent bc1fc29e21
commit de077c2078
7 changed files with 59 additions and 72 deletions

View File

@ -280,39 +280,6 @@ panfrost_translate_compare_func(enum pipe_compare_func in)
}
}
static unsigned
panfrost_translate_alt_compare_func(enum pipe_compare_func in)
{
switch (in) {
case PIPE_FUNC_NEVER:
return MALI_ALT_FUNC_NEVER;
case PIPE_FUNC_LESS:
return MALI_ALT_FUNC_LESS;
case PIPE_FUNC_EQUAL:
return MALI_ALT_FUNC_EQUAL;
case PIPE_FUNC_LEQUAL:
return MALI_ALT_FUNC_LEQUAL;
case PIPE_FUNC_GREATER:
return MALI_ALT_FUNC_GREATER;
case PIPE_FUNC_NOTEQUAL:
return MALI_ALT_FUNC_NOTEQUAL;
case PIPE_FUNC_GEQUAL:
return MALI_ALT_FUNC_GEQUAL;
case PIPE_FUNC_ALWAYS:
return MALI_ALT_FUNC_ALWAYS;
default:
unreachable("Invalid alt func");
}
}
static unsigned
panfrost_translate_stencil_op(enum pipe_stencil_op in)
{
@ -1781,7 +1748,9 @@ panfrost_create_sampler_state(
.wrap_s = translate_tex_wrap(cso->wrap_s),
.wrap_t = translate_tex_wrap(cso->wrap_t),
.wrap_r = translate_tex_wrap(cso->wrap_r),
.compare_func = panfrost_translate_alt_compare_func(cso->compare_func),
.compare_func = panfrost_flip_compare_func(
panfrost_translate_compare_func(
cso->compare_func)),
.border_color = {
cso->border_color.f[0],
cso->border_color.f[1],

View File

@ -18,6 +18,7 @@ encoder_FILES := \
encoder/pan_attributes.c \
encoder/pan_encoder.h \
encoder/pan_invocation.c \
encoder/pan_sampler.c
encoder/pan_tiler.c \
encoder/pan_scratch.c

View File

@ -24,6 +24,7 @@ libpanfrost_encoder_files = files(
'pan_attributes.c',
'pan_invocation.c',
'pan_sampler.c',
'pan_tiler.c',
'pan_scratch.c',
'pan_props.c',

View File

@ -102,4 +102,9 @@ panfrost_vertex_instanced(
void panfrost_vertex_id(unsigned padded_count, union mali_attr *attr);
void panfrost_instance_id(unsigned padded_count, union mali_attr *attr);
/* Samplers */
enum mali_func
panfrost_flip_compare_func(enum mali_func f);
#endif

View File

@ -0,0 +1,45 @@
/*
* Copyright (C) 2019 Collabora, Ltd.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*
*/
#include "pan_encoder.h"
/* Sampler comparison functions are flipped in OpenGL from the hardware, so we
* need to be able to flip accordingly */
enum mali_func
panfrost_flip_compare_func(enum mali_func f)
{
switch (f) {
case MALI_FUNC_LESS:
return MALI_FUNC_GREATER;
case MALI_FUNC_GREATER:
return MALI_FUNC_LESS;
case MALI_FUNC_LEQUAL:
return MALI_FUNC_GEQUAL;
case MALI_FUNC_GEQUAL:
return MALI_FUNC_LEQUAL;
default:
return f;
}
}

View File

@ -88,19 +88,6 @@ enum mali_func {
MALI_FUNC_ALWAYS = 7
};
/* Same OpenGL, but mixed up. Why? Because forget me, that's why! */
enum mali_alt_func {
MALI_ALT_FUNC_NEVER = 0,
MALI_ALT_FUNC_GREATER = 1,
MALI_ALT_FUNC_EQUAL = 2,
MALI_ALT_FUNC_GEQUAL = 3,
MALI_ALT_FUNC_LESS = 4,
MALI_ALT_FUNC_NOTEQUAL = 5,
MALI_ALT_FUNC_LEQUAL = 6,
MALI_ALT_FUNC_ALWAYS = 7
};
/* Flags apply to unknown2_3? */
#define MALI_HAS_MSAA (1 << 0)
@ -1290,12 +1277,13 @@ struct mali_sampler_descriptor {
uint16_t min_lod;
uint16_t max_lod;
/* All one word in reality, but packed a bit */
/* All one word in reality, but packed a bit. Comparisons are flipped
* from OpenGL. */
enum mali_wrap_mode wrap_s : 4;
enum mali_wrap_mode wrap_t : 4;
enum mali_wrap_mode wrap_r : 4;
enum mali_alt_func compare_func : 3;
enum mali_func compare_func : 3;
/* No effect on 2D textures. For cubemaps, set for ES3 and clear for
* ES2, controlling seamless cubemapping */

View File

@ -375,28 +375,6 @@ pandecode_func(enum mali_func mode)
}
#undef DEFINE_CASE
/* Why is this duplicated? Who knows... */
#define DEFINE_CASE(name) case MALI_ALT_FUNC_ ## name: return "MALI_ALT_FUNC_" #name
static char *
pandecode_alt_func(enum mali_alt_func mode)
{
switch (mode) {
DEFINE_CASE(NEVER);
DEFINE_CASE(LESS);
DEFINE_CASE(EQUAL);
DEFINE_CASE(LEQUAL);
DEFINE_CASE(GREATER);
DEFINE_CASE(NOTEQUAL);
DEFINE_CASE(GEQUAL);
DEFINE_CASE(ALWAYS);
default:
pandecode_msg("XXX: invalid alt func %X\n", mode);
return "";
}
}
#undef DEFINE_CASE
#define DEFINE_CASE(name) case MALI_STENCIL_ ## name: return "MALI_STENCIL_" #name
static char *
pandecode_stencil_op(enum mali_stencil_op op)
@ -2468,7 +2446,7 @@ pandecode_vertex_tiler_postfix_pre(
pandecode_prop("wrap_t = %s", pandecode_wrap_mode(s->wrap_t));
pandecode_prop("wrap_r = %s", pandecode_wrap_mode(s->wrap_r));
pandecode_prop("compare_func = %s", pandecode_alt_func(s->compare_func));
pandecode_prop("compare_func = %s", pandecode_func(s->compare_func));
if (s->zero || s->zero2) {
pandecode_msg("XXX: sampler zero tripped\n");