• Home
  • Raw
  • Download

Lines Matching +full:- +full:p

20  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
135 if ((key->varying_vp_inputs & VERT_BIT_COLOR0) && in check_active_shininess()
136 (key->light_color_material_mask & (1 << attr))) in check_active_shininess()
139 if (key->varying_vp_inputs & VERT_BIT_GENERIC(attr)) in check_active_shininess()
142 if (ctx->Light.Material.Attrib[attr][0] != 0.0F) in check_active_shininess()
151 const struct gl_program *fp = ctx->FragmentProgram._Current; in make_state_key()
160 key->need_eye_coords = ctx->_NeedEyeCoords; in make_state_key()
162 key->fragprog_inputs_read = fp->info.inputs_read; in make_state_key()
163 key->varying_vp_inputs = ctx->varying_vp_inputs; in make_state_key()
165 if (ctx->RenderMode == GL_FEEDBACK) { in make_state_key()
167 key->fragprog_inputs_read |= (VARYING_BIT_COL0 | VARYING_BIT_TEX0); in make_state_key()
170 key->separate_specular = (ctx->Light.Model.ColorControl == in make_state_key()
173 if (ctx->Light.Enabled) { in make_state_key()
174 key->light_global_enabled = 1; in make_state_key()
176 if (ctx->Light.Model.LocalViewer) in make_state_key()
177 key->light_local_viewer = 1; in make_state_key()
179 if (ctx->Light.Model.TwoSide) in make_state_key()
180 key->light_twoside = 1; in make_state_key()
182 if (ctx->Light.ColorMaterialEnabled) { in make_state_key()
183 key->light_color_material_mask = ctx->Light._ColorMaterialBitmask; in make_state_key()
186 mask = ctx->Light._EnabledLights; in make_state_key()
189 struct gl_light *light = &ctx->Light.Light[i]; in make_state_key()
191 key->unit[i].light_enabled = 1; in make_state_key()
193 if (light->EyePosition[3] == 0.0F) in make_state_key()
194 key->unit[i].light_eyepos3_is_zero = 1; in make_state_key()
196 if (light->SpotCutoff == 180.0F) in make_state_key()
197 key->unit[i].light_spotcutoff_is_180 = 1; in make_state_key()
199 if (light->ConstantAttenuation != 1.0F || in make_state_key()
200 light->LinearAttenuation != 0.0F || in make_state_key()
201 light->QuadraticAttenuation != 0.0F) in make_state_key()
202 key->unit[i].light_attenuated = 1; in make_state_key()
206 key->material_shininess_is_zero = 0; in make_state_key()
208 else if (key->light_twoside && in make_state_key()
210 key->material_shininess_is_zero = 0; in make_state_key()
213 key->material_shininess_is_zero = 1; in make_state_key()
217 if (ctx->Transform.Normalize) in make_state_key()
218 key->normalize = 1; in make_state_key()
220 if (ctx->Transform.RescaleNormals) in make_state_key()
221 key->rescale_normals = 1; in make_state_key()
223 if (ctx->Fog.FogCoordinateSource == GL_FRAGMENT_DEPTH_EXT) { in make_state_key()
224 key->fog_source_is_depth = 1; in make_state_key()
225 key->fog_distance_mode = translate_fog_distance_mode(ctx->Fog.FogDistanceMode); in make_state_key()
228 if (ctx->Point._Attenuated) in make_state_key()
229 key->point_attenuated = 1; in make_state_key()
231 if (ctx->Array.VAO->VertexAttrib[VERT_ATTRIB_POINT_SIZE].Enabled) in make_state_key()
232 key->point_array = 1; in make_state_key()
234 if (ctx->Texture._TexGenEnabled || in make_state_key()
235 ctx->Texture._TexMatEnabled || in make_state_key()
236 ctx->Texture._MaxEnabledTexImageUnit != -1) in make_state_key()
237 key->texture_enabled_global = 1; in make_state_key()
239 mask = ctx->Texture._EnabledCoordUnits | ctx->Texture._TexGenEnabled in make_state_key()
240 | ctx->Texture._TexMatEnabled | ctx->Point.CoordReplace; in make_state_key()
243 struct gl_texture_unit *texUnit = &ctx->Texture.Unit[i]; in make_state_key()
245 if (texUnit->_Current) in make_state_key()
246 key->unit[i].texunit_really_enabled = 1; in make_state_key()
248 if (ctx->Point.PointSprite) in make_state_key()
249 if (ctx->Point.CoordReplace & (1u << i)) in make_state_key()
250 key->unit[i].coord_replace = 1; in make_state_key()
252 if (ctx->Texture._TexMatEnabled & ENABLE_TEXMAT(i)) in make_state_key()
253 key->unit[i].texmat_enabled = 1; in make_state_key()
255 if (texUnit->TexGenEnabled) { in make_state_key()
256 key->unit[i].texgen_enabled = 1; in make_state_key()
258 key->unit[i].texgen_mode0 = in make_state_key()
259 translate_texgen( texUnit->TexGenEnabled & (1<<0), in make_state_key()
260 texUnit->GenS.Mode ); in make_state_key()
261 key->unit[i].texgen_mode1 = in make_state_key()
262 translate_texgen( texUnit->TexGenEnabled & (1<<1), in make_state_key()
263 texUnit->GenT.Mode ); in make_state_key()
264 key->unit[i].texgen_mode2 = in make_state_key()
265 translate_texgen( texUnit->TexGenEnabled & (1<<2), in make_state_key()
266 texUnit->GenR.Mode ); in make_state_key()
267 key->unit[i].texgen_mode3 = in make_state_key()
268 translate_texgen( texUnit->TexGenEnabled & (1<<3), in make_state_key()
269 texUnit->GenQ.Mode ); in make_state_key()
276 /* Very useful debugging tool - produces annotated listing of
290 * GCC is smart enough to deal with these dword-sized structures in
378 static struct ureg get_temp( struct tnl_program *p ) in get_temp() argument
380 int bit = ffs( ~p->temp_in_use ); in get_temp()
386 if ((GLuint) bit > p->program->arb.NumTemporaries) in get_temp()
387 p->program->arb.NumTemporaries = bit; in get_temp()
389 p->temp_in_use |= 1<<(bit-1); in get_temp()
390 return make_ureg(PROGRAM_TEMPORARY, bit-1); in get_temp()
394 static struct ureg reserve_temp( struct tnl_program *p ) in reserve_temp() argument
396 struct ureg temp = get_temp( p ); in reserve_temp()
397 p->temp_reserved |= 1<<temp.idx; in reserve_temp()
402 static void release_temp( struct tnl_program *p, struct ureg reg ) in release_temp() argument
405 p->temp_in_use &= ~(1<<reg.idx); in release_temp()
406 p->temp_in_use |= p->temp_reserved; /* can't release reserved temps */ in release_temp()
410 static void release_temps( struct tnl_program *p ) in release_temps() argument
412 p->temp_in_use = p->temp_reserved; in release_temps()
416 static struct ureg register_param5(struct tnl_program *p, in register_param5() argument
430 idx = _mesa_add_state_reference(p->program->Parameters, tokens ); in register_param5()
435 #define register_param1(p,s0) register_param5(p,s0,0,0,0,0) argument
436 #define register_param2(p,s0,s1) register_param5(p,s0,s1,0,0,0) argument
437 #define register_param3(p,s0,s1,s2) register_param5(p,s0,s1,s2,0,0) argument
438 #define register_param4(p,s0,s1,s2,s3) register_param5(p,s0,s1,s2,s3,0) argument
445 static struct ureg register_input( struct tnl_program *p, GLuint input ) in register_input() argument
449 if (p->state->varying_vp_inputs & VERT_BIT(input)) { in register_input()
450 p->program->info.inputs_read |= VERT_BIT(input); in register_input()
454 return register_param3( p, STATE_INTERNAL, STATE_CURRENT_ATTRIB, input ); in register_input()
462 static struct ureg register_output( struct tnl_program *p, GLuint output ) in register_output() argument
464 p->program->info.outputs_written |= BITFIELD64_BIT(output); in register_output()
469 static struct ureg register_const4f( struct tnl_program *p, in register_const4f() argument
482 idx = _mesa_add_unnamed_constant(p->program->Parameters, values, 4, in register_const4f()
488 #define register_const1f(p, s0) register_const4f(p, s0, 0, 0, 1) argument
489 #define register_scalar_const(p, s0) register_const4f(p, s0, s0, s0, s0) argument
490 #define register_const2f(p, s0, s1) register_const4f(p, s0, s1, 0, 1) argument
491 #define register_const3f(p, s0, s1, s2) register_const4f(p, s0, s1, s2, 1) argument
499 static struct ureg get_identity_param( struct tnl_program *p ) in get_identity_param() argument
501 if (is_undef(p->identity)) in get_identity_param()
502 p->identity = register_const4f(p, 0,0,0,1); in get_identity_param()
504 return p->identity; in get_identity_param()
507 static void register_matrix_param5( struct tnl_program *p, in register_matrix_param5() argument
520 for (i = 0; i <= s3 - s2; i++) in register_matrix_param5()
521 matrix[i] = register_param5( p, s0, s1, i, i, s4 ); in register_matrix_param5()
528 src->File = reg.file; in emit_arg()
529 src->Index = reg.idx; in emit_arg()
530 src->Swizzle = reg.swz; in emit_arg()
531 src->Negate = reg.negate ? NEGATE_XYZW : NEGATE_NONE; in emit_arg()
532 src->RelAddr = 0; in emit_arg()
534 assert(src->Index == reg.idx); in emit_arg()
541 dst->File = reg.file; in emit_dst()
542 dst->Index = reg.idx; in emit_dst()
544 dst->WriteMask = mask ? mask : WRITEMASK_XYZW; in emit_dst()
546 assert(dst->Index == reg.idx); in emit_dst()
567 static void emit_op3fn(struct tnl_program *p, in emit_op3fn() argument
580 assert(p->program->arb.NumInstructions <= p->max_inst); in emit_op3fn()
582 if (p->program->arb.NumInstructions == p->max_inst) { in emit_op3fn()
587 p->max_inst *= 2; in emit_op3fn()
590 rzalloc_array(p->program, struct prog_instruction, p->max_inst); in emit_op3fn()
596 _mesa_copy_instructions(newInst, p->program->arb.Instructions, in emit_op3fn()
597 p->program->arb.NumInstructions); in emit_op3fn()
599 ralloc_free(p->program->arb.Instructions); in emit_op3fn()
601 p->program->arb.Instructions = newInst; in emit_op3fn()
604 nr = p->program->arb.NumInstructions++; in emit_op3fn()
606 inst = &p->program->arb.Instructions[nr]; in emit_op3fn()
607 inst->Opcode = (enum prog_opcode) op; in emit_op3fn()
609 emit_arg( &inst->SrcReg[0], src0 ); in emit_op3fn()
610 emit_arg( &inst->SrcReg[1], src1 ); in emit_op3fn()
611 emit_arg( &inst->SrcReg[2], src2 ); in emit_op3fn()
613 emit_dst( &inst->DstReg, dest, mask ); in emit_op3fn()
619 #define emit_op3(p, op, dst, mask, src0, src1, src2) \ argument
620 emit_op3fn(p, op, dst, mask, src0, src1, src2, __func__, __LINE__)
622 #define emit_op2(p, op, dst, mask, src0, src1) \ argument
623 emit_op3fn(p, op, dst, mask, src0, src1, undef, __func__, __LINE__)
625 #define emit_op1(p, op, dst, mask, src0) \ argument
626 emit_op3fn(p, op, dst, mask, src0, undef, undef, __func__, __LINE__)
629 static struct ureg make_temp( struct tnl_program *p, struct ureg reg ) in make_temp() argument
632 !(p->temp_reserved & (1<<reg.idx))) in make_temp()
635 struct ureg temp = get_temp(p); in make_temp()
636 emit_op1(p, OPCODE_MOV, temp, 0, reg); in make_temp()
646 static void emit_matrix_transform_vec4( struct tnl_program *p, in emit_matrix_transform_vec4() argument
651 emit_op2(p, OPCODE_DP4, dest, WRITEMASK_X, src, mat[0]); in emit_matrix_transform_vec4()
652 emit_op2(p, OPCODE_DP4, dest, WRITEMASK_Y, src, mat[1]); in emit_matrix_transform_vec4()
653 emit_op2(p, OPCODE_DP4, dest, WRITEMASK_Z, src, mat[2]); in emit_matrix_transform_vec4()
654 emit_op2(p, OPCODE_DP4, dest, WRITEMASK_W, src, mat[3]); in emit_matrix_transform_vec4()
662 static void emit_transpose_matrix_transform_vec4( struct tnl_program *p, in emit_transpose_matrix_transform_vec4() argument
670 tmp = get_temp(p); in emit_transpose_matrix_transform_vec4()
674 emit_op2(p, OPCODE_MUL, tmp, 0, swizzle1(src,X), mat[0]); in emit_transpose_matrix_transform_vec4()
675 emit_op3(p, OPCODE_MAD, tmp, 0, swizzle1(src,Y), mat[1], tmp); in emit_transpose_matrix_transform_vec4()
676 emit_op3(p, OPCODE_MAD, tmp, 0, swizzle1(src,Z), mat[2], tmp); in emit_transpose_matrix_transform_vec4()
677 emit_op3(p, OPCODE_MAD, dest, 0, swizzle1(src,W), mat[3], tmp); in emit_transpose_matrix_transform_vec4()
680 release_temp(p, tmp); in emit_transpose_matrix_transform_vec4()
684 static void emit_matrix_transform_vec3( struct tnl_program *p, in emit_matrix_transform_vec3() argument
689 emit_op2(p, OPCODE_DP3, dest, WRITEMASK_X, src, mat[0]); in emit_matrix_transform_vec3()
690 emit_op2(p, OPCODE_DP3, dest, WRITEMASK_Y, src, mat[1]); in emit_matrix_transform_vec3()
691 emit_op2(p, OPCODE_DP3, dest, WRITEMASK_Z, src, mat[2]); in emit_matrix_transform_vec3()
695 static void emit_normalize_vec3( struct tnl_program *p, in emit_normalize_vec3() argument
699 struct ureg tmp = get_temp(p); in emit_normalize_vec3()
700 emit_op2(p, OPCODE_DP3, tmp, WRITEMASK_X, src, src); in emit_normalize_vec3()
701 emit_op1(p, OPCODE_RSQ, tmp, WRITEMASK_X, tmp); in emit_normalize_vec3()
702 emit_op2(p, OPCODE_MUL, dest, 0, src, swizzle1(tmp, X)); in emit_normalize_vec3()
703 release_temp(p, tmp); in emit_normalize_vec3()
707 static void emit_passthrough( struct tnl_program *p, in emit_passthrough() argument
711 struct ureg out = register_output(p, output); in emit_passthrough()
712 emit_op1(p, OPCODE_MOV, out, 0, register_input(p, input)); in emit_passthrough()
716 static struct ureg get_eye_position( struct tnl_program *p ) in get_eye_position() argument
718 if (is_undef(p->eye_position)) { in get_eye_position()
719 struct ureg pos = register_input( p, VERT_ATTRIB_POS ); in get_eye_position()
722 p->eye_position = reserve_temp(p); in get_eye_position()
724 if (p->mvp_with_dp4) { in get_eye_position()
725 register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, in get_eye_position()
728 emit_matrix_transform_vec4(p, p->eye_position, modelview, pos); in get_eye_position()
731 register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, in get_eye_position()
734 emit_transpose_matrix_transform_vec4(p, p->eye_position, modelview, pos); in get_eye_position()
738 return p->eye_position; in get_eye_position()
742 static struct ureg get_eye_position_z( struct tnl_program *p ) in get_eye_position_z() argument
744 if (!is_undef(p->eye_position)) in get_eye_position_z()
745 return swizzle1(p->eye_position, Z); in get_eye_position_z()
747 if (is_undef(p->eye_position_z)) { in get_eye_position_z()
748 struct ureg pos = register_input( p, VERT_ATTRIB_POS ); in get_eye_position_z()
751 p->eye_position_z = reserve_temp(p); in get_eye_position_z()
753 register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 3, in get_eye_position_z()
756 emit_op2(p, OPCODE_DP4, p->eye_position_z, 0, pos, modelview[2]); in get_eye_position_z()
759 return p->eye_position_z; in get_eye_position_z()
763 static struct ureg get_eye_position_normalized( struct tnl_program *p ) in get_eye_position_normalized() argument
765 if (is_undef(p->eye_position_normalized)) { in get_eye_position_normalized()
766 struct ureg eye = get_eye_position(p); in get_eye_position_normalized()
767 p->eye_position_normalized = reserve_temp(p); in get_eye_position_normalized()
768 emit_normalize_vec3(p, p->eye_position_normalized, eye); in get_eye_position_normalized()
771 return p->eye_position_normalized; in get_eye_position_normalized()
775 static struct ureg get_transformed_normal( struct tnl_program *p ) in get_transformed_normal() argument
777 if (is_undef(p->transformed_normal) && in get_transformed_normal()
778 !p->state->need_eye_coords && in get_transformed_normal()
779 !p->state->normalize && in get_transformed_normal()
780 !(p->state->need_eye_coords == p->state->rescale_normals)) in get_transformed_normal()
782 p->transformed_normal = register_input(p, VERT_ATTRIB_NORMAL ); in get_transformed_normal()
784 else if (is_undef(p->transformed_normal)) in get_transformed_normal()
786 struct ureg normal = register_input(p, VERT_ATTRIB_NORMAL ); in get_transformed_normal()
788 struct ureg transformed_normal = reserve_temp(p); in get_transformed_normal()
790 if (p->state->need_eye_coords) { in get_transformed_normal()
791 register_matrix_param5( p, STATE_MODELVIEW_MATRIX, 0, 0, 2, in get_transformed_normal()
796 emit_matrix_transform_vec3( p, transformed_normal, mvinv, normal ); in get_transformed_normal()
802 if (p->state->normalize) { in get_transformed_normal()
803 emit_normalize_vec3( p, transformed_normal, normal ); in get_transformed_normal()
806 else if (p->state->need_eye_coords == p->state->rescale_normals) { in get_transformed_normal()
807 /* This is already adjusted for eye/non-eye rendering: in get_transformed_normal()
809 struct ureg rescale = register_param2(p, STATE_INTERNAL, in get_transformed_normal()
812 emit_op2( p, OPCODE_MUL, transformed_normal, 0, normal, rescale ); in get_transformed_normal()
817 p->transformed_normal = normal; in get_transformed_normal()
820 return p->transformed_normal; in get_transformed_normal()
824 static void build_hpos( struct tnl_program *p ) in build_hpos() argument
826 struct ureg pos = register_input( p, VERT_ATTRIB_POS ); in build_hpos()
827 struct ureg hpos = register_output( p, VARYING_SLOT_POS ); in build_hpos()
830 if (p->mvp_with_dp4) { in build_hpos()
831 register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, in build_hpos()
833 emit_matrix_transform_vec4( p, hpos, mvp, pos ); in build_hpos()
836 register_matrix_param5( p, STATE_MVP_MATRIX, 0, 0, 3, in build_hpos()
838 emit_transpose_matrix_transform_vec4( p, hpos, mvp, pos ); in build_hpos()
845 return (property - STATE_AMBIENT) * 2 + side; in material_attrib()
850 * Get a bitmask of which material values vary on a per-vertex basis.
852 static void set_material_flags( struct tnl_program *p ) in set_material_flags() argument
854 p->color_materials = 0; in set_material_flags()
855 p->materials = 0; in set_material_flags()
857 if (p->state->varying_vp_inputs & VERT_BIT_COLOR0) { in set_material_flags()
858 p->materials = in set_material_flags()
859 p->color_materials = p->state->light_color_material_mask; in set_material_flags()
862 p->materials |= (p->state->varying_vp_inputs >> VERT_ATTRIB_GENERIC0); in set_material_flags()
866 static struct ureg get_material( struct tnl_program *p, GLuint side, in get_material() argument
871 if (p->color_materials & (1<<attrib)) in get_material()
872 return register_input(p, VERT_ATTRIB_COLOR0); in get_material()
873 else if (p->materials & (1<<attrib)) { in get_material()
874 /* Put material values in the GENERIC slots -- they are not used in get_material()
877 return register_input( p, attrib + VERT_ATTRIB_GENERIC0 ); in get_material()
880 return register_param3( p, STATE_MATERIAL, side, property ); in get_material()
893 * Probably want to shift this to the program compilation phase - if
899 static struct ureg get_scenecolor( struct tnl_program *p, GLuint side ) in get_scenecolor() argument
901 if (p->materials & SCENE_COLOR_BITS(side)) { in get_scenecolor()
902 struct ureg lm_ambient = register_param1(p, STATE_LIGHTMODEL_AMBIENT); in get_scenecolor()
903 struct ureg material_emission = get_material(p, side, STATE_EMISSION); in get_scenecolor()
904 struct ureg material_ambient = get_material(p, side, STATE_AMBIENT); in get_scenecolor()
905 struct ureg material_diffuse = get_material(p, side, STATE_DIFFUSE); in get_scenecolor()
906 struct ureg tmp = make_temp(p, material_diffuse); in get_scenecolor()
907 emit_op3(p, OPCODE_MAD, tmp, WRITEMASK_XYZ, lm_ambient, in get_scenecolor()
912 return register_param2( p, STATE_LIGHTMODEL_SCENECOLOR, side ); in get_scenecolor()
916 static struct ureg get_lightprod( struct tnl_program *p, GLuint light, in get_lightprod() argument
920 if (p->materials & (1<<attrib)) { in get_lightprod()
922 register_param3(p, STATE_LIGHT, light, property); in get_lightprod()
923 struct ureg material_value = get_material(p, side, property); in get_lightprod()
924 struct ureg tmp = get_temp(p); in get_lightprod()
925 emit_op2(p, OPCODE_MUL, tmp, 0, light_value, material_value); in get_lightprod()
929 return register_param4(p, STATE_LIGHTPROD, light, side, property); in get_lightprod()
933 static struct ureg calculate_light_attenuation( struct tnl_program *p, in calculate_light_attenuation() argument
938 struct ureg attenuation = register_param3(p, STATE_LIGHT, i, in calculate_light_attenuation()
944 if (!p->state->unit[i].light_spotcutoff_is_180) { in calculate_light_attenuation()
945 struct ureg spot_dir_norm = register_param3(p, STATE_INTERNAL, in calculate_light_attenuation()
947 struct ureg spot = get_temp(p); in calculate_light_attenuation()
948 struct ureg slt = get_temp(p); in calculate_light_attenuation()
950 att = get_temp(p); in calculate_light_attenuation()
952 emit_op2(p, OPCODE_DP3, spot, 0, negate(VPpli), spot_dir_norm); in calculate_light_attenuation()
953 emit_op2(p, OPCODE_SLT, slt, 0, swizzle1(spot_dir_norm,W), spot); in calculate_light_attenuation()
954 emit_op1(p, OPCODE_ABS, spot, 0, spot); in calculate_light_attenuation()
955 emit_op2(p, OPCODE_POW, spot, 0, spot, swizzle1(attenuation, W)); in calculate_light_attenuation()
956 emit_op2(p, OPCODE_MUL, att, 0, slt, spot); in calculate_light_attenuation()
958 release_temp(p, spot); in calculate_light_attenuation()
959 release_temp(p, slt); in calculate_light_attenuation()
966 if (p->state->unit[i].light_attenuated && !is_undef(dist)) { in calculate_light_attenuation()
968 att = get_temp(p); in calculate_light_attenuation()
970 emit_op1(p, OPCODE_RCP, dist, WRITEMASK_YZ, dist); in calculate_light_attenuation()
972 emit_op2(p, OPCODE_MUL, dist, WRITEMASK_XZ, dist, swizzle1(dist,Y)); in calculate_light_attenuation()
973 /* 1/dist-atten */ in calculate_light_attenuation()
974 emit_op2(p, OPCODE_DP3, dist, 0, attenuation, dist); in calculate_light_attenuation()
976 if (!p->state->unit[i].light_spotcutoff_is_180) { in calculate_light_attenuation()
977 /* dist-atten */ in calculate_light_attenuation()
978 emit_op1(p, OPCODE_RCP, dist, 0, dist); in calculate_light_attenuation()
979 /* spot-atten * dist-atten */ in calculate_light_attenuation()
980 emit_op2(p, OPCODE_MUL, att, 0, dist, att); in calculate_light_attenuation()
983 /* dist-atten */ in calculate_light_attenuation()
984 emit_op1(p, OPCODE_RCP, att, 0, dist); in calculate_light_attenuation()
997 static void emit_degenerate_lit( struct tnl_program *p, in emit_degenerate_lit() argument
1001 struct ureg id = get_identity_param(p); /* id = {0,0,0,1} */ in emit_degenerate_lit()
1009 emit_op2(p, OPCODE_MAX, lit, WRITEMASK_XYZW, id, dots); in emit_degenerate_lit()
1014 emit_op2(p, OPCODE_SLT, lit, WRITEMASK_Z, swizzle1(id,Z), dots); in emit_degenerate_lit()
1019 * space - STATE_SPOT_DIRECTION and STATE_HALF_VECTOR implicitly assume eye
1022 static void build_lighting( struct tnl_program *p ) in build_lighting() argument
1024 const GLboolean twoside = p->state->light_twoside; in build_lighting()
1025 const GLboolean separate = p->state->separate_specular; in build_lighting()
1027 struct ureg normal = get_transformed_normal(p); in build_lighting()
1028 struct ureg lit = get_temp(p); in build_lighting()
1029 struct ureg dots = get_temp(p); in build_lighting()
1043 if (p->state->unit[i].light_enabled) in build_lighting()
1046 set_material_flags(p); in build_lighting()
1049 if (!p->state->material_shininess_is_zero) { in build_lighting()
1050 struct ureg shininess = get_material(p, 0, STATE_SHININESS); in build_lighting()
1051 emit_op1(p, OPCODE_MOV, dots, WRITEMASK_W, swizzle1(shininess,X)); in build_lighting()
1052 release_temp(p, shininess); in build_lighting()
1055 _col0 = make_temp(p, get_scenecolor(p, 0)); in build_lighting()
1057 _col1 = make_temp(p, get_identity_param(p)); in build_lighting()
1063 if (!p->state->material_shininess_is_zero) { in build_lighting()
1064 /* Note that we negate the back-face specular exponent here. in build_lighting()
1065 * The negation will be un-done later in the back-face code below. in build_lighting()
1067 struct ureg shininess = get_material(p, 1, STATE_SHININESS); in build_lighting()
1068 emit_op1(p, OPCODE_MOV, dots, WRITEMASK_Z, in build_lighting()
1070 release_temp(p, shininess); in build_lighting()
1073 _bfc0 = make_temp(p, get_scenecolor(p, 1)); in build_lighting()
1075 _bfc1 = make_temp(p, get_identity_param(p)); in build_lighting()
1083 struct ureg res0 = register_output( p, VARYING_SLOT_COL0 ); in build_lighting()
1084 emit_op1(p, OPCODE_MOV, res0, 0, _col0); in build_lighting()
1088 struct ureg res1 = register_output( p, VARYING_SLOT_COL1 ); in build_lighting()
1089 emit_op1(p, OPCODE_MOV, res1, 0, _col1); in build_lighting()
1093 struct ureg res0 = register_output( p, VARYING_SLOT_BFC0 ); in build_lighting()
1094 emit_op1(p, OPCODE_MOV, res0, 0, _bfc0); in build_lighting()
1098 struct ureg res1 = register_output( p, VARYING_SLOT_BFC1 ); in build_lighting()
1099 emit_op1(p, OPCODE_MOV, res1, 0, _bfc1); in build_lighting()
1103 release_temps(p); in build_lighting()
1108 if (p->state->unit[i].light_enabled) { in build_lighting()
1114 if (p->state->unit[i].light_eyepos3_is_zero) { in build_lighting()
1115 VPpli = register_param3(p, STATE_INTERNAL, in build_lighting()
1118 struct ureg Ppli = register_param3(p, STATE_INTERNAL, in build_lighting()
1120 struct ureg V = get_eye_position(p); in build_lighting()
1122 VPpli = get_temp(p); in build_lighting()
1123 dist = get_temp(p); in build_lighting()
1127 emit_op2(p, OPCODE_SUB, VPpli, 0, Ppli, V); in build_lighting()
1132 emit_op2(p, OPCODE_DP3, dist, 0, VPpli, VPpli); in build_lighting()
1133 emit_op1(p, OPCODE_RSQ, dist, 0, dist); in build_lighting()
1134 emit_op2(p, OPCODE_MUL, VPpli, 0, VPpli, dist); in build_lighting()
1139 att = calculate_light_attenuation(p, i, VPpli, dist); in build_lighting()
1140 release_temp(p, dist); in build_lighting()
1144 if (!p->state->material_shininess_is_zero) { in build_lighting()
1145 if (p->state->light_local_viewer) { in build_lighting()
1146 struct ureg eye_hat = get_eye_position_normalized(p); in build_lighting()
1147 half = get_temp(p); in build_lighting()
1148 emit_op2(p, OPCODE_SUB, half, 0, VPpli, eye_hat); in build_lighting()
1149 emit_normalize_vec3(p, half, half); in build_lighting()
1150 } else if (p->state->unit[i].light_eyepos3_is_zero) { in build_lighting()
1151 half = register_param3(p, STATE_INTERNAL, in build_lighting()
1154 struct ureg z_dir = swizzle(get_identity_param(p),X,Y,W,Z); in build_lighting()
1155 half = get_temp(p); in build_lighting()
1156 emit_op2(p, OPCODE_ADD, half, 0, VPpli, z_dir); in build_lighting()
1157 emit_normalize_vec3(p, half, half); in build_lighting()
1163 if (p->state->material_shininess_is_zero) { in build_lighting()
1164 emit_op2(p, OPCODE_DP3, dots, 0, normal, VPpli); in build_lighting()
1167 emit_op2(p, OPCODE_DP3, dots, WRITEMASK_X, normal, VPpli); in build_lighting()
1168 emit_op2(p, OPCODE_DP3, dots, WRITEMASK_Y, normal, half); in build_lighting()
1174 struct ureg ambient = get_lightprod(p, i, 0, STATE_AMBIENT); in build_lighting()
1175 struct ureg diffuse = get_lightprod(p, i, 0, STATE_DIFFUSE); in build_lighting()
1176 struct ureg specular = get_lightprod(p, i, 0, STATE_SPECULAR); in build_lighting()
1184 res0 = register_output( p, VARYING_SLOT_COL0 ); in build_lighting()
1185 res1 = register_output( p, VARYING_SLOT_COL1 ); in build_lighting()
1191 res1 = register_output( p, VARYING_SLOT_COL0 ); in build_lighting()
1203 emit_op1(p, OPCODE_LIT, lit, 0, dots); in build_lighting()
1204 emit_op2(p, OPCODE_MUL, lit, 0, lit, att); in build_lighting()
1205 emit_op3(p, OPCODE_MAD, _col0, 0, swizzle1(lit,X), ambient, _col0); in build_lighting()
1207 else if (!p->state->material_shininess_is_zero) { in build_lighting()
1208 /* there's a non-zero specular term */ in build_lighting()
1209 emit_op1(p, OPCODE_LIT, lit, 0, dots); in build_lighting()
1210 emit_op2(p, OPCODE_ADD, _col0, 0, ambient, _col0); in build_lighting()
1214 emit_degenerate_lit(p, lit, dots); in build_lighting()
1215 emit_op2(p, OPCODE_ADD, _col0, 0, ambient, _col0); in build_lighting()
1218 emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _col0); in build_lighting()
1219 emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _col1); in build_lighting()
1221 release_temp(p, ambient); in build_lighting()
1222 release_temp(p, diffuse); in build_lighting()
1223 release_temp(p, specular); in build_lighting()
1229 struct ureg ambient = get_lightprod(p, i, 1, STATE_AMBIENT); in build_lighting()
1230 struct ureg diffuse = get_lightprod(p, i, 1, STATE_DIFFUSE); in build_lighting()
1231 struct ureg specular = get_lightprod(p, i, 1, STATE_SPECULAR); in build_lighting()
1239 res0 = register_output( p, VARYING_SLOT_BFC0 ); in build_lighting()
1240 res1 = register_output( p, VARYING_SLOT_BFC1 ); in build_lighting()
1246 res1 = register_output( p, VARYING_SLOT_BFC0 ); in build_lighting()
1257 * dot products. dots.Z has the negated back-face specular in build_lighting()
1259 * negation makes the back-face specular term positive again. in build_lighting()
1264 emit_op1(p, OPCODE_LIT, lit, 0, dots); in build_lighting()
1265 emit_op2(p, OPCODE_MUL, lit, 0, lit, att); in build_lighting()
1266 emit_op3(p, OPCODE_MAD, _bfc0, 0, swizzle1(lit,X), ambient, _bfc0); in build_lighting()
1268 else if (!p->state->material_shininess_is_zero) { in build_lighting()
1269 emit_op1(p, OPCODE_LIT, lit, 0, dots); in build_lighting()
1270 emit_op2(p, OPCODE_ADD, _bfc0, 0, ambient, _bfc0); /**/ in build_lighting()
1273 emit_degenerate_lit(p, lit, dots); in build_lighting()
1274 emit_op2(p, OPCODE_ADD, _bfc0, 0, ambient, _bfc0); in build_lighting()
1277 emit_op3(p, OPCODE_MAD, res0, mask0, swizzle1(lit,Y), diffuse, _bfc0); in build_lighting()
1278 emit_op3(p, OPCODE_MAD, res1, mask1, swizzle1(lit,Z), specular, _bfc1); in build_lighting()
1284 release_temp(p, ambient); in build_lighting()
1285 release_temp(p, diffuse); in build_lighting()
1286 release_temp(p, specular); in build_lighting()
1289 release_temp(p, half); in build_lighting()
1290 release_temp(p, VPpli); in build_lighting()
1291 release_temp(p, att); in build_lighting()
1295 release_temps( p ); in build_lighting()
1299 static void build_fog( struct tnl_program *p ) in build_fog() argument
1301 struct ureg fog = register_output(p, VARYING_SLOT_FOGC); in build_fog()
1304 if (p->state->fog_source_is_depth) { in build_fog()
1306 switch (p->state->fog_distance_mode) { in build_fog()
1308 input = get_eye_position(p); in build_fog()
1309 emit_op2(p, OPCODE_DP3, fog, WRITEMASK_X, input, input); in build_fog()
1310 emit_op1(p, OPCODE_RSQ, fog, WRITEMASK_X, fog); in build_fog()
1311 emit_op1(p, OPCODE_RCP, fog, WRITEMASK_X, fog); in build_fog()
1314 input = get_eye_position_z(p); in build_fog()
1315 emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input); in build_fog()
1318 input = get_eye_position_z(p); in build_fog()
1319 emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input); in build_fog()
1328 input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X); in build_fog()
1329 emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input); in build_fog()
1332 emit_op1(p, OPCODE_MOV, fog, WRITEMASK_YZW, get_identity_param(p)); in build_fog()
1336 static void build_reflect_texgen( struct tnl_program *p, in build_reflect_texgen() argument
1340 struct ureg normal = get_transformed_normal(p); in build_reflect_texgen()
1341 struct ureg eye_hat = get_eye_position_normalized(p); in build_reflect_texgen()
1342 struct ureg tmp = get_temp(p); in build_reflect_texgen()
1345 emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); in build_reflect_texgen()
1347 emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); in build_reflect_texgen()
1348 /* (-2n.u)n + u */ in build_reflect_texgen()
1349 emit_op3(p, OPCODE_MAD, dest, writemask, negate(tmp), normal, eye_hat); in build_reflect_texgen()
1351 release_temp(p, tmp); in build_reflect_texgen()
1355 static void build_sphere_texgen( struct tnl_program *p, in build_sphere_texgen() argument
1359 struct ureg normal = get_transformed_normal(p); in build_sphere_texgen()
1360 struct ureg eye_hat = get_eye_position_normalized(p); in build_sphere_texgen()
1361 struct ureg tmp = get_temp(p); in build_sphere_texgen()
1362 struct ureg half = register_scalar_const(p, .5); in build_sphere_texgen()
1363 struct ureg r = get_temp(p); in build_sphere_texgen()
1364 struct ureg inv_m = get_temp(p); in build_sphere_texgen()
1365 struct ureg id = get_identity_param(p); in build_sphere_texgen()
1370 * components. Of course - if two texture units enable in build_sphere_texgen()
1376 emit_op2(p, OPCODE_DP3, tmp, 0, normal, eye_hat); in build_sphere_texgen()
1378 emit_op2(p, OPCODE_ADD, tmp, 0, tmp, tmp); in build_sphere_texgen()
1379 /* (-2n.u)n + u */ in build_sphere_texgen()
1380 emit_op3(p, OPCODE_MAD, r, 0, negate(tmp), normal, eye_hat); in build_sphere_texgen()
1382 emit_op2(p, OPCODE_ADD, tmp, 0, r, swizzle(id,X,Y,W,Z)); in build_sphere_texgen()
1384 emit_op2(p, OPCODE_DP3, tmp, 0, tmp, tmp); in build_sphere_texgen()
1386 emit_op1(p, OPCODE_RSQ, tmp, 0, tmp); in build_sphere_texgen()
1388 emit_op2(p, OPCODE_MUL, inv_m, 0, tmp, half); in build_sphere_texgen()
1390 emit_op3(p, OPCODE_MAD, dest, writemask, r, inv_m, half); in build_sphere_texgen()
1392 release_temp(p, tmp); in build_sphere_texgen()
1393 release_temp(p, r); in build_sphere_texgen()
1394 release_temp(p, inv_m); in build_sphere_texgen()
1398 static void build_texture_transform( struct tnl_program *p ) in build_texture_transform() argument
1404 if (!(p->state->fragprog_inputs_read & VARYING_BIT_TEX(i))) in build_texture_transform()
1407 if (p->state->unit[i].coord_replace) in build_texture_transform()
1410 if (p->state->unit[i].texgen_enabled || in build_texture_transform()
1411 p->state->unit[i].texmat_enabled) { in build_texture_transform()
1413 GLuint texmat_enabled = p->state->unit[i].texmat_enabled; in build_texture_transform()
1414 struct ureg out = register_output(p, VARYING_SLOT_TEX0 + i); in build_texture_transform()
1417 if (p->state->unit[i].texgen_enabled) { in build_texture_transform()
1425 out_texgen = get_temp(p); in build_texture_transform()
1429 modes[0] = p->state->unit[i].texgen_mode0; in build_texture_transform()
1430 modes[1] = p->state->unit[i].texgen_mode1; in build_texture_transform()
1431 modes[2] = p->state->unit[i].texgen_mode2; in build_texture_transform()
1432 modes[3] = p->state->unit[i].texgen_mode3; in build_texture_transform()
1437 struct ureg obj = register_input(p, VERT_ATTRIB_POS); in build_texture_transform()
1439 register_param3(p, STATE_TEXGEN, i, in build_texture_transform()
1442 emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, in build_texture_transform()
1447 struct ureg eye = get_eye_position(p); in build_texture_transform()
1449 register_param3(p, STATE_TEXGEN, i, in build_texture_transform()
1452 emit_op2(p, OPCODE_DP4, out_texgen, WRITEMASK_X << j, in build_texture_transform()
1471 build_sphere_texgen(p, out_texgen, sphere_mask); in build_texture_transform()
1475 build_reflect_texgen(p, out_texgen, reflect_mask); in build_texture_transform()
1479 struct ureg normal = get_transformed_normal(p); in build_texture_transform()
1480 emit_op1(p, OPCODE_MOV, out_texgen, normal_mask, normal ); in build_texture_transform()
1484 struct ureg in = register_input(p, VERT_ATTRIB_TEX0+i); in build_texture_transform()
1485 emit_op1(p, OPCODE_MOV, out_texgen, copy_mask, in ); in build_texture_transform()
1493 register_input(p, VERT_ATTRIB_TEX0+i)); in build_texture_transform()
1494 if (p->mvp_with_dp4) { in build_texture_transform()
1495 register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, in build_texture_transform()
1497 emit_matrix_transform_vec4( p, out, texmat, in ); in build_texture_transform()
1500 register_matrix_param5( p, STATE_TEXTURE_MATRIX, i, 0, 3, in build_texture_transform()
1502 emit_transpose_matrix_transform_vec4( p, out, texmat, in ); in build_texture_transform()
1506 release_temps(p); in build_texture_transform()
1509 emit_passthrough(p, VERT_ATTRIB_TEX0+i, VARYING_SLOT_TEX0+i); in build_texture_transform()
1518 static void build_atten_pointsize( struct tnl_program *p ) in build_atten_pointsize() argument
1520 struct ureg eye = get_eye_position_z(p); in build_atten_pointsize()
1521 struct ureg state_size = register_param2(p, STATE_INTERNAL, STATE_POINT_SIZE_CLAMPED); in build_atten_pointsize()
1522 struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION); in build_atten_pointsize()
1523 struct ureg out = register_output(p, VARYING_SLOT_PSIZ); in build_atten_pointsize()
1524 struct ureg ut = get_temp(p); in build_atten_pointsize()
1527 emit_op1(p, OPCODE_ABS, ut, WRITEMASK_Y, swizzle1(eye, Z)); in build_atten_pointsize()
1529 emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y), in build_atten_pointsize()
1531 emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y), in build_atten_pointsize()
1535 emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut ); in build_atten_pointsize()
1539 emit_op2(p, OPCODE_MUL, out, WRITEMASK_X, ut, state_size); in build_atten_pointsize()
1544 emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size); in build_atten_pointsize()
1545 emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y)); in build_atten_pointsize()
1546 emit_op2(p, OPCODE_MIN, out, WRITEMASK_X, ut, swizzle1(state_size, Z)); in build_atten_pointsize()
1549 release_temp(p, ut); in build_atten_pointsize()
1554 * Pass-though per-vertex point size, from user's point size array.
1556 static void build_array_pointsize( struct tnl_program *p ) in build_array_pointsize() argument
1558 struct ureg in = register_input(p, VERT_ATTRIB_POINT_SIZE); in build_array_pointsize()
1559 struct ureg out = register_output(p, VARYING_SLOT_PSIZ); in build_array_pointsize()
1560 emit_op1(p, OPCODE_MOV, out, WRITEMASK_X, in); in build_array_pointsize()
1564 static void build_tnl_program( struct tnl_program *p ) in build_tnl_program() argument
1568 build_hpos(p); in build_tnl_program()
1572 if (p->state->fragprog_inputs_read & (VARYING_BIT_COL0|VARYING_BIT_COL1)) { in build_tnl_program()
1573 if (p->state->light_global_enabled) in build_tnl_program()
1574 build_lighting(p); in build_tnl_program()
1576 if (p->state->fragprog_inputs_read & VARYING_BIT_COL0) in build_tnl_program()
1577 emit_passthrough(p, VERT_ATTRIB_COLOR0, VARYING_SLOT_COL0); in build_tnl_program()
1579 if (p->state->fragprog_inputs_read & VARYING_BIT_COL1) in build_tnl_program()
1580 emit_passthrough(p, VERT_ATTRIB_COLOR1, VARYING_SLOT_COL1); in build_tnl_program()
1584 if (p->state->fragprog_inputs_read & VARYING_BIT_FOGC) in build_tnl_program()
1585 build_fog(p); in build_tnl_program()
1587 if (p->state->fragprog_inputs_read & VARYING_BITS_TEX_ANY) in build_tnl_program()
1588 build_texture_transform(p); in build_tnl_program()
1590 if (p->state->point_attenuated) in build_tnl_program()
1591 build_atten_pointsize(p); in build_tnl_program()
1592 else if (p->state->point_array) in build_tnl_program()
1593 build_array_pointsize(p); in build_tnl_program()
1597 emit_op1(p, OPCODE_END, undef, 0, undef); in build_tnl_program()
1613 struct tnl_program p; in create_new_program() local
1615 memset(&p, 0, sizeof(p)); in create_new_program()
1616 p.state = key; in create_new_program()
1617 p.program = program; in create_new_program()
1618 p.eye_position = undef; in create_new_program()
1619 p.eye_position_z = undef; in create_new_program()
1620 p.eye_position_normalized = undef; in create_new_program()
1621 p.transformed_normal = undef; in create_new_program()
1622 p.identity = undef; in create_new_program()
1623 p.temp_in_use = 0; in create_new_program()
1624 p.mvp_with_dp4 = mvp_with_dp4; in create_new_program()
1627 p.temp_reserved = 0; in create_new_program()
1629 p.temp_reserved = ~((1<<max_temps)-1); in create_new_program()
1634 p.max_inst = 32; in create_new_program()
1635 p.program->arb.Instructions = in create_new_program()
1636 rzalloc_array(program, struct prog_instruction, p.max_inst); in create_new_program()
1637 p.program->String = NULL; in create_new_program()
1638 p.program->arb.NumInstructions = in create_new_program()
1639 p.program->arb.NumTemporaries = in create_new_program()
1640 p.program->arb.NumParameters = in create_new_program()
1641 p.program->arb.NumAttributes = p.program->arb.NumAddressRegs = 0; in create_new_program()
1642 p.program->Parameters = _mesa_new_parameter_list(); in create_new_program()
1643 p.program->info.inputs_read = 0; in create_new_program()
1644 p.program->info.outputs_written = 0; in create_new_program()
1646 build_tnl_program( &p ); in create_new_program()
1651 * Return a vertex program which implements the current fixed-function
1664 /* Look for an already-prepared program for this state: in _mesa_get_fixed_func_vertex_program()
1666 prog = _mesa_search_program_cache(ctx->VertexProgram.Cache, &key, in _mesa_get_fixed_func_vertex_program()
1674 prog = ctx->Driver.NewProgram(ctx, GL_VERTEX_PROGRAM_ARB, 0, true); in _mesa_get_fixed_func_vertex_program()
1679 ctx->Const.ShaderCompilerOptions[MESA_SHADER_VERTEX].OptimizeForAOS, in _mesa_get_fixed_func_vertex_program()
1680 ctx->Const.Program[MESA_SHADER_VERTEX].MaxTemps ); in _mesa_get_fixed_func_vertex_program()
1682 if (ctx->Driver.ProgramStringNotify) in _mesa_get_fixed_func_vertex_program()
1683 ctx->Driver.ProgramStringNotify(ctx, GL_VERTEX_PROGRAM_ARB, prog); in _mesa_get_fixed_func_vertex_program()
1685 _mesa_program_cache_insert(ctx, ctx->VertexProgram.Cache, &key, in _mesa_get_fixed_func_vertex_program()