コード例 #1
0
ファイル: prog_parameter.c プロジェクト: RAOF/mesa
/**
 * Add a new state reference to the parameter list.
 * This will be used when the program contains something like this:
 *    PARAM ambient = state.material.front.ambient;
 *
 * \param paramList  the parameter list
 * \param stateTokens  an array of 5 (STATE_LENGTH) state tokens
 * \return index of the new parameter.
 */
GLint
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
                          const gl_state_index stateTokens[STATE_LENGTH])
{
   const GLuint size = 4; /* XXX fix */
   char *name;
   GLint index;

   /* Check if the state reference is already in the list */
   for (index = 0; index < (GLint) paramList->NumParameters; index++) {
      if (!memcmp(paramList->Parameters[index].StateIndexes,
		  stateTokens, STATE_LENGTH * sizeof(gl_state_index))) {
	 return index;
      }
   }

   name = _mesa_program_state_string(stateTokens);
   index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
                               size, GL_NONE,
                               NULL, (gl_state_index *) stateTokens);
   paramList->StateFlags |= _mesa_program_state_flags(stateTokens);

   /* free name string here since we duplicated it in add_parameter() */
   free(name);

   return index;
}
コード例 #2
0
GLint
_mesa_add_sized_state_reference(struct gl_program_parameter_list *paramList,
                                const gl_state_index16 stateTokens[STATE_LENGTH],
                                const unsigned size, bool pad_and_align)
{
   char *name;
   GLint index;

   /* Check if the state reference is already in the list */
   for (index = 0; index < (GLint) paramList->NumParameters; index++) {
      if (!memcmp(paramList->Parameters[index].StateIndexes,
                  stateTokens,
                  sizeof(paramList->Parameters[index].StateIndexes))) {
         return index;
      }
   }

   name = _mesa_program_state_string(stateTokens);
   index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
                               size, GL_NONE, NULL, stateTokens,
                               pad_and_align);
   paramList->StateFlags |= _mesa_program_state_flags(stateTokens);

   /* free name string here since we duplicated it in add_parameter() */
   free(name);

   return index;
}
コード例 #3
0
ファイル: prog_print.c プロジェクト: BNieuwenhuizen/mesa
/**
 * Return string representation of the given register.
 * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined
 * by the ARB/NV program languages so we've taken some liberties here.
 * \param f  the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc)
 * \param index  number of the register in the register file
 * \param mode  the output format/mode/style
 * \param prog  pointer to containing program
 */
static const char *
reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode,
           GLboolean relAddr, const struct gl_program *prog)
{
    static char str[100];
    const char *addr = relAddr ? "ADDR+" : "";

    str[0] = 0;

    switch (mode) {
    case PROG_PRINT_DEBUG:
        sprintf(str, "%s[%s%d]",
                _mesa_register_file_name(f), addr, index);
        break;

    case PROG_PRINT_ARB:
        switch (f) {
        case PROGRAM_INPUT:
            sprintf(str, "%s", arb_input_attrib_string(index, prog->Target));
            break;
        case PROGRAM_OUTPUT:
            sprintf(str, "%s", arb_output_attrib_string(index, prog->Target));
            break;
        case PROGRAM_TEMPORARY:
            sprintf(str, "temp%d", index);
            break;
        case PROGRAM_CONSTANT: /* extension */
            sprintf(str, "constant[%s%d]", addr, index);
            break;
        case PROGRAM_UNIFORM: /* extension */
            sprintf(str, "uniform[%s%d]", addr, index);
            break;
        case PROGRAM_SYSTEM_VALUE:
            sprintf(str, "sysvalue[%s%d]", addr, index);
            break;
        case PROGRAM_STATE_VAR:
        {
            struct gl_program_parameter *param
                    = prog->Parameters->Parameters + index;
            char *state = _mesa_program_state_string(param->StateIndexes);
            sprintf(str, "%s", state);
            free(state);
        }
        break;
        case PROGRAM_ADDRESS:
            sprintf(str, "A%d", index);
            break;
        default:
            _mesa_problem(NULL, "bad file in reg_string()");
        }
        break;

    default:
        _mesa_problem(NULL, "bad mode in reg_string()");
    }

    return str;
}
コード例 #4
0
ファイル: prog_parameter.c プロジェクト: Starlink/mesa
/**
 * Add a new state reference to the parameter list.
 * This will be used when the program contains something like this:
 *    PARAM ambient = state.material.front.ambient;
 *
 * \param paramList  the parameter list
 * \param stateTokens  an array of 5 (STATE_LENGTH) state tokens
 * \return index of the new parameter.
 */
