[Mesa-dev] [PATCH 07/18] i965/blorp: Load tranformation coordinates as vec4

Topi Pohjolainen topi.pohjolainen at intel.com
Thu Jun 23 19:17:03 UTC 2016


In preparation for loading as flat vertex input.

Signed-off-by: Topi Pohjolainen <topi.pohjolainen at intel.com>
---
 src/mesa/drivers/dri/i965/brw_blorp_blit.cpp | 25 +++++++++++++------------
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
index a9eac60..e021d23 100644
--- a/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
+++ b/src/mesa/drivers/dri/i965/brw_blorp_blit.cpp
@@ -333,10 +333,7 @@ struct brw_blorp_blit_vars {
    /* Input values from brw_blorp_wm_inputs */
    nir_variable *u_discard_rect;
    nir_variable *u_rect_grid;
-   struct {
-      nir_variable *multiplier;
-      nir_variable *offset;
-   } u_x_transform, u_y_transform;
+   nir_variable *u_coord_transform;
    nir_variable *u_src_z;
 
    /* gl_FragCoord */
@@ -371,15 +368,17 @@ brw_blorp_blit_vars_init(nir_builder *b, struct brw_blorp_blit_vars *v,
       v->u_discard_rect = NULL;
    }
 
+   v->u_coord_transform = nir_variable_create(b->shader, nir_var_uniform,
+                                              glsl_type::vec4_type,
+                                              "coord_transform");
+   v->u_coord_transform->data.location =
+      offsetof(struct brw_blorp_wm_inputs, x_transform.multiplier);
+
 #define LOAD_UNIFORM(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);
 
-   LOAD_UNIFORM(x_transform.multiplier, glsl_float_type())
-   LOAD_UNIFORM(x_transform.offset, glsl_float_type())
-   LOAD_UNIFORM(y_transform.multiplier, glsl_float_type())
-   LOAD_UNIFORM(y_transform.offset, glsl_float_type())
    LOAD_UNIFORM(src_z, glsl_uint_type())
 
 #undef DECL_UNIFORM
@@ -417,10 +416,12 @@ nir_ssa_def *
 blorp_blit_apply_transform(nir_builder *b, nir_ssa_def *src_pos,
                            struct brw_blorp_blit_vars *v)
 {
-   nir_ssa_def *offset = nir_vec2(b, nir_load_var(b, v->u_x_transform.offset),
-                                     nir_load_var(b, v->u_y_transform.offset));
-   nir_ssa_def *mul = nir_vec2(b, nir_load_var(b, v->u_x_transform.multiplier),
-                                  nir_load_var(b, v->u_y_transform.multiplier));
+   nir_ssa_def *coord_transform = nir_load_var(b, v->u_coord_transform);
+
+   nir_ssa_def *offset = nir_vec2(b, nir_channel(b, coord_transform, 1),
+                                     nir_channel(b, coord_transform, 3));
+   nir_ssa_def *mul = nir_vec2(b, nir_channel(b, coord_transform, 0),
+                                  nir_channel(b, coord_transform, 2));
 
    return nir_ffma(b, src_pos, mul, offset);
 }
-- 
2.5.5



More information about the mesa-dev mailing list