glsl: move lower instructions logic inside that pass

There is now only a single called of this pass so tidy things up
and move all this logic inside the pass.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/19112>
This commit is contained in:
Timothy Arceri
2022-10-17 21:49:44 +11:00
committed by Marge Bot
parent e5102a406f
commit b4b2fd0bb4
4 changed files with 40 additions and 35 deletions

View File

@@ -33,19 +33,6 @@
struct gl_linked_shader;
struct gl_shader_program;
/* Operations for lower_instructions() */
#define LDEXP_TO_ARITH 0x80
#define DOPS_TO_DFRAC 0x800
#define DFREXP_DLDEXP_TO_ARITH 0x1000
#define BIT_COUNT_TO_MATH 0x02000
#define EXTRACT_TO_SHIFTS 0x04000
#define INSERT_TO_SHIFTS 0x08000
#define REVERSE_TO_SHIFTS 0x10000
#define FIND_LSB_TO_FLOAT_CAST 0x20000
#define FIND_MSB_TO_FLOAT_CAST 0x40000
#define IMUL_HIGH_TO_MUL 0x80000
#define SQRT_TO_ABS_SQRT 0x200000
/* Operations for lower_64bit_integer_instructions() */
#define DIV64 (1U << 0)
#define MOD64 (1U << 1)
@@ -79,7 +66,9 @@ bool do_tree_grafting(exec_list *instructions);
bool do_vec_index_to_cond_assign(exec_list *instructions);
bool lower_discard(exec_list *instructions);
void lower_discard_flow(exec_list *instructions);
bool lower_instructions(exec_list *instructions, unsigned what_to_lower);
bool lower_instructions(exec_list *instructions, bool have_ldexp,
bool have_dfrexp, bool have_dround,
bool force_abs_sqrt, bool have_gpu_shader5);
bool lower_clip_cull_distance(struct gl_shader_program *prog,
gl_linked_shader *shader);
bool lower_packing_builtins(exec_list *instructions,

View File

@@ -56,6 +56,19 @@
#include <math.h>
/* Operations for lower_instructions() */
#define LDEXP_TO_ARITH 0x80
#define DOPS_TO_DFRAC 0x800
#define DFREXP_DLDEXP_TO_ARITH 0x1000
#define BIT_COUNT_TO_MATH 0x02000
#define EXTRACT_TO_SHIFTS 0x04000
#define INSERT_TO_SHIFTS 0x08000
#define REVERSE_TO_SHIFTS 0x10000
#define FIND_LSB_TO_FLOAT_CAST 0x20000
#define FIND_MSB_TO_FLOAT_CAST 0x40000
#define IMUL_HIGH_TO_MUL 0x80000
#define SQRT_TO_ABS_SQRT 0x200000
using namespace ir_builder;
namespace {
@@ -110,8 +123,27 @@ private:
#define lowering(x) (this->lower & x)
bool
lower_instructions(exec_list *instructions, unsigned what_to_lower)
lower_instructions(exec_list *instructions, bool have_ldexp, bool have_dfrexp,
bool have_dround, bool force_abs_sqrt,
bool have_gpu_shader5)
{
unsigned what_to_lower =
(have_ldexp ? 0 : LDEXP_TO_ARITH) |
(have_dfrexp ? 0 : DFREXP_DLDEXP_TO_ARITH) |
(have_dround ? 0 : DOPS_TO_DFRAC) |
(force_abs_sqrt ? SQRT_TO_ABS_SQRT : 0) |
/* Assume that if ARB_gpu_shader5 is not supported then all of the
* extended integer functions need lowering. It may be necessary to add
* some caps for individual instructions.
*/
(!have_gpu_shader5 ? BIT_COUNT_TO_MATH |
EXTRACT_TO_SHIFTS |
INSERT_TO_SHIFTS |
REVERSE_TO_SHIFTS |
FIND_LSB_TO_FLOAT_CAST |
FIND_MSB_TO_FLOAT_CAST |
IMUL_HIGH_TO_MUL : 0);
lower_instructions_visitor v(what_to_lower);
visit_list_elements(&v, instructions);

View File

@@ -103,7 +103,7 @@ do_optimization(struct exec_list *ir, const char *optimization,
return lower_discard(ir);
} else if (sscanf(optimization, "lower_instructions ( %d ) ",
&int_0) == 1) {
return lower_instructions(ir, int_0);
return lower_instructions(ir, false, false, false, false, false);
} else {
printf("Unrecognized optimization %s\n", optimization);
exit(EXIT_FAILURE);