[Mesa-dev] [PATCH 08/22] i965/meta: Store destination offset and scale as a vec2s
Ian Romanick
idr at freedesktop.org
Thu Feb 18 01:58:01 UTC 2016
From: Ian Romanick <ian.d.romanick at 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.
text data bss dec hex filename
5126616 209888 28120 5364624 51db90 before-64/lib64/i965_dri.so
5126552 209888 28120 5364560 51db50 after-64/lib64/i965_dri.so
Signed-off-by: Ian Romanick <ian.d.romanick at intel.com>
---
src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c | 28 +++++++++++------------
1 file changed, 14 insertions(+), 14 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 a48034e..782dda0 100644
--- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
+++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c
@@ -103,10 +103,8 @@ static const struct sampler_and_fetch {
*/
#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
-#define draw_rect_h_loc 7
+#define dst_off_loc 2
+#define draw_rect_loc 3
#define dst_x0_loc 8
#define dst_x1_loc 9
#define dst_y0_loc 10
@@ -134,12 +132,10 @@ static const char *fs_tmpl =
DECLARE_UNIFORM(vec2, src_off)
/* Top right coordinates of the target rectangle in Y-tiled space. */
- DECLARE_UNIFORM(float, dst_x_off)
- DECLARE_UNIFORM(float, dst_y_off)
+ DECLARE_UNIFORM(vec2, dst_off)
/* Unnormalized size of the drawing rectangle in Y-tiled space. */
- DECLARE_UNIFORM(float, draw_rect_w)
- DECLARE_UNIFORM(float, draw_rect_h)
+ DECLARE_UNIFORM(vec2, draw_rect)
/* Bounding rectangle in the W-tiled space that will be used to skip pixels
* lying outside. In some cases the Y-tiled rectangle is larger.
@@ -157,8 +153,8 @@ static const char *fs_tmpl =
"\n"
"void get_unorm_target_coords()\n"
"{\n"
- " txl_coords.x = int(tex_coords.x * draw_rect_w + dst_x_off);\n"
- " txl_coords.y = int(tex_coords.y * draw_rect_h + dst_y_off);\n"
+ " txl_coords.x = int(tex_coords.x * draw_rect.x + dst_off.x);\n"
+ " txl_coords.y = int(tex_coords.y * draw_rect.y + dst_off.y);\n"
"}\n"
"\n"
"void translate_dst_to_src()\n"
@@ -252,10 +248,14 @@ setup_bounding_rect(const struct blit_dims *dims)
static void
setup_drawing_rect(const struct blit_dims *dims)
{
- _mesa_Uniform1f(draw_rect_w_loc, dims->dst_x1 - dims->dst_x0);
- _mesa_Uniform1f(draw_rect_h_loc, dims->dst_y1 - dims->dst_y0);
- _mesa_Uniform1f(dst_x_off_loc, dims->dst_x0);
- _mesa_Uniform1f(dst_y_off_loc, dims->dst_y0);
+ const float offset[2] = { dims->dst_x0, dims->dst_y0 };
+ const float draw_rect[2] = {
+ (float) (dims->dst_x1 - dims->dst_x0),
+ (float) (dims->dst_y1 - dims->dst_y0)
+ };
+
+ _mesa_Uniform2fv(draw_rect_loc, 1, draw_rect);
+ _mesa_Uniform2fv(dst_off_loc, 1, offset);
}
/**
--
2.5.0
More information about the mesa-dev
mailing list