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 <eric@anholt.net>
This commit is contained in:
Kenneth Graunke
2019-02-06 00:03:49 -08:00
parent 243c11dc16
commit 8d1646e0e1
2 changed files with 14 additions and 4 deletions

View File

@@ -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" */

View File

@@ -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,