aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorEric Anholt <[email protected]>2020-01-06 11:47:03 -0800
committerMarge Bot <[email protected]>2020-01-14 23:55:00 +0000
commitb807f7a43a4df6a13ec365a4c2f152a81e64731b (patch)
tree5741ff8e328e2dbf58574895becb83ff0808a73a /src
parent8832a884345686e6a8b2c0c8aa7515ad3f775b9e (diff)
mesa/st: Deduplicate the NIR uniform lowering code.
Just a little refactor as I go looking at the type size functions. Reviewed-by: Kristian H. Kristensen <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/3297>
Diffstat (limited to 'src')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp23
-rw-r--r--src/mesa/state_tracker/st_nir.h1
-rw-r--r--src/mesa/state_tracker/st_nir_builtins.c10
3 files changed, 16 insertions, 18 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index c92b1c365a7..aad93fb71e2 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -897,6 +897,19 @@ st_nir_lower_samplers(struct pipe_screen *screen, nir_shader *nir,
}
}
+void
+st_nir_lower_uniforms(struct st_context *st, nir_shader *nir)
+{
+ if (st->ctx->Const.PackedDriverUniformStorage) {
+ NIR_PASS_V(nir, nir_lower_io, nir_var_uniform, st_glsl_type_dword_size,
+ (nir_lower_io_options)0);
+ NIR_PASS_V(nir, nir_lower_uniforms_to_ubo, 4);
+ } else {
+ NIR_PASS_V(nir, nir_lower_io, nir_var_uniform, st_glsl_uniforms_type_size,
+ (nir_lower_io_options)0);
+ }
+}
+
/* Last third of preparing nir from glsl, which happens after shader
* variant lowering.
*/
@@ -917,15 +930,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog,
/* Set num_uniforms in number of attribute slots (vec4s) */
nir->num_uniforms = DIV_ROUND_UP(prog->Parameters->NumParameterValues, 4);
- if (st->ctx->Const.PackedDriverUniformStorage) {
- NIR_PASS_V(nir, nir_lower_io, nir_var_uniform, st_glsl_type_dword_size,
- (nir_lower_io_options)0);
- NIR_PASS_V(nir, nir_lower_uniforms_to_ubo, 4);
- } else {
- NIR_PASS_V(nir, nir_lower_io, nir_var_uniform, st_glsl_uniforms_type_size,
- (nir_lower_io_options)0);
- }
-
+ st_nir_lower_uniforms(st, nir);
st_nir_lower_samplers(screen, nir, shader_program, prog);
if (finalize_by_driver && screen->finalize_nir)
diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h
index 1d1bf1b74bc..43f2a917022 100644
--- a/src/mesa/state_tracker/st_nir.h
+++ b/src/mesa/state_tracker/st_nir.h
@@ -58,6 +58,7 @@ void st_nir_assign_varying_locations(struct st_context *st,
void st_nir_lower_samplers(struct pipe_screen *screen, struct nir_shader *nir,
struct gl_shader_program *shader_program,
struct gl_program *prog);
+void st_nir_lower_uniforms(struct st_context *st, struct nir_shader *nir);
struct pipe_shader_state *
st_nir_finish_builtin_shader(struct st_context *st,
diff --git a/src/mesa/state_tracker/st_nir_builtins.c b/src/mesa/state_tracker/st_nir_builtins.c
index aa26c6548c2..de518098024 100644
--- a/src/mesa/state_tracker/st_nir_builtins.c
+++ b/src/mesa/state_tracker/st_nir_builtins.c
@@ -58,15 +58,7 @@ st_nir_finish_builtin_shader(struct st_context *st,
st_nir_assign_varying_locations(st, nir);
st_nir_lower_samplers(screen, nir, NULL, NULL);
-
- if (st->ctx->Const.PackedDriverUniformStorage) {
- NIR_PASS_V(nir, nir_lower_io, nir_var_uniform, st_glsl_type_dword_size,
- (nir_lower_io_options)0);
- NIR_PASS_V(nir, nir_lower_uniforms_to_ubo, 4);
- } else {
- NIR_PASS_V(nir, nir_lower_io, nir_var_uniform, st_glsl_uniforms_type_size,
- (nir_lower_io_options)0);
- }
+ st_nir_lower_uniforms(st, nir);
if (screen->finalize_nir)
screen->finalize_nir(screen, nir, true);