00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00045 #include "pipe/p_winsys.h"
00046 #include "util/u_math.h"
00047 #include "util/u_memory.h"
00048 #include "pipe/p_inlines.h"
00049 #include "brw_context.h"
00050 #include "brw_state.h"
00051
00052 boolean brw_pool_alloc( struct brw_mem_pool *pool,
00053 unsigned size,
00054 unsigned alignment,
00055 unsigned *offset_return)
00056 {
00057 unsigned fixup = align(pool->offset, alignment) - pool->offset;
00058
00059 size = align(size, 4);
00060
00061 if (pool->offset + fixup + size >= pool->size) {
00062 debug_printf("%s failed\n", __FUNCTION__);
00063 assert(0);
00064 exit(0);
00065 }
00066
00067 pool->offset += fixup;
00068 *offset_return = pool->offset;
00069 pool->offset += size;
00070
00071 return TRUE;
00072 }
00073
00074 static
00075 void brw_invalidate_pool( struct brw_mem_pool *pool )
00076 {
00077 if (BRW_DEBUG & DEBUG_STATE)
00078 debug_printf("\n\n\n %s \n\n\n", __FUNCTION__);
00079
00080 pool->offset = 0;
00081
00082 brw_clear_all_caches(pool->brw);
00083 }
00084
00085
00086 static void brw_init_pool( struct brw_context *brw,
00087 unsigned pool_id,
00088 unsigned size )
00089 {
00090 struct brw_mem_pool *pool = &brw->pool[pool_id];
00091
00092 pool->size = size;
00093 pool->brw = brw;
00094
00095 pool->buffer = pipe_buffer_create(brw->pipe.screen,
00096 4096,
00097 0 ,
00098 size);
00099 }
00100
00101 static void brw_destroy_pool( struct brw_context *brw,
00102 unsigned pool_id )
00103 {
00104 struct brw_mem_pool *pool = &brw->pool[pool_id];
00105
00106 pipe_buffer_reference( pool->brw->pipe.screen,
00107 &pool->buffer,
00108 NULL );
00109 }
00110
00111
00112 void brw_pool_check_wrap( struct brw_context *brw,
00113 struct brw_mem_pool *pool )
00114 {
00115 if (pool->offset > (pool->size * 3) / 4) {
00116 brw->state.dirty.brw |= BRW_NEW_SCENE;
00117 }
00118
00119 }
00120
00121 void brw_init_pools( struct brw_context *brw )
00122 {
00123 brw_init_pool(brw, BRW_GS_POOL, 0x80000);
00124 brw_init_pool(brw, BRW_SS_POOL, 0x80000);
00125 }
00126
00127 void brw_destroy_pools( struct brw_context *brw )
00128 {
00129 brw_destroy_pool(brw, BRW_GS_POOL);
00130 brw_destroy_pool(brw, BRW_SS_POOL);
00131 }
00132
00133
00134 void brw_invalidate_pools( struct brw_context *brw )
00135 {
00136 brw_invalidate_pool(&brw->pool[BRW_GS_POOL]);
00137 brw_invalidate_pool(&brw->pool[BRW_SS_POOL]);
00138 }