From: Kenneth Graunke Date: Wed, 6 Feb 2019 08:03:49 +0000 (-0800) Subject: st/nir: Pull sampler lowering into a helper function. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=8d1646e0e1d926052a883590ba6bb185c963db55;p=mesa.git st/nir: Pull sampler lowering into a helper function. This will make it easier to reuse across GLSL / ARB / built-ins. Reviewed-by: Eric Anholt --- diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 686c243e508..b904060528b 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -846,6 +846,16 @@ st_nir_assign_varying_locations(struct st_context *st, nir_shader *nir) } } +void +st_nir_lower_samplers(struct pipe_screen *screen, nir_shader *nir, + struct gl_shader_program *shader_program) +{ + if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF)) + NIR_PASS_V(nir, gl_nir_lower_samplers_as_deref, shader_program); + else + NIR_PASS_V(nir, gl_nir_lower_samplers, shader_program); +} + /* Last third of preparing nir from glsl, which happens after shader * variant lowering. */ @@ -881,10 +891,7 @@ st_finalize_nir(struct st_context *st, struct gl_program *prog, 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, gl_nir_lower_samplers_as_deref, shader_program); - else - NIR_PASS_V(nir, gl_nir_lower_samplers, shader_program); + st_nir_lower_samplers(screen, nir, shader_program); } } /* extern "C" */ diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h index fcd67e32d44..42a04a4676b 100644 --- a/src/mesa/state_tracker/st_nir.h +++ b/src/mesa/state_tracker/st_nir.h @@ -55,6 +55,9 @@ st_link_nir(struct gl_context *ctx, void st_nir_assign_varying_locations(struct st_context *st, struct nir_shader *nir); +void st_nir_lower_samplers(struct pipe_screen *screen, struct nir_shader *nir, + struct gl_shader_program *shader_program); + struct pipe_shader_state * st_nir_finish_builtin_shader(struct st_context *st, struct nir_shader *nir,