From: Ian Romanick <ian.d.roman...@intel.com> This has a few small benefits.
1. Reduces the size (and the tracking size) of the shaders. This should basically undo the text expansion done previously. 2. Reduces the number of _mesa_Uniform* calls from 4 to 2. This means half as much time spent doing redundant validation of parameters, etc. 3. Allows the use of _mesa_Uniform*v. On x64, the non-v path takes the value in a register, stores it on the stack, and calls _mesa_uniform with a pointer to that stack location. A future patch could call _mesa_uniform directly. This patch and the next couple could probably be squashed. I authored them in several steps to make debugging (bisecting) easier and to make reviewing easier. text data bss dec hex filename 5126824 209888 28120 5364832 51dc60 before-64/lib64/i965_dri.so 5126696 209888 28120 5364704 51dbe0 after-64/lib64/i965_dri.so Signed-off-by: Ian Romanick <ian.d.roman...@intel.com> --- src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c | 54 ++++++++++++----------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c index a9fb43a..a48034e 100644 --- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c +++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c @@ -101,10 +101,8 @@ static const struct sampler_and_fetch { /* We can't use an enum for this because of the preprocessor stringify * techinique. */ -#define src_x_scale_loc 0 -#define src_y_scale_loc 1 -#define src_x_off_loc 2 -#define src_y_off_loc 3 +#define src_scale_loc 0 +#define src_off_loc 1 #define dst_x_off_loc 4 #define dst_y_off_loc 5 #define draw_rect_w_loc 6 @@ -130,12 +128,10 @@ static const char *fs_tmpl = "#extension GL_ARB_explicit_attrib_location: require\n" "#extension GL_ARB_explicit_uniform_location: require\n" "%s" - DECLARE_UNIFORM(float, src_x_scale) - DECLARE_UNIFORM(float, src_y_scale) + DECLARE_UNIFORM(vec2, src_scale) /* Top right coordinates of the source rectangle in W-tiled space. */ - DECLARE_UNIFORM(float, src_x_off) - DECLARE_UNIFORM(float, src_y_off) + DECLARE_UNIFORM(vec2, src_off) /* Top right coordinates of the target rectangle in Y-tiled space. */ DECLARE_UNIFORM(float, dst_x_off) @@ -167,8 +163,8 @@ static const char *fs_tmpl = "\n" "void translate_dst_to_src()\n" "{\n" - " txl_coords.x = int(float(txl_coords.x) * src_x_scale + src_x_off);\n" - " txl_coords.y = int(float(txl_coords.y) * src_y_scale + src_y_off);\n" + " txl_coords.x = int(float(txl_coords.x) * src_scale.x + src_off.x);\n" + " txl_coords.y = int(float(txl_coords.y) * src_scale.y + src_off.y);\n" "}\n" "\n" "void translate_y_to_w_tiling()\n" @@ -278,17 +274,17 @@ setup_drawing_rect(const struct blit_dims *dims) * src_x = src_x0 + (dst_x1 -dst_x - 0.5) * scale */ static void -setup_coord_coeff(GLuint multiplier, GLuint offset, - int src_0, int src_1, int dst_0, int dst_1, bool mirror) +calculate_coord_coeff(float *scale, float *offset, + int src_0, int src_1, int dst_0, int dst_1, bool mirror) { - const float scale = ((float)(src_1 - src_0)) / (dst_1 - dst_0); + const float s = ((float)(src_1 - src_0)) / (dst_1 - dst_0); if (mirror) { - _mesa_Uniform1f(multiplier, -scale); - _mesa_Uniform1f(offset, src_0 + (dst_1 - 0.5f) * scale); + *scale = -s; + *offset = src_0 + (dst_1 - 0.5f) * s; } else { - _mesa_Uniform1f(multiplier, scale); - _mesa_Uniform1f(offset, src_0 + (-dst_0 + 0.5f) * scale); + *scale = s; + *offset = src_0 + (-dst_0 + 0.5f) * s; } } @@ -304,15 +300,21 @@ setup_coord_coeff(GLuint multiplier, GLuint offset, static void setup_coord_transform(const struct blit_dims *dims) { - setup_coord_coeff(src_x_scale_loc, - src_x_off_loc, - dims->src_x0, dims->src_x1, dims->dst_x0, dims->dst_x1, - dims->mirror_x); - - setup_coord_coeff(src_y_scale_loc, - src_y_off_loc, - dims->src_y0, dims->src_y1, dims->dst_y0, dims->dst_y1, - dims->mirror_y); + float scale[2]; + float offset[2]; + + calculate_coord_coeff(&scale[0], + &offset[0], + dims->src_x0, dims->src_x1, dims->dst_x0, dims->dst_x1, + dims->mirror_x); + + calculate_coord_coeff(&scale[1], + &offset[1], + dims->src_y0, dims->src_y1, dims->dst_y0, dims->dst_y1, + dims->mirror_y); + + _mesa_Uniform2fv(src_scale_loc, 1, scale); + _mesa_Uniform2fv(src_off_loc, 1, offset); } static void -- 2.5.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev