ReactOS Fundraising Campaign 2012
 
€ 4,410 / € 30,000

Information | Donate

Home | Info | Community | Development | myReactOS | Contact Us

  1. Home
  2. Community
  3. Development
  4. myReactOS
  5. Fundraiser 2012

  1. Main Page
  2. Alphabetical List
  3. Data Structures
  4. Directories
  5. File List
  6. Data Fields
  7. Globals
  8. Related Pages

ReactOS Development > Doxygen

static GLint alloc_reg ( slang_var_table *  vt,
GLint  size,
GLboolean  isTemp 
) [static]

Allocation helper.

Parameters:
sizevar size in floats
Returns:
position for var, measured in floats

Definition at line 209 of file slang_vartable.c.

Referenced by _slang_alloc_temp(), and _slang_alloc_var().

{
   struct table *t = vt->Top;
   /* if size == 1, allocate anywhere, else, pos must be multiple of 4 */
   const GLuint step = (size == 1) ? 1 : 4;
   GLuint i, j;
   assert(size > 0); /* number of floats */

   for (i = 0; i <= vt->MaxRegisters * 4 - size; i += step) {
      GLuint found = 0;
      for (j = 0; j < (GLuint) size; j++) {
         assert(i + j < 4 * MAX_PROGRAM_TEMPS);
         if (i + j < vt->MaxRegisters * 4 && t->Temps[i + j] == FREE) {
            found++;
         }
         else {
            break;
         }
      }
      if (found == size) {
         /* found block of size free regs */
         if (size > 1)
            assert(i % 4 == 0);
         for (j = 0; j < (GLuint) size; j++) {
            assert(i + j < 4 * MAX_PROGRAM_TEMPS);
            t->Temps[i + j] = isTemp ? TEMP : VAR;
         }
         assert(i < MAX_PROGRAM_TEMPS * 4);
         t->ValSize[i] = size;
         return i;
      }
   }

   /* if we get here, we ran out of registers */
   return -1;
}

Generated on Fri May 25 2012 04:58:01 for ReactOS by doxygen 1.7.6.1

ReactOS is a registered trademark or a trademark of ReactOS Foundation in the United States and other countries.