summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-11-14 10:06:47 +1100
committerTimothy Arceri <[email protected]>2017-12-04 09:10:30 +1100
commita9ac01b96f265af10fe4de58699c75ec6e0b6238 (patch)
tree100ffa0c40b7616d8f7a94753322512049b8f23a
parentd586f39cb0fb65624d9e0534f5eaafbf2a3ccc88 (diff)
st/glsl_to_nir: make st_glsl_to_nir() static
Here we also move the extern C functions to the bottom of the file. Reviewed-by: Nicolai Hähnle <[email protected]>
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp102
-rw-r--r--src/mesa/state_tracker/st_nir.h4
2 files changed, 51 insertions, 55 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index b51e738b8ce..4a772e65421 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -247,13 +247,11 @@ st_nir_assign_uniform_locations(struct gl_program *prog,
*size = max;
}
-extern "C" {
-
/* First third of converting glsl_to_nir.. this leaves things in a pre-
* nir_lower_io state, so that shader variants can more easily insert/
* replace variables, etc.
*/
-nir_shader *
+static nir_shader *
st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
struct gl_shader_program *shader_program,
gl_shader_stage stage)
@@ -392,54 +390,6 @@ sort_varyings(struct exec_list *var_list)
exec_list_move_nodes_to(&new_list, var_list);
}
-/* Last third of preparing nir from glsl, which happens after shader
- * variant lowering.
- */
-void
-st_finalize_nir(struct st_context *st, struct gl_program *prog,
- struct gl_shader_program *shader_program, nir_shader *nir)
-{
- struct pipe_screen *screen = st->pipe->screen;
-
- NIR_PASS_V(nir, nir_split_var_copies);
- NIR_PASS_V(nir, nir_lower_var_copies);
- NIR_PASS_V(nir, nir_lower_io_types);
-
- if (nir->info.stage == MESA_SHADER_VERTEX) {
- /* Needs special handling so drvloc matches the vbo state: */
- st_nir_assign_vs_in_locations(prog, nir);
- /* Re-lower global vars, to deal with any dead VS inputs. */
- NIR_PASS_V(nir, nir_lower_global_vars_to_local);
-
- sort_varyings(&nir->outputs);
- st_nir_assign_var_locations(&nir->outputs,
- &nir->num_outputs);
- st_nir_fixup_varying_slots(st, &nir->outputs);
- } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
- sort_varyings(&nir->inputs);
- st_nir_assign_var_locations(&nir->inputs,
- &nir->num_inputs);
- st_nir_fixup_varying_slots(st, &nir->inputs);
- st_nir_assign_var_locations(&nir->outputs,
- &nir->num_outputs);
- } else if (nir->info.stage == MESA_SHADER_COMPUTE) {
- /* TODO? */
- } else {
- unreachable("invalid shader type for tgsi bypass\n");
- }
-
- NIR_PASS_V(nir, nir_lower_atomics_to_ssbo,
- st->ctx->Const.Program[nir->info.stage].MaxAtomicBuffers);
-
- st_nir_assign_uniform_locations(prog, shader_program,
- &nir->uniforms, &nir->num_uniforms);
-
- if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
- NIR_PASS_V(nir, nir_lower_samplers_as_deref, shader_program);
- else
- NIR_PASS_V(nir, nir_lower_samplers, shader_program);
-}
-
static void
set_st_program(struct gl_program *prog,
struct gl_shader_program *shader_program,
@@ -518,6 +468,8 @@ st_nir_get_mesa_program(struct gl_context *ctx,
prog->nir = nir;
}
+extern "C" {
+
bool
st_link_nir(struct gl_context *ctx,
struct gl_shader_program *shader_program)
@@ -551,4 +503,52 @@ st_link_nir(struct gl_context *ctx,
return true;
}
+/* Last third of preparing nir from glsl, which happens after shader
+ * variant lowering.
+ */
+void
+st_finalize_nir(struct st_context *st, struct gl_program *prog,
+ struct gl_shader_program *shader_program, nir_shader *nir)
+{
+ struct pipe_screen *screen = st->pipe->screen;
+
+ NIR_PASS_V(nir, nir_split_var_copies);
+ NIR_PASS_V(nir, nir_lower_var_copies);
+ NIR_PASS_V(nir, nir_lower_io_types);
+
+ if (nir->info.stage == MESA_SHADER_VERTEX) {
+ /* Needs special handling so drvloc matches the vbo state: */
+ st_nir_assign_vs_in_locations(prog, nir);
+ /* Re-lower global vars, to deal with any dead VS inputs. */
+ NIR_PASS_V(nir, nir_lower_global_vars_to_local);
+
+ sort_varyings(&nir->outputs);
+ st_nir_assign_var_locations(&nir->outputs,
+ &nir->num_outputs);
+ st_nir_fixup_varying_slots(st, &nir->outputs);
+ } else if (nir->info.stage == MESA_SHADER_FRAGMENT) {
+ sort_varyings(&nir->inputs);
+ st_nir_assign_var_locations(&nir->inputs,
+ &nir->num_inputs);
+ st_nir_fixup_varying_slots(st, &nir->inputs);
+ st_nir_assign_var_locations(&nir->outputs,
+ &nir->num_outputs);
+ } else if (nir->info.stage == MESA_SHADER_COMPUTE) {
+ /* TODO? */
+ } else {
+ unreachable("invalid shader type for tgsi bypass\n");
+ }
+
+ NIR_PASS_V(nir, nir_lower_atomics_to_ssbo,
+ st->ctx->Const.Program[nir->info.stage].MaxAtomicBuffers);
+
+ st_nir_assign_uniform_locations(prog, shader_program,
+ &nir->uniforms, &nir->num_uniforms);
+
+ if (screen->get_param(screen, PIPE_CAP_NIR_SAMPLERS_AS_DEREF))
+ NIR_PASS_V(nir, nir_lower_samplers_as_deref, shader_program);
+ else
+ NIR_PASS_V(nir, nir_lower_samplers, shader_program);
+}
+
} /* extern "C" */
diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h
index c65e753f9b4..8c81c3f2d86 100644
--- a/src/mesa/state_tracker/st_nir.h
+++ b/src/mesa/state_tracker/st_nir.h
@@ -37,10 +37,6 @@ 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);
-struct nir_shader * st_glsl_to_nir(struct st_context *st, struct gl_program *prog,
- struct gl_shader_program *shader_program,
- gl_shader_stage stage);
-
void st_finalize_nir(struct st_context *st, struct gl_program *prog,
struct gl_shader_program *shader_program,
struct nir_shader *nir);