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:

committed by
Marge Bot

parent
e5102a406f
commit
b4b2fd0bb4
@@ -33,19 +33,6 @@
|
|||||||
struct gl_linked_shader;
|
struct gl_linked_shader;
|
||||||
struct gl_shader_program;
|
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() */
|
/* Operations for lower_64bit_integer_instructions() */
|
||||||
#define DIV64 (1U << 0)
|
#define DIV64 (1U << 0)
|
||||||
#define MOD64 (1U << 1)
|
#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 do_vec_index_to_cond_assign(exec_list *instructions);
|
||||||
bool lower_discard(exec_list *instructions);
|
bool lower_discard(exec_list *instructions);
|
||||||
void lower_discard_flow(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,
|
bool lower_clip_cull_distance(struct gl_shader_program *prog,
|
||||||
gl_linked_shader *shader);
|
gl_linked_shader *shader);
|
||||||
bool lower_packing_builtins(exec_list *instructions,
|
bool lower_packing_builtins(exec_list *instructions,
|
||||||
|
@@ -56,6 +56,19 @@
|
|||||||
|
|
||||||
#include <math.h>
|
#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;
|
using namespace ir_builder;
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
@@ -110,8 +123,27 @@ private:
|
|||||||
#define lowering(x) (this->lower & x)
|
#define lowering(x) (this->lower & x)
|
||||||
|
|
||||||
bool
|
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);
|
lower_instructions_visitor v(what_to_lower);
|
||||||
|
|
||||||
visit_list_elements(&v, instructions);
|
visit_list_elements(&v, instructions);
|
||||||
|
@@ -103,7 +103,7 @@ do_optimization(struct exec_list *ir, const char *optimization,
|
|||||||
return lower_discard(ir);
|
return lower_discard(ir);
|
||||||
} else if (sscanf(optimization, "lower_instructions ( %d ) ",
|
} else if (sscanf(optimization, "lower_instructions ( %d ) ",
|
||||||
&int_0) == 1) {
|
&int_0) == 1) {
|
||||||
return lower_instructions(ir, int_0);
|
return lower_instructions(ir, false, false, false, false, false);
|
||||||
} else {
|
} else {
|
||||||
printf("Unrecognized optimization %s\n", optimization);
|
printf("Unrecognized optimization %s\n", optimization);
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@@ -83,25 +83,9 @@ link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||||||
lower_blend_equation_advanced(
|
lower_blend_equation_advanced(
|
||||||
shader, ctx->Extensions.KHR_blend_equation_advanced_coherent);
|
shader, ctx->Extensions.KHR_blend_equation_advanced_coherent);
|
||||||
|
|
||||||
lower_instructions(ir,
|
lower_instructions(ir, have_ldexp, have_dfrexp, have_dround,
|
||||||
(have_ldexp ? 0 : LDEXP_TO_ARITH) |
|
ctx->Const.ForceGLSLAbsSqrt,
|
||||||
(have_dfrexp ? 0 : DFREXP_DLDEXP_TO_ARITH) |
|
ctx->Extensions.ARB_gpu_shader5);
|
||||||
(have_dround ? 0 : DOPS_TO_DFRAC) |
|
|
||||||
(ctx->Const.ForceGLSLAbsSqrt ? 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.
|
|
||||||
*/
|
|
||||||
(!ctx->Extensions.ARB_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));
|
|
||||||
|
|
||||||
do_vec_index_to_cond_assign(ir);
|
do_vec_index_to_cond_assign(ir);
|
||||||
lower_vector_insert(ir, true);
|
lower_vector_insert(ir, true);
|
||||||
|
Reference in New Issue
Block a user