mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-04-30 23:28:06 +02:00
glsl: move rule inside lower_packing_builtins()
We only have a single user of this pass so lets tidy things up and move all the rules in the pass itself. 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:
parent
141703f906
commit
a31c547206
3 changed files with 51 additions and 49 deletions
|
|
@ -53,31 +53,6 @@ struct gl_shader_program;
|
|||
#define DIV64 (1U << 0)
|
||||
#define MOD64 (1U << 1)
|
||||
|
||||
/**
|
||||
* \see class lower_packing_builtins_visitor
|
||||
*/
|
||||
enum lower_packing_builtins_op {
|
||||
LOWER_PACK_UNPACK_NONE = 0x0000,
|
||||
|
||||
LOWER_PACK_SNORM_2x16 = 0x0001,
|
||||
LOWER_UNPACK_SNORM_2x16 = 0x0002,
|
||||
|
||||
LOWER_PACK_UNORM_2x16 = 0x0004,
|
||||
LOWER_UNPACK_UNORM_2x16 = 0x0008,
|
||||
|
||||
LOWER_PACK_HALF_2x16 = 0x0010,
|
||||
LOWER_UNPACK_HALF_2x16 = 0x0020,
|
||||
|
||||
LOWER_PACK_SNORM_4x8 = 0x0040,
|
||||
LOWER_UNPACK_SNORM_4x8 = 0x0080,
|
||||
|
||||
LOWER_PACK_UNORM_4x8 = 0x0100,
|
||||
LOWER_UNPACK_UNORM_4x8 = 0x0200,
|
||||
|
||||
LOWER_PACK_USE_BFI = 0x0400,
|
||||
LOWER_PACK_USE_BFE = 0x0800,
|
||||
};
|
||||
|
||||
bool do_common_optimization(exec_list *ir, bool linked,
|
||||
const struct gl_shader_compiler_options *options,
|
||||
bool native_integers);
|
||||
|
|
@ -110,7 +85,10 @@ void lower_discard_flow(exec_list *instructions);
|
|||
bool lower_instructions(exec_list *instructions, unsigned what_to_lower);
|
||||
bool lower_clip_cull_distance(struct gl_shader_program *prog,
|
||||
gl_linked_shader *shader);
|
||||
bool lower_packing_builtins(exec_list *instructions, int op_mask);
|
||||
bool lower_packing_builtins(exec_list *instructions,
|
||||
bool has_shading_language_packing,
|
||||
bool has_gpu_shader5,
|
||||
bool has_half_float_packing);
|
||||
bool lower_vector_insert(exec_list *instructions, bool lower_nonconstant_index);
|
||||
bool lower_vector_derefs(gl_linked_shader *shader);
|
||||
void lower_named_interface_blocks(void *mem_ctx, gl_linked_shader *shader);
|
||||
|
|
|
|||
|
|
@ -26,6 +26,28 @@
|
|||
#include "ir_optimization.h"
|
||||
#include "ir_rvalue_visitor.h"
|
||||
|
||||
enum lower_packing_builtins_op {
|
||||
LOWER_PACK_UNPACK_NONE = 0x0000,
|
||||
|
||||
LOWER_PACK_SNORM_2x16 = 0x0001,
|
||||
LOWER_UNPACK_SNORM_2x16 = 0x0002,
|
||||
|
||||
LOWER_PACK_UNORM_2x16 = 0x0004,
|
||||
LOWER_UNPACK_UNORM_2x16 = 0x0008,
|
||||
|
||||
LOWER_PACK_HALF_2x16 = 0x0010,
|
||||
LOWER_UNPACK_HALF_2x16 = 0x0020,
|
||||
|
||||
LOWER_PACK_SNORM_4x8 = 0x0040,
|
||||
LOWER_UNPACK_SNORM_4x8 = 0x0080,
|
||||
|
||||
LOWER_PACK_UNORM_4x8 = 0x0100,
|
||||
LOWER_UNPACK_UNORM_4x8 = 0x0200,
|
||||
|
||||
LOWER_PACK_USE_BFI = 0x0400,
|
||||
LOWER_PACK_USE_BFE = 0x0800,
|
||||
};
|
||||
|
||||
namespace {
|
||||
|
||||
using namespace ir_builder;
|
||||
|
|
@ -1299,12 +1321,31 @@ private:
|
|||
|
||||
/**
|
||||
* \brief Lower the builtin packing functions.
|
||||
*
|
||||
* \param op_mask is a bitmask of `enum lower_packing_builtins_op`.
|
||||
*/
|
||||
bool
|
||||
lower_packing_builtins(exec_list *instructions, int op_mask)
|
||||
lower_packing_builtins(exec_list *instructions,
|
||||
bool has_shading_language_packing,
|
||||
bool has_gpu_shader5,
|
||||
bool has_half_float_packing)
|
||||
{
|
||||
if (!has_shading_language_packing)
|
||||
return false;
|
||||
|
||||
int op_mask = LOWER_PACK_SNORM_2x16 |
|
||||
LOWER_UNPACK_SNORM_2x16 |
|
||||
LOWER_PACK_UNORM_2x16 |
|
||||
LOWER_UNPACK_UNORM_2x16 |
|
||||
LOWER_PACK_SNORM_4x8 |
|
||||
LOWER_UNPACK_SNORM_4x8 |
|
||||
LOWER_UNPACK_UNORM_4x8 |
|
||||
LOWER_PACK_UNORM_4x8;
|
||||
|
||||
if (has_gpu_shader5)
|
||||
op_mask |= LOWER_PACK_USE_BFI | LOWER_PACK_USE_BFE;
|
||||
|
||||
if (!has_half_float_packing)
|
||||
op_mask |= LOWER_PACK_HALF_2x16 | LOWER_UNPACK_HALF_2x16;
|
||||
|
||||
lower_packing_builtins_visitor v(op_mask);
|
||||
visit_list_elements(&v, instructions, true);
|
||||
return v.get_progress();
|
||||
|
|
|
|||
|
|
@ -74,26 +74,9 @@ link_shader(struct gl_context *ctx, struct gl_shader_program *prog)
|
|||
if (!pscreen->get_param(pscreen, PIPE_CAP_INT64_DIVMOD))
|
||||
lower_64bit_integer_instructions(ir, DIV64 | MOD64);
|
||||
|
||||
if (ctx->Extensions.ARB_shading_language_packing) {
|
||||
unsigned lower_inst = LOWER_PACK_SNORM_2x16 |
|
||||
LOWER_UNPACK_SNORM_2x16 |
|
||||
LOWER_PACK_UNORM_2x16 |
|
||||
LOWER_UNPACK_UNORM_2x16 |
|
||||
LOWER_PACK_SNORM_4x8 |
|
||||
LOWER_UNPACK_SNORM_4x8 |
|
||||
LOWER_UNPACK_UNORM_4x8 |
|
||||
LOWER_PACK_UNORM_4x8;
|
||||
|
||||
if (ctx->Extensions.ARB_gpu_shader5)
|
||||
lower_inst |= LOWER_PACK_USE_BFI |
|
||||
LOWER_PACK_USE_BFE;
|
||||
if (!ctx->st->has_half_float_packing)
|
||||
lower_inst |= LOWER_PACK_HALF_2x16 |
|
||||
LOWER_UNPACK_HALF_2x16;
|
||||
|
||||
lower_packing_builtins(ir, lower_inst);
|
||||
}
|
||||
|
||||
lower_packing_builtins(ir, ctx->Extensions.ARB_shading_language_packing,
|
||||
ctx->Extensions.ARB_gpu_shader5,
|
||||
ctx->st->has_half_float_packing);
|
||||
do_mat_op_to_vec(ir);
|
||||
|
||||
if (stage == MESA_SHADER_FRAGMENT && pscreen->get_param(pscreen, PIPE_CAP_FBFETCH))
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue