-/**
- * Generate instructions for loading bump map textures.
- */
-static void
-load_texunit_bumpmap( texenv_fragment_program *p, GLuint unit )
-{
- const struct state_key *key = p->state;
- GLuint bumpedUnitNr = key->unit[unit].OptRGB[1].Source - SRC_TEXTURE0;
- ir_rvalue *bump;
- ir_rvalue *texcoord;
- ir_variable *rot_mat_0, *rot_mat_1;
-
- rot_mat_0 = p->shader->symbols->get_variable("gl_BumpRotMatrix0MESA");
- assert(rot_mat_0);
- rot_mat_1 = p->shader->symbols->get_variable("gl_BumpRotMatrix1MESA");
- assert(rot_mat_1);
-
- ir_variable *tc_array = p->shader->symbols->get_variable("gl_TexCoord");
- assert(tc_array);
- texcoord = new(p->mem_ctx) ir_dereference_variable(tc_array);
- ir_rvalue *index = new(p->mem_ctx) ir_constant(bumpedUnitNr);
- texcoord = new(p->mem_ctx) ir_dereference_array(texcoord, index);
- tc_array->data.max_array_access = MAX2(tc_array->data.max_array_access, unit);
-
- load_texenv_source( p, unit + SRC_TEXTURE0, unit );
-
- /* Apply rot matrix and add coords to be available in next phase.
- * dest = Arg1 + (Arg0.xx * rotMat0) + (Arg0.yy * rotMat1)
- * note only 2 coords are affected the rest are left unchanged (mul by 0)
- */
- ir_rvalue *bump_x, *bump_y;
-
- texcoord = smear(p, texcoord);
-
- /* bump_texcoord = texcoord */
- ir_variable *bumped = p->make_temp(texcoord->type, "bump_texcoord");
- p->emit(bumped);
- p->emit(assign(bumped, texcoord));
-
- /* bump_texcoord.xy += arg0.x * rotmat0 + arg0.y * rotmat1 */
- bump = get_source(p, key->unit[unit].OptRGB[0].Source, unit);
- bump_x = mul(swizzle_x(bump), rot_mat_0);
- bump_y = mul(swizzle_y(bump->clone(p->mem_ctx, NULL)), rot_mat_1);
-
- p->emit(assign(bumped, add(swizzle_xy(bumped), add(bump_x, bump_y)),
- WRITEMASK_XY));
-
- p->texcoord_tex[bumpedUnitNr] = bumped;
-}
-