aboutsummaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorKenneth Graunke <[email protected]>2018-10-25 02:22:33 -0700
committerKenneth Graunke <[email protected]>2018-11-03 23:34:34 -0700
commit5294d65011afa3437322bc53b5909f4e88a9c9f7 (patch)
treefa3a5a0444a3e603ec65daf2f3180823ebaf1d8a /src/mesa/state_tracker
parent424a6052dfe76d9d6fd3679d79dd7d4d093771e3 (diff)
st/mesa: Pull nir_lower_wpos_ytransform work into a helper function.
This will let me use it in the ARB program code as well. Reviewed-by: Rob Clark <[email protected]>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_glsl_to_nir.cpp65
-rw-r--r--src/mesa/state_tracker/st_nir.h4
2 files changed, 40 insertions, 29 deletions
diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp
index c58deadc957..f609efbff95 100644
--- a/src/mesa/state_tracker/st_glsl_to_nir.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp
@@ -619,6 +619,40 @@ st_nir_link_shaders(nir_shader **producer, nir_shader **consumer, bool scalar)
extern "C" {
+void
+st_nir_lower_wpos_ytransform(struct nir_shader *nir,
+ struct gl_program *prog,
+ struct pipe_screen *pscreen)
+{
+ if (nir->info.stage != MESA_SHADER_FRAGMENT)
+ return;
+
+ static const gl_state_index16 wposTransformState[STATE_LENGTH] = {
+ STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
+ };
+ nir_lower_wpos_ytransform_options wpos_options = { { 0 } };
+
+ memcpy(wpos_options.state_tokens, wposTransformState,
+ sizeof(wpos_options.state_tokens));
+ wpos_options.fs_coord_origin_upper_left =
+ pscreen->get_param(pscreen,
+ PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT);
+ wpos_options.fs_coord_origin_lower_left =
+ pscreen->get_param(pscreen,
+ PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
+ wpos_options.fs_coord_pixel_center_integer =
+ pscreen->get_param(pscreen,
+ PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
+ wpos_options.fs_coord_pixel_center_half_integer =
+ pscreen->get_param(pscreen,
+ PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER);
+
+ if (nir_lower_wpos_ytransform(nir, &wpos_options)) {
+ nir_validate_shader(nir, "after nir_lower_wpos_ytransform");
+ _mesa_add_state_reference(prog->Parameters, wposTransformState);
+ }
+}
+
bool
st_link_nir(struct gl_context *ctx,
struct gl_shader_program *shader_program)
@@ -697,35 +731,8 @@ st_link_nir(struct gl_context *ctx,
nir_shader *nir = shader->Program->nir;
- /* fragment shaders may need : */
- if (nir->info.stage == MESA_SHADER_FRAGMENT) {
- static const gl_state_index16 wposTransformState[STATE_LENGTH] = {
- STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM
- };
- nir_lower_wpos_ytransform_options wpos_options = { { 0 } };
- struct pipe_screen *pscreen = st->pipe->screen;
-
- memcpy(wpos_options.state_tokens, wposTransformState,
- sizeof(wpos_options.state_tokens));
- wpos_options.fs_coord_origin_upper_left =
- pscreen->get_param(pscreen,
- PIPE_CAP_TGSI_FS_COORD_ORIGIN_UPPER_LEFT);
- wpos_options.fs_coord_origin_lower_left =
- pscreen->get_param(pscreen,
- PIPE_CAP_TGSI_FS_COORD_ORIGIN_LOWER_LEFT);
- wpos_options.fs_coord_pixel_center_integer =
- pscreen->get_param(pscreen,
- PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_INTEGER);
- wpos_options.fs_coord_pixel_center_half_integer =
- pscreen->get_param(pscreen,
- PIPE_CAP_TGSI_FS_COORD_PIXEL_CENTER_HALF_INTEGER);
-
- if (nir_lower_wpos_ytransform(nir, &wpos_options)) {
- nir_validate_shader(nir, "after nir_lower_wpos_ytransform");
- _mesa_add_state_reference(shader->Program->Parameters,
- wposTransformState);
- }
- }
+ NIR_PASS_V(nir, st_nir_lower_wpos_ytransform, shader->Program,
+ st->pipe->screen);
NIR_PASS_V(nir, nir_lower_system_values);
diff --git a/src/mesa/state_tracker/st_nir.h b/src/mesa/state_tracker/st_nir.h
index aa6e32758e8..10f23c03ef6 100644
--- a/src/mesa/state_tracker/st_nir.h
+++ b/src/mesa/state_tracker/st_nir.h
@@ -38,6 +38,10 @@ 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_nir_lower_wpos_ytransform(struct nir_shader *nir,
+ struct gl_program *prog,
+ struct pipe_screen *pscreen);
+
void st_finalize_nir(struct st_context *st, struct gl_program *prog,
struct gl_shader_program *shader_program,
struct nir_shader *nir);