brw_state.h File Reference

Include dependency graph for brw_state.h:

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Defines

#define BRW_CACHED_BATCH_STRUCT(brw, s)   brw_cached_batch_struct( brw, (s), sizeof(*(s)) )

Functions

unsigned brw_cache_data (struct brw_cache *cache, const void *data)
unsigned brw_cache_data_sz (struct brw_cache *cache, const void *data, unsigned data_sz)
unsigned brw_upload_cache (struct brw_cache *cache, const void *key, unsigned key_sz, const void *data, unsigned data_sz, const void *aux, void *aux_return)
boolean brw_search_cache (struct brw_cache *cache, const void *key, unsigned key_size, void *aux_return, unsigned *offset_return)
void brw_init_caches (struct brw_context *brw)
void brw_destroy_caches (struct brw_context *brw)
static struct pipe_bufferbrw_cache_buffer (struct brw_context *brw, enum brw_cache_id id)
boolean brw_cached_batch_struct (struct brw_context *brw, const void *data, unsigned sz)
void brw_destroy_batch_cache (struct brw_context *brw)
void brw_init_pools (struct brw_context *brw)
void brw_destroy_pools (struct brw_context *brw)
boolean brw_pool_alloc (struct brw_mem_pool *pool, unsigned size, unsigned alignment, unsigned *offset_return)
void brw_pool_fence (struct brw_context *brw, struct brw_mem_pool *pool, unsigned fence)
void brw_pool_check_wrap (struct brw_context *brw, struct brw_mem_pool *pool)
void brw_clear_all_caches (struct brw_context *brw)
void brw_invalidate_pools (struct brw_context *brw)
void brw_clear_batch_cache_flush (struct brw_context *brw)

Variables

struct brw_tracked_state brw_blend_constant_color
struct brw_tracked_state brw_cc_unit
struct brw_tracked_state brw_cc_vp
struct brw_tracked_state brw_clip_prog
struct brw_tracked_state brw_clip_unit
struct brw_tracked_state brw_constant_buffer_state
struct brw_tracked_state brw_constant_buffer
struct brw_tracked_state brw_curbe_offsets
struct brw_tracked_state brw_invarient_state
struct brw_tracked_state brw_gs_prog
struct brw_tracked_state brw_gs_unit
struct brw_tracked_state brw_drawing_rect
struct brw_tracked_state brw_line_stipple
struct brw_tracked_state brw_pipelined_state_pointers
struct brw_tracked_state brw_binding_table_pointers
struct brw_tracked_state brw_depthbuffer
struct brw_tracked_state brw_polygon_stipple_offset
struct brw_tracked_state brw_polygon_stipple
struct brw_tracked_state brw_program_parameters
struct brw_tracked_state brw_recalculate_urb_fence
struct brw_tracked_state brw_sf_prog
struct brw_tracked_state brw_sf_unit
struct brw_tracked_state brw_sf_vp
struct brw_tracked_state brw_state_base_address
struct brw_tracked_state brw_urb_fence
struct brw_tracked_state brw_vertex_state
struct brw_tracked_state brw_vs_prog
struct brw_tracked_state brw_vs_unit
struct brw_tracked_state brw_wm_prog
struct brw_tracked_state brw_wm_samplers
struct brw_tracked_state brw_wm_surfaces
struct brw_tracked_state brw_wm_unit
struct brw_tracked_state brw_psp_urb_cbs
struct brw_tracked_state brw_active_vertprog
struct brw_tracked_state brw_tnl_vertprog
struct brw_tracked_state brw_pipe_control
struct brw_tracked_state brw_clear_surface_cache
struct brw_tracked_state brw_clear_batch_cache


Define Documentation

#define BRW_CACHED_BATCH_STRUCT ( brw,
 )     brw_cached_batch_struct( brw, (s), sizeof(*(s)) )

Definition at line 118 of file brw_state.h.


Function Documentation

static struct pipe_buffer* brw_cache_buffer ( struct brw_context brw,
enum brw_cache_id  id 
) [static, read]

