Beispiel #1
0
static void build_fog( struct tnl_program *p )
{
   struct ureg fog = register_output(p, VARYING_SLOT_FOGC);
   struct ureg input;

   if (p->state->fog_source_is_depth) {

      switch (p->state->fog_distance_mode) {
      case FDM_EYE_RADIAL: /* Z = sqrt(Xe*Xe + Ye*Ye + Ze*Ze) */
	input = get_eye_position(p);
	emit_op2(p, OPCODE_DP3, fog, WRITEMASK_X, input, input);
	emit_op1(p, OPCODE_RSQ, fog, WRITEMASK_X, fog);
	emit_op1(p, OPCODE_RCP, fog, WRITEMASK_X, fog);
	break;
      case FDM_EYE_PLANE: /* Z = Ze */
	input = get_eye_position_z(p);
	emit_op1(p, OPCODE_MOV, fog, WRITEMASK_X, input);
	break;
      case FDM_EYE_PLANE_ABS: /* Z = abs(Ze) */
	input = get_eye_position_z(p);
	emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input);
	break;
      default: assert(0); break; /* can't happen */
      }

   }
   else {
      input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
      emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input);
   }

   emit_op1(p, OPCODE_MOV, fog, WRITEMASK_YZW, get_identity_param(p));
}
Beispiel #2
0
/**
 * Point size attenuation computation.
 */
static void build_atten_pointsize( struct tnl_program *p )
{
   struct ureg eye = get_eye_position_z(p);
   struct ureg state_size = register_param1(p, STATE_POINT_SIZE);
   struct ureg state_attenuation = register_param1(p, STATE_POINT_ATTENUATION);
   struct ureg out = register_output(p, VERT_RESULT_PSIZ);
   struct ureg ut = get_temp(p);

   /* dist = |eyez| */
   emit_op1(p, OPCODE_ABS, ut, WRITEMASK_Y, swizzle1(eye, Z));
   /* p1 + dist * (p2 + dist * p3); */
   emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
		swizzle1(state_attenuation, Z), swizzle1(state_attenuation, Y));
   emit_op3(p, OPCODE_MAD, ut, WRITEMASK_X, swizzle1(ut, Y),
		ut, swizzle1(state_attenuation, X));

   /* 1 / sqrt(factor) */
   emit_op1(p, OPCODE_RSQ, ut, WRITEMASK_X, ut );

#if 0
   /* out = pointSize / sqrt(factor) */
   emit_op2(p, OPCODE_MUL, out, WRITEMASK_X, ut, state_size);
#else
   /* this is a good place to clamp the point size since there's likely
    * no hardware registers to clamp point size at rasterization time.
    */
   emit_op2(p, OPCODE_MUL, ut, WRITEMASK_X, ut, state_size);
   emit_op2(p, OPCODE_MAX, ut, WRITEMASK_X, ut, swizzle1(state_size, Y));
   emit_op2(p, OPCODE_MIN, out, WRITEMASK_X, ut, swizzle1(state_size, Z));
#endif

   release_temp(p, ut);
}
Beispiel #3
0
static void build_fog( struct tnl_program *p )
{
   struct ureg fog = register_output(p, VERT_RESULT_FOGC);
   struct ureg input;

   if (p->state->fog_source_is_depth) {
      input = get_eye_position_z(p);
   }
   else {
      input = swizzle1(register_input(p, VERT_ATTRIB_FOG), X);
   }

   /* result.fog = {abs(f),0,0,1}; */
   emit_op1(p, OPCODE_ABS, fog, WRITEMASK_X, input);
   emit_op1(p, OPCODE_MOV, fog, WRITEMASK_YZW, get_identity_param(p));
}