st/nir/radeonsi: move nir_lower_uniforms_to_ubo() to the state tracker

This will only ever be used by gallium drivers so it probably doesn't
belong in the nir toolkit. Also we want to pass it some non NIR
things in the following patch.

To avoid regressions we wrap the lowering calls that have been moved
to st_glsl_to_nir with a quick hack so that they are only called for
radeonsi, we will replace the hack with a check for uniform packing
in a following patch.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
Timothy Arceri 2018-03-09 11:57:52 +11:00
parent a80cf442d9
commit ffa4bbe466
9 changed files with 18 additions and 14 deletions

View File

@ -244,7 +244,6 @@ NIR_FILES = \
nir/nir_lower_tex.c \
nir/nir_lower_to_source_mods.c \
nir/nir_lower_two_sided_color.c \
nir/nir_lower_uniforms_to_ubo.c \
nir/nir_lower_vars_to_ssa.c \
nir/nir_lower_var_copies.c \
nir/nir_lower_vec_to_movs.c \

View File

@ -138,7 +138,6 @@ files_libnir = files(
'nir_lower_tex.c',
'nir_lower_to_source_mods.c',
'nir_lower_two_sided_color.c',
'nir_lower_uniforms_to_ubo.c',
'nir_lower_vars_to_ssa.c',
'nir_lower_var_copies.c',
'nir_lower_vec_to_movs.c',

View File

@ -2712,7 +2712,6 @@ void nir_lower_bitmap(nir_shader *shader, const nir_lower_bitmap_options *option
bool nir_lower_atomics(nir_shader *shader,
const struct gl_shader_program *shader_program);
bool nir_lower_atomics_to_ssbo(nir_shader *shader, unsigned ssbo_offset);
bool nir_lower_uniforms_to_ubo(nir_shader *shader);
bool nir_lower_to_source_mods(nir_shader *shader);
bool nir_lower_gs_intrinsics(nir_shader *shader);

View File

@ -32,12 +32,6 @@
#include "compiler/nir_types.h"
static int
type_size(const struct glsl_type *type)
{
return glsl_count_attribute_slots(type, false);
}
static void scan_instruction(struct tgsi_shader_info *info,
nir_instr *instr)
{
@ -650,10 +644,6 @@ si_lower_nir(struct si_shader_selector* sel)
* - ensure constant offsets for texture instructions are folded
* and copy-propagated
*/
NIR_PASS_V(sel->nir, nir_lower_io, nir_var_uniform, type_size,
(nir_lower_io_options)0);
NIR_PASS_V(sel->nir, nir_lower_uniforms_to_ubo);
NIR_PASS_V(sel->nir, nir_lower_returns);
NIR_PASS_V(sel->nir, nir_lower_vars_to_ssa);
NIR_PASS_V(sel->nir, nir_lower_alu_to_scalar);

View File

@ -532,6 +532,7 @@ STATETRACKER_FILES = \
state_tracker/st_nir.h \
state_tracker/st_nir_lower_builtin.c \
state_tracker/st_nir_lower_tex_src_plane.c \
state_tracker/st_nir_lower_uniforms_to_ubo.c \
state_tracker/st_pbo.c \
state_tracker/st_pbo.h \
state_tracker/st_program.c \

View File

@ -579,6 +579,7 @@ files_libmesa_gallium = files(
'state_tracker/st_nir.h',
'state_tracker/st_nir_lower_builtin.c',
'state_tracker/st_nir_lower_tex_src_plane.c',
'state_tracker/st_nir_lower_uniforms_to_ubo.c',
'state_tracker/st_pbo.c',
'state_tracker/st_pbo.h',
'state_tracker/st_program.c',

View File

@ -37,6 +37,7 @@
#include "main/uniforms.h"
#include "st_context.h"
#include "st_glsl_types.h"
#include "st_program.h"
#include "compiler/nir/nir.h"
@ -752,6 +753,18 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
st_nir_assign_uniform_locations(st->ctx, prog, shader_program,
&nir->uniforms, &nir->num_uniforms);
/* Below is a quick hack so that uniform lowering only runs on radeonsi
* (the only NIR backend that currently supports tess) once we enable
* uniform packing support we will just use
* ctx->Const.PackedDriverUniformStorage for this check.
*/
if (screen->get_shader_param(screen, PIPE_SHADER_TESS_CTRL,
PIPE_SHADER_CAP_MAX_INSTRUCTIONS) > 0) {
NIR_PASS_V(nir, nir_lower_io, nir_var_uniform, type_size,
(nir_lower_io_options)0);
NIR_PASS_V(nir, st_nir_lower_uniforms_to_ubo);
}
if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
NIR_PASS_V(nir, nir_lower_samplers_as_deref, shader_program);
else

View File

@ -36,6 +36,7 @@ struct nir_shader;
void st_nir_lower_builtin(struct nir_shader *shader);
void st_nir_lower_tex_src_plane(struct nir_shader *shader, unsigned free_slots,
unsigned lower_2plane, unsigned lower_3plane);
bool st_nir_lower_uniforms_to_ubo(struct nir_shader *shader);
void st_finalize_nir(struct st_context *st, struct gl_program *prog,
struct gl_shader_program *shader_program,

View File

@ -31,6 +31,7 @@
#include "nir.h"
#include "nir_builder.h"
#include "st_nir.h"
static bool
lower_instr(nir_intrinsic_instr *instr, nir_builder *b)
@ -71,7 +72,7 @@ lower_instr(nir_intrinsic_instr *instr, nir_builder *b)
}
bool
nir_lower_uniforms_to_ubo(nir_shader *shader)
st_nir_lower_uniforms_to_ubo(nir_shader *shader)
{
bool progress = false;