Definition at line 109 of file brw_state.h.

References brw_mem_pool::buffer, brw_context::cache, and brw_cache::pool.

00111 {
00112    return brw->cache[id].pool->buffer;
00113 }

unsigned brw_cache_data ( struct brw_cache cache,
const void *  data 
)

Definition at line 219 of file brw_state_cache.c.

References brw_cache_data_sz(), and brw_cache::key_size.

00221 {
00222    return brw_cache_data_sz(cache, data, cache->key_size);
00223 }

unsigned brw_cache_data_sz ( struct brw_cache cache,
const void *  data,
unsigned  data_sz 
)

Definition at line 203 of file brw_state_cache.c.

References brw_search_cache(), and brw_upload_cache().

00206 {
00207    unsigned addr;
00208 
00209    if (!brw_search_cache(cache, data, data_size, NULL, &addr)) {
00210       addr = brw_upload_cache(cache,
00211                               data, data_size,
00212                               data, data_size,
00213                               NULL, NULL);
00214    }
00215 
00216    return addr;
00217 }

boolean brw_cached_batch_struct ( struct brw_context brw,
const void *  data,
unsigned  sz 
)

Definition at line 40 of file brw_state_batch.c.

References assert, brw_batchbuffer_data(), brw_context::cached_batch_items, CALLOC_STRUCT, brw_context::emit_state_always, FALSE, FREE, brw_cached_batch_item::header, MALLOC, brw_cached_batch_item::next, header::opcode, brw_cached_batch_item::sz, TRUE, and brw_context::winsys.

00043 {
00044    struct brw_cached_batch_item *item = brw->cached_batch_items;
00045    struct header *newheader = (struct header *)data;
00046 
00047    if (brw->emit_state_always) {
00048       brw_batchbuffer_data(brw->winsys, data, sz);
00049       return TRUE;
00050    }
00051 
00052    while (item) {
00053       if (item->header->opcode == newheader->opcode) {
00054          if (item->sz == sz && memcmp(item->header, newheader, sz) == 0)
00055             return FALSE;
00056          if (item->sz != sz) {
00057             FREE(item->header);
00058             item->header = MALLOC(sz);
00059             item->sz = sz;
00060          }
00061          goto emit;
00062       }
00063       item = item->next;
00064    }
00065 
00066    assert(!item);
00067    item = CALLOC_STRUCT(brw_cached_batch_item);
00068    item->header = MALLOC(sz);
00069    item->sz = sz;
00070    item->next = brw->cached_batch_items;
00071    brw->cached_batch_items = item;
00072 
00073 emit:
00074    memcpy(item->header, newheader, sz);
00075    brw_batchbuffer_data(brw->winsys, data, sz);
00076    return TRUE;
00077 }

void brw_clear_all_caches ( struct brw_context brw  ) 

Definition at line 414 of file brw_state_cache.c.

References brw_state_flags::brw, BRW_DEBUG, BRW_MAX_CACHE, brw_state_flags::cache, brw_context::cache, clear_cache(), brw_context::curbe, debug_printf(), DEBUG_STATE, brw_context::dirty, FREE, brw_context::last_buf, and brw_context::state.

00415 {
00416    int i;
00417 
00418    if (BRW_DEBUG & DEBUG_STATE)
00419       debug_printf("%s\n", __FUNCTION__);
00420 
00421    for (i = 0; i < BRW_MAX_CACHE; i++)
00422       clear_cache(&brw->cache[i]);
00423 
00424    if (brw->curbe.last_buf) {
00425       FREE(brw->curbe.last_buf);
00426       brw->curbe.last_buf = NULL;
00427    }
00428 
00429    brw->state.dirty.brw |= ~0;
00430    brw->state.dirty.cache |= ~0;
00431 }

void brw_clear_batch_cache_flush ( struct brw_context brw  ) 

Definition at line 98 of file brw_state_batch.c.

References brw_state_flags::brw, brw_state_flags::cache, clear_batch_cache(), brw_context::dirty, and brw_context::state.

