diff options
Diffstat (limited to 'src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c | 59 |
1 files changed, 32 insertions, 27 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 5b0c2e9bdd5..7e0424846a5 100644 --- a/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c +++ b/src/mesa/drivers/dri/i965/brw_meta_stencil_blit.c @@ -193,6 +193,9 @@ static const char *fs_tmpl = " %s;\n" "}\n"; +#define get_uniform_loc(sh_prog, name) \ + _mesa_program_resource_location(sh_prog, GL_UNIFORM, name) + /** * Setup uniforms telling the coordinates of the destination rectangle in the * native w-tiled space. These are needed to ignore pixels that lie outside. @@ -201,12 +204,13 @@ static const char *fs_tmpl = * 16x2 y-tiled). */ static void -setup_bounding_rect(GLuint prog, const struct blit_dims *dims) +setup_bounding_rect(struct gl_shader_program *sh_prog, + const struct blit_dims *dims) { - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_x0"), dims->dst_x0); - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_x1"), dims->dst_x1); - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_y0"), dims->dst_y0); - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_y1"), dims->dst_y1); + _mesa_Uniform1i(get_uniform_loc(sh_prog, "dst_x0"), dims->dst_x0); + _mesa_Uniform1i(get_uniform_loc(sh_prog, "dst_x1"), dims->dst_x1); + _mesa_Uniform1i(get_uniform_loc(sh_prog, "dst_y0"), dims->dst_y0); + _mesa_Uniform1i(get_uniform_loc(sh_prog, "dst_y1"), dims->dst_y1); } /** @@ -215,14 +219,15 @@ setup_bounding_rect(GLuint prog, const struct blit_dims *dims) * between destination and source that may have differing offsets. */ static void -setup_drawing_rect(GLuint prog, const struct blit_dims *dims) +setup_drawing_rect(struct gl_shader_program *sh_prog, + const struct blit_dims *dims) { - _mesa_Uniform1f(_mesa_GetUniformLocation(prog, "draw_rect_w"), + _mesa_Uniform1f(get_uniform_loc(sh_prog, "draw_rect_w"), dims->dst_x1 - dims->dst_x0); - _mesa_Uniform1f(_mesa_GetUniformLocation(prog, "draw_rect_h"), + _mesa_Uniform1f(get_uniform_loc(sh_prog, "draw_rect_h"), dims->dst_y1 - dims->dst_y0); - _mesa_Uniform1f(_mesa_GetUniformLocation(prog, "dst_x_off"), dims->dst_x0); - _mesa_Uniform1f(_mesa_GetUniformLocation(prog, "dst_y_off"), dims->dst_y0); + _mesa_Uniform1f(get_uniform_loc(sh_prog, "dst_x_off"), dims->dst_x0); + _mesa_Uniform1f(get_uniform_loc(sh_prog, "dst_y_off"), dims->dst_y0); } /** @@ -241,7 +246,7 @@ setup_drawing_rect(GLuint prog, const struct blit_dims *dims) * src_x = src_x0 + (dst_x1 -dst_x - 0.5) * scale */ static void -setup_coord_coeff(GLuint prog, GLuint multiplier, GLuint offset, +setup_coord_coeff(GLuint multiplier, GLuint 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); @@ -265,22 +270,21 @@ setup_coord_coeff(GLuint prog, GLuint multiplier, GLuint offset, * destination rectangle is adjusted for possible msaa and Y-tiling. */ static void -setup_coord_transform(GLuint prog, const struct blit_dims *dims) +setup_coord_transform(struct gl_shader_program *sh_prog, + const struct blit_dims *dims) { - setup_coord_coeff(prog, - _mesa_GetUniformLocation(prog, "src_x_scale"), - _mesa_GetUniformLocation(prog, "src_x_off"), + setup_coord_coeff(get_uniform_loc(sh_prog, "src_x_scale"), + get_uniform_loc(sh_prog, "src_x_off"), dims->src_x0, dims->src_x1, dims->dst_x0, dims->dst_x1, dims->mirror_x); - setup_coord_coeff(prog, - _mesa_GetUniformLocation(prog, "src_y_scale"), - _mesa_GetUniformLocation(prog, "src_y_off"), + setup_coord_coeff(get_uniform_loc(sh_prog, "src_y_scale"), + get_uniform_loc(sh_prog, "src_y_off"), dims->src_y0, dims->src_y1, dims->dst_y0, dims->dst_y1, dims->mirror_y); } -static GLuint +static struct gl_shader_program * setup_program(struct brw_context *brw, bool msaa_tex) { struct gl_context *ctx = &brw->ctx; @@ -291,21 +295,22 @@ setup_program(struct brw_context *brw, bool msaa_tex) _mesa_meta_setup_vertex_objects(&brw->ctx, &blit->VAO, &blit->buf_obj, true, 2, 2, 0); - GLuint *prog_id = &brw->meta_stencil_blit_programs[msaa_tex]; + struct gl_shader_program **sh_prog_p = + &brw->meta_stencil_blit_programs[msaa_tex]; - if (*prog_id) { - _mesa_UseProgram(*prog_id); - return *prog_id; + if (*sh_prog_p) { + _mesa_meta_use_program(ctx, *sh_prog_p); + return *sh_prog_p; } fs_source = ralloc_asprintf(NULL, fs_tmpl, sampler->sampler, sampler->fetch); _mesa_meta_compile_and_link_program(ctx, vs_source, fs_source, "i965 stencil blit", - prog_id); + sh_prog_p); ralloc_free(fs_source); - return *prog_id; + return *sh_prog_p; } /** @@ -425,7 +430,7 @@ brw_meta_stencil_blit(struct brw_context *brw, struct gl_context *ctx = &brw->ctx; struct blit_dims dims = *orig_dims; struct fb_tex_blit_state blit; - GLuint prog; + struct gl_shader_program *prog; struct gl_framebuffer *drawFb = NULL; struct gl_renderbuffer *rb = NULL; GLenum target; @@ -467,7 +472,7 @@ brw_meta_stencil_blit(struct brw_context *brw, setup_drawing_rect(prog, &dims); setup_coord_transform(prog, orig_dims); - _mesa_Uniform1i(_mesa_GetUniformLocation(prog, "dst_num_samples"), + _mesa_Uniform1i(get_uniform_loc(prog, "dst_num_samples"), dst_mt->num_samples); prepare_vertex_data(ctx, ctx->Meta->Blit.buf_obj); |