Ejemplo n.º 1
0
static void
sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level,
		  const struct gl_texture_image *image )
{
   char *addr;
   int size, texel_size;

   if (t->format == 0) {
      t->format = image->Format;
      switch (t->format)
      {
      case GL_RGBA:
         t->hwformat = TEXEL_ARGB_8888_32;
         break;
      case GL_INTENSITY:
         t->hwformat = TEXEL_I8;
         break;
      case GL_ALPHA:
         t->hwformat = TEXEL_A8;
         break;
      case GL_LUMINANCE:
         t->hwformat = TEXEL_L8;
         break;
      case GL_LUMINANCE_ALPHA:
         t->hwformat = TEXEL_AL88;
         break;
      case GL_RGB:
         t->hwformat = TEXEL_ARGB_0888_32;
         break;
      default:
         sis_fatal_error("Bad texture format.\n");
      }
   }
   assert(t->format == image->Format);

   texel_size = image->TexFormat->TexelBytes;
   size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS;

   addr = sisAllocFB( smesa, size, &t->image[level].handle );
   if (addr == NULL) {
      addr = sisAllocAGP( smesa, size, &t->image[level].handle );
      if (addr == NULL)
         sis_fatal_error("Failure to allocate texture memory.\n");
      t->image[level].memType = AGP_TYPE;
   }
   else
      t->image[level].memType = VIDEO_TYPE;
   
   t->image[level].Data = ALIGN(addr, TEXTURE_HW_ALIGNMENT);
   t->image[level].pitch = image->Width * texel_size;
   t->image[level].size = image->Width * image->Height * texel_size;
   t->numImages++;
}
Ejemplo n.º 2
0
void
sisAllocZStencilBuffer( sisContextPtr smesa )
{
   GLuint z_depth;
   GLuint totalBytes;
   int width2;

   GLubyte *addr;

   z_depth = ( smesa->glCtx->Visual.depthBits +
               smesa->glCtx->Visual.stencilBits ) / 8;

   width2 = ALIGNMENT( smesa->width * z_depth, 4 );

   totalBytes = smesa->height * width2 + Z_BUFFER_HW_PLUS;

   addr = sisAllocFB( smesa, totalBytes, &smesa->zbFree );
   if (addr == NULL)
      sis_fatal_error("Failure to allocate Z buffer.\n");

   if (SIS_VERBOSE & VERBOSE_SIS_BUFFER) {
      fprintf(stderr, "sis_alloc_z_stencil_buffer: addr=%p\n", addr);
   }

   addr = (GLubyte *)ALIGNMENT( (unsigned long)addr, Z_BUFFER_HW_ALIGNMENT );

   smesa->depthbuffer = (void *) addr;
   smesa->depthPitch = width2;
   smesa->depthOffset = (unsigned long)addr - (unsigned long)smesa->FbBase;

   /* set pZClearPacket */
   memset( &smesa->zClearPacket, 0, sizeof(ENGPACKET) );

   smesa->zClearPacket.dwSrcPitch = (z_depth == 2) ? 0x80000000 : 0xf0000000;
   smesa->zClearPacket.dwDestBaseAddr = (unsigned long)(addr -
      (unsigned long)smesa->FbBase);
   smesa->zClearPacket.wDestPitch = width2;
   smesa->zClearPacket.stdwDestPos.wY = 0;
   smesa->zClearPacket.stdwDestPos.wX = 0;

   smesa->zClearPacket.wDestHeight = smesa->virtualY;
   smesa->zClearPacket.stdwDim.wWidth = (GLshort)width2 / z_depth;
   smesa->zClearPacket.stdwDim.wHeight = (GLshort)smesa->height;
   smesa->zClearPacket.stdwCmd.cRop = 0xf0;

   if (smesa->blockWrite)
      smesa->zClearPacket.stdwCmd.cCmd0 = CMD0_PAT_FG_COLOR;
   else
      smesa->zClearPacket.stdwCmd.cCmd0 = 0;
   smesa->zClearPacket.stdwCmd.cCmd1 = CMD1_DIR_X_INC | CMD1_DIR_Y_INC;
}
Ejemplo n.º 3
0
void
sisAllocBackbuffer( sisContextPtr smesa )
{
   GLuint depth = smesa->bytesPerPixel;
   GLuint size, width2;

   char *addr;

   width2 = (depth == 2) ? ALIGNMENT (smesa->width, 2) : smesa->width;
   size = width2 * smesa->height * depth + DRAW_BUFFER_HW_PLUS;

   /* Fixme: unique context alloc/free back-buffer? */
   addr = sisAllocFB( smesa, size, &smesa->bbFree );
   if (addr == NULL)
      sis_fatal_error("Failure to allocate back buffer.\n");

   addr = (char *)ALIGNMENT( (unsigned long)addr, DRAW_BUFFER_HW_ALIGNMENT );

   smesa->backbuffer = addr;
   smesa->backOffset = (unsigned long)(addr - (unsigned long)smesa->FbBase);
   smesa->backPitch = width2 * depth;

   memset ( &smesa->cbClearPacket, 0, sizeof(ENGPACKET) );

   smesa->cbClearPacket.dwSrcPitch = (depth == 2) ? 0x80000000 : 0xf0000000;
   smesa->cbClearPacket.dwDestBaseAddr = smesa->backOffset;
   smesa->cbClearPacket.wDestPitch = smesa->backPitch;
   smesa->cbClearPacket.stdwDestPos.wY = 0;
   smesa->cbClearPacket.stdwDestPos.wX = 0;

   smesa->cbClearPacket.wDestHeight = smesa->virtualY;
   smesa->cbClearPacket.stdwDim.wWidth = (GLshort) width2;
   smesa->cbClearPacket.stdwDim.wHeight = (GLshort) smesa->height;
   smesa->cbClearPacket.stdwCmd.cRop = 0xf0;

   if (smesa->blockWrite)
      smesa->cbClearPacket.stdwCmd.cCmd0 = (GLbyte)(CMD0_PAT_FG_COLOR);
   else
      smesa->cbClearPacket.stdwCmd.cCmd0 = 0;
   smesa->cbClearPacket.stdwCmd.cCmd1 = CMD1_DIR_X_INC | CMD1_DIR_Y_INC;
}
Ejemplo n.º 4
0
static void
sisAllocTexImage( sisContextPtr smesa, sisTexObjPtr t, int level,
                  const struct gl_texture_image *image )
{
    char *addr;
    int size, texel_size;

    if (t->format == 0) {
        t->format = image->_BaseFormat;
        switch (image->TexFormat)
        {
        case MESA_FORMAT_ARGB8888:
            t->hwformat = TEXEL_ARGB_8888_32;
            break;
        case MESA_FORMAT_ARGB4444:
            t->hwformat = TEXEL_ARGB_4444_16;
            break;
        case MESA_FORMAT_ARGB1555:
            t->hwformat = TEXEL_ARGB_1555_16;
            break;
        case MESA_FORMAT_RGB565:
            t->hwformat = TEXEL_RGB_565_16;
            break;
        case MESA_FORMAT_RGB332:
            t->hwformat = TEXEL_RGB_332_8;
            break;
        case MESA_FORMAT_I8:
            t->hwformat = TEXEL_I8;
            break;
        case MESA_FORMAT_A8:
            t->hwformat = TEXEL_A8;
            break;
        case MESA_FORMAT_L8:
            t->hwformat = TEXEL_L8;
            break;
        case MESA_FORMAT_AL88:
            t->hwformat = TEXEL_AL88;
            break;
        case MESA_FORMAT_YCBCR:
            t->hwformat = TEXEL_YUV422;
            break;
        case MESA_FORMAT_YCBCR_REV:
            t->hwformat = TEXEL_VUY422;
            break;
        default:
            sis_fatal_error("Bad texture format 0x%x.\n", image->TexFormat);
        }
    }
    assert(t->format == image->_BaseFormat);

    texel_size = _mesa_get_format_bytes(image->TexFormat);
    size = image->Width * image->Height * texel_size + TEXTURE_HW_PLUS;

    addr = sisAllocFB( smesa, size, &t->image[level].handle );
    if (addr == NULL) {
        addr = sisAllocAGP( smesa, size, &t->image[level].handle );
        if (addr == NULL)
            sis_fatal_error("Failure to allocate texture memory.\n");
        t->image[level].memType = AGP_TYPE;
    }
    else
        t->image[level].memType = VIDEO_TYPE;

    t->image[level].Data = ALIGN(addr, TEXTURE_HW_ALIGNMENT);
    t->image[level].pitch = image->Width * texel_size;
    t->image[level].size = image->Width * image->Height * texel_size;
    t->numImages++;
}