00099 {
00100    clear_batch_cache(brw);
00101 
00102 /*    brw_do_flush(brw, BRW_FLUSH_STATE_CACHE|BRW_FLUSH_READ_CACHE); */
00103 
00104    brw->state.dirty.brw |= ~0;
00105    brw->state.dirty.cache |= ~0;
00106 }

void brw_destroy_batch_cache ( struct brw_context brw  ) 

Definition at line 110 of file brw_state_batch.c.

References clear_batch_cache().

00111 {
00112    clear_batch_cache(brw);
00113 }

void brw_destroy_caches ( struct brw_context brw  ) 

Definition at line 437 of file brw_state_cache.c.

References BRW_MAX_CACHE, brw_context::cache, and clear_cache().

00438 {
00439    unsigned i;
00440 
00441    for (i = 0; i < BRW_MAX_CACHE; i++)
00442       clear_cache(&brw->cache[i]);
00443 }

void brw_destroy_pools ( struct brw_context brw  ) 

Definition at line 127 of file brw_state_pool.c.

References brw_destroy_pool(), BRW_GS_POOL, and BRW_SS_POOL.

00128 {
00129    brw_destroy_pool(brw, BRW_GS_POOL);
00130    brw_destroy_pool(brw, BRW_SS_POOL);
00131 }

void brw_init_caches ( struct brw_context brw  ) 

Definition at line 258 of file brw_state_cache.c.

References BRW_CC_UNIT, BRW_CC_VP, BRW_CLIP_PROG, BRW_CLIP_UNIT, BRW_GS_PROG, BRW_GS_UNIT, brw_init_cache(), BRW_SAMPLER, BRW_SAMPLER_DEFAULT_COLOR, BRW_SF_PROG, BRW_SF_UNIT, BRW_SF_VP, BRW_SS_SURF_BIND, BRW_SS_SURFACE, BRW_VS_PROG, BRW_VS_UNIT, BRW_WM_PROG, BRW_WM_UNIT, DW_GENERAL_STATE, and DW_SURFACE_STATE.

