~ubuntu-branches/ubuntu/quantal/mesa-glw/quantal

« back to all changes in this revision

Viewing changes to src/mesa/drivers/dri/i915/intel_texmem.c

  • Committer: Bazaar Package Importer
  • Author(s): Morten Kjeldgaard
  • Date: 2008-05-06 16:19:15 UTC
  • Revision ID: james.westby@ubuntu.com-20080506161915-uynz7nftmfixu6bq
Tags: upstream-7.0.3
ImportĀ upstreamĀ versionĀ 7.0.3

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "texmem.h"
 
2
#include "simple_list.h"
 
3
#include "imports.h"
 
4
#include "macros.h"
 
5
 
 
6
#include "intel_tex.h"
 
7
 
 
8
static GLuint
 
9
driLog2( GLuint n )
 
10
{
 
11
   GLuint log2;
 
12
 
 
13
   for ( log2 = 1 ; n > 1 ; log2++ ) {
 
14
      n >>= 1;
 
15
   }
 
16
 
 
17
   return log2;
 
18
}
 
19
 
 
20
static void calculate_heap_size( driTexHeap * heap, unsigned size, 
 
21
                                 unsigned nr_regions, unsigned alignmentShift )
 
22
{
 
23
   unsigned     l;
 
24
 
 
25
   l = driLog2( (size - 1) / nr_regions );
 
26
   if ( l < alignmentShift )
 
27
   {
 
28
      l = alignmentShift;
 
29
   }
 
30
 
 
31
   heap->logGranularity = l;
 
32
   heap->size = size & ~((1L << l) - 1);
 
33
}
 
34
 
 
35
 
 
36
GLboolean 
 
37
intel_driReinitTextureHeap( driTexHeap *heap,
 
38
                            unsigned size )
 
39
{
 
40
   driTextureObject *t, *tmp;
 
41
 
 
42
   /* Kick out everything:
 
43
    */
 
44
   foreach_s ( t, tmp, & heap->texture_objects ) {
 
45
      if ( t->tObj != NULL ) {
 
46
         driSwapOutTextureObject( t );
 
47
      }
 
48
      else {
 
49
         driDestroyTextureObject( t );
 
50
      }
 
51
   }
 
52
   
 
53
   /* Destroy the memory manager:
 
54
    */
 
55
   mmDestroy( heap->memory_heap );
 
56
      
 
57
   /* Recreate the memory manager:
 
58
    */
 
59
   calculate_heap_size(heap, size, heap->nrRegions, heap->alignmentShift);
 
60
   heap->memory_heap = mmInit( 0, heap->size );
 
61
   if ( heap->memory_heap == NULL ) {
 
62
      fprintf(stderr, "driReinitTextureHeap: couldn't recreate memory heap\n");
 
63
      FREE( heap );
 
64
      return GL_FALSE;
 
65
   }
 
66
 
 
67
   make_empty_list( & heap->texture_objects );
 
68
 
 
69
   return GL_TRUE;
 
70
}
 
71
 
 
72