[Mesa-dev] [v2 14/18] i965/blorp: Use flat inputs instead of uniforms

Topi Pohjolainen topi.pohjolainen at intel.com
Mon Jul 4 16:45:02 UTC 2016


v2 (Jason): Use LOAD_INPUT() macro

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
Reviewed-by: Jason Ekstrand <jason at jlekstrand.net> (v1)
---
 src/mesa/drivers/dri/i965/brw_blorp_blit.cpp  | 24 +++++++++++++-----------
 src/mesa/drivers/dri/i965/brw_blorp_clear.cpp |  9 +++++----
 2 files changed, 18 insertions(+), 15 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index 0d9fb92..76e771f 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -331,10 +331,10 @@ enum sampler_message_arg
 
 struct brw_blorp_blit_vars {
    /* Input values from brw_blorp_wm_inputs */
-   nir_variable *u_discard_rect;
-   nir_variable *u_rect_grid;
-   nir_variable *u_coord_transform;
-   nir_variable *u_src_z;
+   nir_variable *v_discard_rect;
+   nir_variable *v_rect_grid;
+   nir_variable *v_coord_transform;
+   nir_variable *v_src_z;
 
    /* gl_FragCoord */
    nir_variable *frag_coord;
@@ -351,9 +351,11 @@ brw_blorp_blit_vars_init(nir_builder *b, struct brw_blorp_blit_vars *v,
     assert(!key->use_kill || !(key->blend && key->blit_scaled));
 
 #define LOAD_INPUT(name, type)\
-   v->u_##name = nir_variable_create(b->shader, nir_var_uniform, type, #name); \
-   v->u_##name->data.location = \
-      offsetof(struct brw_blorp_wm_inputs, name);
+   v->v_##name = nir_variable_create(b->shader, nir_var_shader_in, \
+                                     type, #name); \
+   v->v_##name->data.interpolation = INTERP_QUALIFIER_FLAT; \
+   v->v_##name->data.location = VARYING_SLOT_VAR0 + \
+      offsetof(struct brw_blorp_wm_inputs, name) / (4 * sizeof(float));
 
    LOAD_INPUT(discard_rect, glsl_vec4_type())
    LOAD_INPUT(rect_grid, glsl_vec4_type())
@@ -395,7 +397,7 @@ nir_ssa_def *
 blorp_blit_apply_transform(nir_builder *b, nir_ssa_def *src_pos,
                            struct brw_blorp_blit_vars *v)
 {
-   nir_ssa_def *coord_transform = nir_load_var(b, v->u_coord_transform);
+   nir_ssa_def *coord_transform = nir_load_var(b, v->v_coord_transform);
 
    nir_ssa_def *offset = nir_vec2(b, nir_channel(b, coord_transform, 1),
                                      nir_channel(b, coord_transform, 3));
@@ -410,7 +412,7 @@ blorp_nir_discard_if_outside_rect(nir_builder *b, nir_ssa_def *pos,
                                   struct brw_blorp_blit_vars *v)
 {
    nir_ssa_def *c0, *c1, *c2, *c3;
-   nir_ssa_def *discard_rect = nir_load_var(b, v->u_discard_rect);
+   nir_ssa_def *discard_rect = nir_load_var(b, v->v_discard_rect);
    nir_ssa_def *dst_x0 = nir_channel(b, discard_rect, 0);
    nir_ssa_def *dst_x1 = nir_channel(b, discard_rect, 1);
    nir_ssa_def *dst_y0 = nir_channel(b, discard_rect, 2);
@@ -498,7 +500,7 @@ blorp_nir_txf(nir_builder *b, struct brw_blorp_blit_vars *v,
     */
    assert(pos->num_components == 2);
    pos = nir_vec3(b, nir_channel(b, pos, 0), nir_channel(b, pos, 1),
-                     nir_load_var(b, v->u_src_z));
+                     nir_load_var(b, v->v_src_z));
 
    tex->sampler_dim = GLSL_SAMPLER_DIM_3D;
    tex->coord_components = 3;
@@ -1031,7 +1033,7 @@ blorp_nir_manual_blend_bilinear(nir_builder *b, nir_ssa_def *pos,
                                 struct brw_blorp_blit_vars *v)
 {
    nir_ssa_def *pos_xy = nir_channels(b, pos, 0x3);
-   nir_ssa_def *rect_grid = nir_load_var(b, v->u_rect_grid);
+   nir_ssa_def *rect_grid = nir_load_var(b, v->v_rect_grid);
    nir_ssa_def *scale = nir_imm_vec2(b, key->x_scale, key->y_scale);
 
    /* Translate coordinates to lay out the samples in a rectangular  grid
diff --git a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
index 4345ee5..a38ea0c 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_clear.cpp
@@ -67,16 +67,17 @@ brw_blorp_params_get_clear_kernel(struct brw_context *brw,
    nir_builder_init_simple_shader(&b, NULL, MESA_SHADER_FRAGMENT, NULL);
    b.shader->info.name = ralloc_strdup(b.shader, "BLORP-clear");
 
-   nir_variable *u_color = nir_variable_create(b.shader, nir_var_uniform,
-                                               glsl_vec4_type(), "u_color");
-   u_color->data.location = 0;
+   nir_variable *v_color = nir_variable_create(b.shader, nir_var_shader_in,
+                                               glsl_vec4_type(), "v_color");
+   v_color->data.location = VARYING_SLOT_VAR0;
+   v_color->data.interpolation = INTERP_QUALIFIER_FLAT;
 
    nir_variable *frag_color = nir_variable_create(b.shader, nir_var_shader_out,
                                                   glsl_vec4_type(),
                                                   "gl_FragColor");
    frag_color->data.location = FRAG_RESULT_COLOR;
 
-   nir_copy_var(&b, frag_color, u_color);
+   nir_copy_var(&b, frag_color, v_color);
 
    struct brw_wm_prog_key wm_key;
    brw_blorp_init_wm_prog_key(&wm_key);
-- 
2.5.5



More information about the mesa-dev mailing list