Beispiel #1
0
void brw_draw_init( struct brw_context *brw )
{
   GLcontext *ctx = &brw->intel.ctx;
   struct vbo_context *vbo = vbo_context(ctx);
   GLuint i;
   
   /* Register our drawing function: 
    */
   vbo->draw_prims = brw_draw_prims;

   brw->vb.upload.size = BRW_UPLOAD_INIT_SIZE;

   for (i = 0; i < BRW_NR_UPLOAD_BUFS; i++) {
      brw->vb.upload.vbo[i] = ctx->Driver.NewBufferObject(ctx, 1, GL_ARRAY_BUFFER_ARB);
      
      /* NOTE:  These are set to no-backing-store.
       */
      bmBufferSetInvalidateCB(&brw->intel,
			      intel_bufferobj_buffer(intel_buffer_object(brw->vb.upload.vbo[i])),
			      brw_invalidate_vbo_cb,
			      &brw->intel,
			      GL_TRUE);
   }

   ctx->Driver.BufferData( ctx, 
			   GL_ARRAY_BUFFER_ARB, 
			   BRW_UPLOAD_INIT_SIZE,
			   NULL,
			   GL_DYNAMIC_DRAW_ARB,
			   brw->vb.upload.vbo[0] );
}
Beispiel #2
0
GLuint intel_finalize_mipmap_tree( struct intel_context *intel,
				   struct gl_texture_object *tObj )
{
   struct intel_texture_object *intelObj = intel_texture_object(tObj);
   GLuint face, i;
   GLuint nr_faces = 0;
   struct gl_texture_image *firstImage;
   GLuint cpp = 0;
   
   if( tObj == intel->frame_buffer_texobj )
      return GL_FALSE;
   
   /* We know/require this is true by now: 
    */
   assert(intelObj->base.Complete);

   /* What levels must the tree include at a minimum?
    */
   if (intelObj->dirty) {
      intel_calculate_first_last_level( intelObj );
/*       intel_miptree_destroy(intel, intelObj->mt); */
/*       intelObj->mt = NULL; */
   }

   firstImage = intelObj->base.Image[0][intelObj->firstLevel];

   /* Fallback case:
    */
   if (firstImage->Border ||
       ((firstImage->_BaseFormat == GL_DEPTH_COMPONENT) &&
        ((tObj->WrapS == GL_CLAMP_TO_BORDER) ||
         (tObj->WrapT == GL_CLAMP_TO_BORDER)))) {
      if (intelObj->mt) {
	 intel_miptree_destroy(intel, intelObj->mt);
	 intelObj->mt = NULL;
	 /* Set all images dirty:
	  */
	 intel_texture_invalidate(intelObj);
      }
      return GL_FALSE;
   }



   if (firstImage->IsCompressed) {
       cpp = intel_compressed_num_bytes(firstImage->TexFormat->MesaFormat);
   } else {
       cpp = firstImage->TexFormat->TexelBytes;
   }
       
   /* Check tree can hold all active levels.  Check tree matches
    * target, imageFormat, etc.
    */
   if (intelObj->mt &&
       (intelObj->mt->target != intelObj->base.Target ||
	intelObj->mt->internal_format != firstImage->InternalFormat ||
	intelObj->mt->first_level != intelObj->firstLevel ||
	intelObj->mt->last_level != intelObj->lastLevel ||
	intelObj->mt->width0 != firstImage->Width ||
	intelObj->mt->height0 != firstImage->Height ||
	intelObj->mt->depth0 != firstImage->Depth ||
	intelObj->mt->cpp != cpp ||
	intelObj->mt->compressed != firstImage->IsCompressed)) 
   {
      intel_miptree_destroy(intel, intelObj->mt);
      intelObj->mt = NULL;
      
      /* Set all images dirty:
       */
      intel_texture_invalidate(intelObj);
   }
      

   /* May need to create a new tree:
    */
   if (!intelObj->mt) {
      intelObj->mt = intel_miptree_create(intel,
					  intelObj->base.Target,
					  firstImage->InternalFormat,
					  intelObj->firstLevel,
					  intelObj->lastLevel,
					  firstImage->Width,
					  firstImage->Height,
					  firstImage->Depth,
					  cpp,
					  firstImage->IsCompressed);

      /* Tell the buffer manager that we will manage the backing
       * store, but we still want it to do fencing for us.
       */
      bmBufferSetInvalidateCB(intel, 
			      intelObj->mt->region->buffer,
			      intel_texture_invalidate_cb,
			      intelObj,
			      GL_FALSE);
   }

   /* Pull in any images not in the object's tree:
    */
   if (intelObj->dirty) {
      nr_faces = (intelObj->base.Target == GL_TEXTURE_CUBE_MAP) ? 6 : 1;
      for (face = 0; face < nr_faces; face++) {
	 if (intelObj->dirty_images[face]) {
	    for (i = intelObj->firstLevel; i <= intelObj->lastLevel; i++) {
	       struct gl_texture_image *texImage = intelObj->base.Image[face][i];

	       /* Need to import images in main memory or held in other trees.
		*/
	       if (intelObj->dirty_images[face] & (1<<i) &&
		   texImage) {

		  if (INTEL_DEBUG & DEBUG_TEXTURE)
		     _mesa_printf("copy data from image %d (%p) into object miptree\n",
				  i,
				  texImage->Data);

		  if (!copy_image_data_to_tree(intel,
					       intelObj,
					       texImage,
					       face,
					       i))
		     return GL_FALSE;

	       }
	    }
	 }
      }

      /* Only clear the dirty flags if everything went ok:
       */
      for (face = 0; face < nr_faces; face++) {
	 intelObj->dirty_images[face] = 0;
      }

      intelObj->dirty = 0;
   }

   return GL_TRUE;
}