GLint
_mesa_add_state_reference(struct gl_program_parameter_list *paramList,
                          const gl_state_index stateTokens[STATE_LENGTH])
{
   const GLuint size = 4; /* XXX fix */
   const char *name;
   GLint index;

   /* Check if the state reference is already in the list */
   for (index = 0; index < (GLint) paramList->NumParameters; index++) {
      GLuint i, match = 0;
      for (i = 0; i < STATE_LENGTH; i++) {
         if (paramList->Parameters[index].StateIndexes[i] == stateTokens[i]) {
            match++;
         }
         else {
            break;
         }
      }
      if (match == STATE_LENGTH) {
         /* this state reference is already in the parameter list */
         return index;
      }
   }

   name = _mesa_program_state_string(stateTokens);
   index = _mesa_add_parameter(paramList, PROGRAM_STATE_VAR, name,
                               size, GL_NONE,
                               NULL, (gl_state_index *) stateTokens);
   paramList->StateFlags |= _mesa_program_state_flags(stateTokens);

   /* free name string here since we duplicated it in add_parameter() */
   _mesa_free((void *) name);

   return index;
}
コード例 #5
0
ファイル: prog_print.c プロジェクト: toastpp/toastpp
/**
 * Return string representation of the given register.
 * Note that some types of registers (like PROGRAM_UNIFORM) aren't defined
 * by the ARB/NV program languages so we've taken some liberties here.
 * \param f  the register file (PROGRAM_INPUT, PROGRAM_TEMPORARY, etc)
 * \param index  number of the register in the register file
 * \param mode  the output format/mode/style
 * \param prog  pointer to containing program
 */
static const char *
reg_string(gl_register_file f, GLint index, gl_prog_print_mode mode,
           GLboolean relAddr, const struct gl_program *prog)
{
   static char str[100];
   const char *addr = relAddr ? "ADDR+" : "";

   str[0] = 0;

   switch (mode) {
   case PROG_PRINT_DEBUG:
      _mesa_sprintf(str, "%s[%s%d]", file_string(f, mode), addr, index);
      break;

   case PROG_PRINT_ARB:
      switch (f) {
      case PROGRAM_INPUT:
         _mesa_sprintf(str, "%s", arb_input_attrib_string(index, prog->Target));
         break;
      case PROGRAM_OUTPUT:
         _mesa_sprintf(str, "%s", arb_output_attrib_string(index, prog->Target));
         break;
      case PROGRAM_TEMPORARY:
         _mesa_sprintf(str, "temp%d", index);
         break;
      case PROGRAM_ENV_PARAM:
         _mesa_sprintf(str, "program.env[%s%d]", addr, index);
         break;
      case PROGRAM_LOCAL_PARAM:
         _mesa_sprintf(str, "program.local[%s%d]", addr, index);
         break;
      case PROGRAM_VARYING: /* extension */
         _mesa_sprintf(str, "varying[%s%d]", addr, index);
         break;
      case PROGRAM_CONSTANT: /* extension */
         _mesa_sprintf(str, "constant[%s%d]", addr, index);
         break;
      case PROGRAM_UNIFORM: /* extension */
         _mesa_sprintf(str, "uniform[%s%d]", addr, index);
         break;
      case PROGRAM_STATE_VAR:
         {
            struct gl_program_parameter *param
               = prog->Parameters->Parameters + index;
            char *state = _mesa_program_state_string(param->StateIndexes);
            _mesa_sprintf(str, state);
            _mesa_free(state);
         }
         break;
      case PROGRAM_ADDRESS:
         _mesa_sprintf(str, "A%d", index);
         break;
      default:
         _mesa_problem(NULL, "bad file in reg_string()");
      }
      break;

   case PROG_PRINT_NV:
      switch (f) {
      case PROGRAM_INPUT:
         if (prog->Target == GL_VERTEX_PROGRAM_ARB)
            _mesa_sprintf(str, "v[%d]", index);
         else
            _mesa_sprintf(str, "f[%d]", index);
         break;
      case PROGRAM_OUTPUT:
         _mesa_sprintf(str, "o[%d]", index);
         break;
      case PROGRAM_TEMPORARY:
         _mesa_sprintf(str, "R%d", index);
         break;
      case PROGRAM_ENV_PARAM:
         _mesa_sprintf(str, "c[%d]", index);
         break;
      case PROGRAM_VARYING: /* extension */
         _mesa_sprintf(str, "varying[%s%d]", addr, index);
         break;
      case PROGRAM_UNIFORM: /* extension */
         _mesa_sprintf(str, "uniform[%s%d]", addr, index);
         break;
      case PROGRAM_CONSTANT: /* extension */
         _mesa_sprintf(str, "constant[%s%d]", addr, index);
         break;
      case PROGRAM_STATE_VAR: /* extension */
         _mesa_sprintf(str, "state[%s%d]", addr, index);
         break;
      default:
         _mesa_problem(NULL, "bad file in reg_string()");
      }
      break;

   default:
      _mesa_problem(NULL, "bad mode in reg_string()");
   }

   return str;
}