00259 {
00260 
00261    brw_init_cache(brw,
00262                   "CC_VP",
00263                   BRW_CC_VP,
00264                   sizeof(struct brw_cc_viewport),
00265                   0,
00266                   DW_GENERAL_STATE);
00267 
00268    brw_init_cache(brw,
00269                   "CC_UNIT",
00270                   BRW_CC_UNIT,
00271                   sizeof(struct brw_cc_unit_state),
00272                   0,
00273                   DW_GENERAL_STATE);
00274 
00275    brw_init_cache(brw,
00276                   "WM_PROG",
00277                   BRW_WM_PROG,
00278                   sizeof(struct brw_wm_prog_key),
00279                   sizeof(struct brw_wm_prog_data),
00280                   DW_GENERAL_STATE);
00281 
00282    brw_init_cache(brw,
00283                   "SAMPLER_DEFAULT_COLOR",
00284                   BRW_SAMPLER_DEFAULT_COLOR,
00285                   sizeof(struct brw_sampler_default_color),
00286                   0,
00287                   DW_GENERAL_STATE);
00288 
00289    brw_init_cache(brw,
00290                   "SAMPLER",
00291                   BRW_SAMPLER,
00292                   0,            /* variable key/data size */
00293                   0,
00294                   DW_GENERAL_STATE);
00295 
00296    brw_init_cache(brw,
00297                   "WM_UNIT",
00298                   BRW_WM_UNIT,
00299                   sizeof(struct brw_wm_unit_state),
00300                   0,
00301                   DW_GENERAL_STATE);
00302 
00303    brw_init_cache(brw,
00304                   "SF_PROG",
00305                   BRW_SF_PROG,
00306                   sizeof(struct brw_sf_prog_key),
00307                   sizeof(struct brw_sf_prog_data),
00308                   DW_GENERAL_STATE);
00309 
00310    brw_init_cache(brw,
00311                   "SF_VP",
00312                   BRW_SF_VP,
00313                   sizeof(struct brw_sf_viewport),
00314                   0,
00315                   DW_GENERAL_STATE);
00316 
00317    brw_init_cache(brw,
00318                   "SF_UNIT",
00319                   BRW_SF_UNIT,
00320                   sizeof(struct brw_sf_unit_state),
00321                   0,
00322                   DW_GENERAL_STATE);
00323 
00324    brw_init_cache(brw,
00325                   "VS_UNIT",
00326                   BRW_VS_UNIT,
00327                   sizeof(struct brw_vs_unit_state),
00328                   0,
00329                   DW_GENERAL_STATE);
00330 
00331    brw_init_cache(brw,
00332                   "VS_PROG",
00333                   BRW_VS_PROG,
00334                   sizeof(struct brw_vs_prog_key),
00335                   sizeof(struct brw_vs_prog_data),
00336                   DW_GENERAL_STATE);
00337 
00338    brw_init_cache(brw,
00339                   "CLIP_UNIT",
00340                   BRW_CLIP_UNIT,
00341                   sizeof(struct brw_clip_unit_state),
00342                   0,
00343                   DW_GENERAL_STATE);
00344 
00345    brw_init_cache(brw,
00346                   "CLIP_PROG",
00347                   BRW_CLIP_PROG,
00348                   sizeof(struct brw_clip_prog_key),
00349                   sizeof(struct brw_clip_prog_data),
00350                   DW_GENERAL_STATE);
00351 
00352    brw_init_cache(brw,
00353                   "GS_UNIT",
00354                   BRW_GS_UNIT,
00355                   sizeof(struct brw_gs_unit_state),
00356                   0,
00357                   DW_GENERAL_STATE);
00358 
00359    brw_init_cache(brw,
00360                   "GS_PROG",
00361                   BRW_GS_PROG,
00362                   sizeof(struct brw_gs_prog_key),
00363                   sizeof(struct brw_gs_prog_data),
00364                   DW_GENERAL_STATE);
00365 
00366    brw_init_cache(brw,
00367                   "SS_SURFACE",
00368                   BRW_SS_SURFACE,
00369                   sizeof(struct brw_surface_state),
00370                   0,
00371                   DW_SURFACE_STATE);
00372 
00373    brw_init_cache(brw,
00374                   "SS_SURF_BIND",
00375                   BRW_SS_SURF_BIND,
00376                   sizeof(struct brw_surface_binding_table),
00377                   0,
00378                   DW_SURFACE_STATE);
00379 }

void brw_init_pools ( struct brw_context brw  ) 

Definition at line 121 of file brw_state_pool.c.

References BRW_GS_POOL, brw_init_pool(), and BRW_SS_POOL.

00122 {
00123    brw_init_pool(brw, BRW_GS_POOL, 0x80000);
00124    brw_init_pool(brw, BRW_SS_POOL, 0x80000);
00125 }

void brw_invalidate_pools ( struct brw_context brw  ) 

Definition at line 134 of file brw_state_pool.c.

References BRW_GS_POOL, brw_invalidate_pool(), BRW_SS_POOL, and brw_context::pool.

00135 {
00136    brw_invalidate_pool(&brw->pool[BRW_GS_POOL]);
00137    brw_invalidate_pool(&brw->pool[BRW_SS_POOL]);
00138 }

boolean brw_pool_alloc ( struct brw_mem_pool pool,
unsigned  size,
unsigned  alignment,
unsigned *  offset_return 
)

Definition at line 52 of file brw_state_pool.c.

References align(), assert, debug_printf(), brw_mem_pool::offset, brw_mem_pool::size, and TRUE.

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 }

void brw_pool_check_wrap ( struct brw_context brw,
struct brw_mem_pool pool 
)

Definition at line 112 of file brw_state_pool.c.

References brw_state_flags::brw, BRW_NEW_SCENE, brw_context::dirty, brw_mem_pool::offset, brw_mem_pool::size, and brw_context::state.

00114 {
00115    if (pool->offset > (pool->size * 3) / 4) {
00116       brw->state.dirty.brw |= BRW_NEW_SCENE;
00117    }
00118 
00119 }

void brw_pool_fence ( struct brw_context brw,
struct brw_mem_pool pool,
unsigned  fence 
)

boolean brw_search_cache ( struct brw_cache cache,
const void *  key,
unsigned  key_size,
void *  aux_return,
unsigned *  offset_return 
)

Definition at line 109 of file brw_state_cache.c.

References brw_cache::brw, brw_state_flags::cache, brw_context::dirty, brw_cache_item::hash, hash_key(), brw_cache::id, brw_cache_item::key, brw_cache_item::key_size, brw_cache::last_addr, brw_cache_item::offset, search_cache(), and brw_context::state.

00114 {
00115    struct brw_cache_item *item;
00116    unsigned addr = 0;
00117    unsigned hash = hash_key(key, key_size);
00118 
00119    item = search_cache(cache, hash, key, key_size);
00120 
00121    if (item) {
00122       if (aux_return)
00123          *(void **)aux_return = (void *)((char *)item->key + item->key_size);
00124 
00125       *offset_return = addr = item->offset;
00126    }
00127 
00128    if (item == NULL || addr != cache->last_addr) {
00129       cache->brw->state.dirty.cache |= 1<<cache->id;
00130       cache->last_addr = addr;
00131    }
00132 
00133    return item != NULL;
00134 }

unsigned brw_upload_cache ( struct brw_cache cache,
const void *  key,
unsigned  key_sz,
const void *  data,
unsigned  data_sz,
const void *  aux,
void *  aux_return 
)

Definition at line 136 of file brw_state_cache.c.

References assert, brw_cache::aux_size, brw_cache::brw, BRW_DEBUG, brw_pool_alloc(), brw_mem_pool::buffer, brw_winsys::buffer_subdata_typed, brw_state_flags::cache, CALLOC_STRUCT, brw_cache_item::data_size, debug_printf(), DEBUG_STATE, brw_context::dirty, brw_cache_item::hash, hash_key(), brw_cache::id, brw_cache::items, brw_cache_item::key, brw_cache_item::key_size, brw_cache::last_addr, MALLOC, brw_cache::n_items, brw_cache::name, brw_cache_item::next, brw_cache_item::offset, offset(), brw_cache::pool, rehash(), brw_cache::size, brw_context::state, and brw_context::winsys.

00143 {
00144    unsigned offset;
00145    struct brw_cache_item *item = CALLOC_STRUCT(brw_cache_item);
00146    unsigned hash = hash_key(key, key_size);
00147    void *tmp = MALLOC(key_size + cache->aux_size);
00148 
00149    if (!brw_pool_alloc(cache->pool, data_size, 1 << 6, &offset)) {
00150       /* Should not be possible:
00151        */
00152       debug_printf("brw_pool_alloc failed\n");
00153       exit(1);
00154    }
00155 
00156    memcpy(tmp, key, key_size);
00157 
00158    if (cache->aux_size)
00159       memcpy(tmp+key_size, aux, cache->aux_size);
00160 
00161    item->key = tmp;
00162    item->hash = hash;
00163    item->key_size = key_size;
00164    item->offset = offset;
00165    item->data_size = data_size;
00166 
00167    if (++cache->n_items > cache->size * 1.5)
00168       rehash(cache);
00169 
00170    hash %= cache->size;
00171    item->next = cache->items[hash];
00172    cache->items[hash] = item;
00173 
00174    if (aux_return) {
00175       assert(cache->aux_size);
00176       *(void **)aux_return = (void *)((char *)item->key + item->key_size);
00177    }
00178 
00179    if (BRW_DEBUG & DEBUG_STATE)
00180       debug_printf("upload %s: %d bytes to pool buffer %p offset %x\n",
00181              cache->name, 
00182              data_size,
00183              (void*)cache->pool->buffer,
00184              offset);
00185 
00186    /* Copy data to the buffer:
00187     */
00188    cache->brw->winsys->buffer_subdata_typed(cache->brw->winsys,
00189                                             cache->pool->buffer, 
00190                                             offset, 
00191                                             data_size, 
00192                                             data,
00193                                             cache->id);
00194 
00195    cache->brw->state.dirty.cache |= 1<<cache->id;
00196    cache->last_addr = offset;
00197 
00198    return offset;
00199 }


Variable Documentation

struct brw_tracked_state brw_active_vertprog

Definition at line 75 of file brw_state.h.

struct brw_tracked_state brw_binding_table_pointers

Definition at line 54 of file brw_state.h.

struct brw_tracked_state brw_blend_constant_color

Definition at line 40 of file brw_state.h.

struct brw_tracked_state brw_cc_unit

Definition at line 41 of file brw_state.h.

struct brw_tracked_state brw_cc_vp

Definition at line 42 of file brw_state.h.

struct brw_tracked_state brw_clear_batch_cache

Definition at line 80 of file brw_state.h.

struct brw_tracked_state brw_clear_surface_cache

Definition at line 79 of file brw_state.h.

struct brw_tracked_state brw_clip_prog

Definition at line 43 of file brw_state.h.

struct brw_tracked_state brw_clip_unit

Definition at line 44 of file brw_state.h.

struct brw_tracked_state brw_constant_buffer

Definition at line 46 of file brw_state.h.

struct brw_tracked_state brw_constant_buffer_state

Definition at line 45 of file brw_state.h.

struct brw_tracked_state brw_curbe_offsets

Definition at line 47 of file brw_state.h.

struct brw_tracked_state brw_depthbuffer

Definition at line 55 of file brw_state.h.

struct brw_tracked_state brw_drawing_rect

Definition at line 51 of file brw_state.h.

struct brw_tracked_state brw_gs_prog

Definition at line 49 of file brw_state.h.

struct brw_tracked_state brw_gs_unit

Definition at line 50 of file brw_state.h.

struct brw_tracked_state brw_invarient_state

Definition at line 48 of file brw_state.h.

struct brw_tracked_state brw_line_stipple

Definition at line 52 of file brw_state.h.

struct brw_tracked_state brw_pipe_control

Definition at line 77 of file brw_state.h.

struct brw_tracked_state brw_pipelined_state_pointers

Definition at line 53 of file brw_state.h.

struct brw_tracked_state brw_polygon_stipple

Definition at line 57 of file brw_state.h.

struct brw_tracked_state brw_polygon_stipple_offset

Definition at line 56 of file brw_state.h.

struct brw_tracked_state brw_program_parameters

Definition at line 58 of file brw_state.h.

struct brw_tracked_state brw_psp_urb_cbs

Definition at line 73 of file brw_state.h.

struct brw_tracked_state brw_recalculate_urb_fence

Definition at line 59 of file brw_state.h.

struct brw_tracked_state brw_sf_prog

Definition at line 60 of file brw_state.h.

struct brw_tracked_state brw_sf_unit

Definition at line 61 of file brw_state.h.

struct brw_tracked_state brw_sf_vp

Definition at line 62 of file brw_state.h.

struct brw_tracked_state brw_state_base_address

Definition at line 63 of file brw_state.h.

struct brw_tracked_state brw_tnl_vertprog

Definition at line 76 of file brw_state.h.

struct brw_tracked_state brw_urb_fence

Definition at line 64 of file brw_state.h.

struct brw_tracked_state brw_vertex_state

Definition at line 65 of file brw_state.h.

struct brw_tracked_state brw_vs_prog

Definition at line 66 of file brw_state.h.

struct brw_tracked_state brw_vs_unit

Definition at line 67 of file brw_state.h.

struct brw_tracked_state brw_wm_prog

Definition at line 68 of file brw_state.h.

struct brw_tracked_state brw_wm_samplers

Definition at line 69 of file brw_state.h.

struct brw_tracked_state brw_wm_surfaces

Definition at line 70 of file brw_state.h.

struct brw_tracked_state brw_wm_unit

Definition at line 71 of file brw_state.h.


Generated on Tue Sep 29 06:25:38 2009 for Gallium3D by  doxygen 1.5.4