tr_winsys.c File Reference

Include dependency graph for tr_winsys.c:

Go to the source code of this file.

Functions

static unsigned trace_buffer_hash (void *buffer)
static int trace_buffer_compare (void *buffer1, void *buffer2)
static const char * trace_winsys_get_name (struct pipe_winsys *_winsys)
static void trace_winsys_flush_frontbuffer (struct pipe_winsys *_winsys, struct pipe_surface *surface, void *context_private)
static struct pipe_surfacetrace_winsys_surface_alloc (struct pipe_winsys *_winsys)
static int trace_winsys_surface_alloc_storage (struct pipe_winsys *_winsys, struct pipe_surface *surface, unsigned width, unsigned height, enum pipe_format format, unsigned flags, unsigned tex_usage)
static void trace_winsys_surface_release (struct pipe_winsys *_winsys, struct pipe_surface **psurface)
static struct pipe_buffertrace_winsys_buffer_create (struct pipe_winsys *_winsys, unsigned alignment, unsigned usage, unsigned size)
static struct pipe_buffertrace_winsys_user_buffer_create (struct pipe_winsys *_winsys, void *data, unsigned size)
void trace_winsys_user_buffer_update (struct pipe_winsys *_winsys, struct pipe_buffer *buffer)
static void * trace_winsys_buffer_map (struct pipe_winsys *_winsys, struct pipe_buffer *buffer, unsigned usage)
static void trace_winsys_buffer_unmap (struct pipe_winsys *_winsys, struct pipe_buffer *buffer)
static void trace_winsys_buffer_destroy (struct pipe_winsys *_winsys, struct pipe_buffer *buffer)
static void trace_winsys_fence_reference (struct pipe_winsys *_winsys, struct pipe_fence_handle **pdst, struct pipe_fence_handle *src)
static int trace_winsys_fence_signalled (struct pipe_winsys *_winsys, struct pipe_fence_handle *fence, unsigned flag)
static int trace_winsys_fence_finish (struct pipe_winsys *_winsys, struct pipe_fence_handle *fence, unsigned flag)
static void trace_winsys_destroy (struct pipe_winsys *_winsys)
struct pipe_winsystrace_winsys_create (struct pipe_winsys *winsys)


Function Documentation

static int trace_buffer_compare ( void *  buffer1,
void *  buffer2 
) [static]

Definition at line 44 of file tr_winsys.c.

00045 {
00046    return (char *)buffer2 - (char *)buffer1;
00047 }

static unsigned trace_buffer_hash ( void *  buffer  )  [static]

Definition at line 38 of file tr_winsys.c.

00039 {
00040    return (unsigned)(uintptr_t)buffer;
00041 }

static struct pipe_buffer* trace_winsys_buffer_create ( struct pipe_winsys _winsys,
unsigned  alignment,
unsigned  usage,
unsigned  size 
) [static, read]

Definition at line 185 of file tr_winsys.c.

References pipe_winsys::buffer_create, pipe_winsys::buffer_map, pipe_winsys::buffer_unmap, PIPE_BUFFER_USAGE_CPU_WRITE, pipe_buffer::size, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_dump_ret, trace_winsys(), pipe_buffer::usage, and trace_winsys::winsys.

00189 {
00190    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00191    struct pipe_winsys *winsys = tr_ws->winsys;
00192    struct pipe_buffer *buffer;
00193    
00194    trace_dump_call_begin("pipe_winsys", "buffer_create");
00195    
00196    trace_dump_arg(ptr, winsys);
00197    trace_dump_arg(uint, alignment);
00198    trace_dump_arg(uint, usage);
00199    trace_dump_arg(uint, size);
00200 
00201    buffer = winsys->buffer_create(winsys, alignment, usage, size);
00202    
00203    trace_dump_ret(ptr, buffer);
00204    
00205    trace_dump_call_end();
00206 
00207    /* Zero the buffer to avoid dumping uninitialized memory */
00208    if(buffer->usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
00209       void *map;
00210       map = winsys->buffer_map(winsys, buffer, PIPE_BUFFER_USAGE_CPU_WRITE);
00211       if(map) {
00212          memset(map, 0, buffer->size);
00213          winsys->buffer_unmap(winsys, buffer);
00214       }
00215    }
00216    
00217    return buffer;
00218 }

static void trace_winsys_buffer_destroy ( struct pipe_winsys _winsys,
struct pipe_buffer buffer 
) [static]

Definition at line 343 of file tr_winsys.c.

References pipe_winsys::buffer_destroy, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_winsys(), and trace_winsys::winsys.

00345 {
00346    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00347    struct pipe_winsys *winsys = tr_ws->winsys;
00348    
00349    trace_dump_call_begin("pipe_winsys", "buffer_destroy");
00350    
00351    trace_dump_arg(ptr, winsys);
00352    trace_dump_arg(ptr, buffer);
00353 
00354    winsys->buffer_destroy(winsys, buffer);
00355    
00356    trace_dump_call_end();
00357 }

static void* trace_winsys_buffer_map ( struct pipe_winsys _winsys,
struct pipe_buffer buffer,
unsigned  usage 
) [static]

Definition at line 289 of file tr_winsys.c.

References assert, pipe_winsys::buffer_map, trace_winsys::buffer_maps, hash_table_get(), hash_table_set(), PIPE_BUFFER_USAGE_CPU_WRITE, trace_winsys(), and trace_winsys::winsys.

00292 {
00293    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00294    struct pipe_winsys *winsys = tr_ws->winsys;
00295    void *map;
00296    
00297    map = winsys->buffer_map(winsys, buffer, usage);
00298    if(map) {
00299       if(usage & PIPE_BUFFER_USAGE_CPU_WRITE) {
00300          assert(!hash_table_get(tr_ws->buffer_maps, buffer));
00301          hash_table_set(tr_ws->buffer_maps, buffer, map);
00302       }
00303    }
00304    
00305    return map;
00306 }

static void trace_winsys_buffer_unmap ( struct pipe_winsys _winsys,
struct pipe_buffer buffer 
) [static]

Definition at line 310 of file tr_winsys.c.

References trace_winsys::buffer_maps, pipe_winsys::buffer_unmap, hash_table_get(), hash_table_remove(), pipe_buffer::size, trace_dump_arg, trace_dump_arg_begin(), trace_dump_arg_end(), trace_dump_bytes(), trace_dump_call_begin(), trace_dump_call_end(), trace_dump_uint(), trace_winsys(), and trace_winsys::winsys.

00312 {
00313    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00314    struct pipe_winsys *winsys = tr_ws->winsys;
00315    const void *map;
00316    
00317    map = hash_table_get(tr_ws->buffer_maps, buffer);
00318    if(map) {
00319       trace_dump_call_begin("pipe_winsys", "buffer_write");
00320       
00321       trace_dump_arg(ptr, winsys);
00322       
00323       trace_dump_arg(ptr, buffer);
00324       
00325       trace_dump_arg_begin("data");
00326       trace_dump_bytes(map, buffer->size);
00327       trace_dump_arg_end();
00328 
00329       trace_dump_arg_begin("size");
00330       trace_dump_uint(buffer->size);
00331       trace_dump_arg_end();
00332    
00333       trace_dump_call_end();
00334 
00335       hash_table_remove(tr_ws->buffer_maps, buffer);
00336    }
00337    
00338    winsys->buffer_unmap(winsys, buffer);
00339 }

struct pipe_winsys* trace_winsys_create ( struct pipe_winsys winsys  )  [read]

Definition at line 454 of file tr_winsys.c.

References trace_winsys::base, pipe_winsys::buffer_create, pipe_winsys::buffer_destroy, pipe_winsys::buffer_map, trace_winsys::buffer_maps, pipe_winsys::buffer_unmap, CALLOC_STRUCT, pipe_winsys::destroy, pipe_winsys::fence_finish, pipe_winsys::fence_reference, pipe_winsys::fence_signalled, pipe_winsys::flush_frontbuffer, FREE, pipe_winsys::get_name, hash_table_create(), pipe_winsys::surface_alloc, pipe_winsys::surface_alloc_storage, pipe_winsys::surface_release, trace_buffer_compare(), trace_buffer_hash(), trace_dump_call_begin(), trace_dump_call_end(), trace_dump_ret, trace_winsys_buffer_create(), trace_winsys_buffer_destroy(), trace_winsys_buffer_map(), trace_winsys_buffer_unmap(), trace_winsys_destroy(), trace_winsys_fence_finish(), trace_winsys_fence_reference(), trace_winsys_fence_signalled(), trace_winsys_flush_frontbuffer(), trace_winsys_get_name(), trace_winsys_surface_alloc(), trace_winsys_surface_alloc_storage(), trace_winsys_surface_release(), trace_winsys_user_buffer_create(), pipe_winsys::user_buffer_create, and trace_winsys::winsys.

00455 {
00456    struct trace_winsys *tr_ws;
00457    
00458    if(!winsys)
00459       goto error1;
00460    
00461    tr_ws = CALLOC_STRUCT(trace_winsys);
00462    if(!tr_ws)
00463       goto error1;
00464 
00465    tr_ws->base.destroy = trace_winsys_destroy;
00466    tr_ws->base.get_name = trace_winsys_get_name;
00467    tr_ws->base.flush_frontbuffer = trace_winsys_flush_frontbuffer;
00468    tr_ws->base.surface_alloc = trace_winsys_surface_alloc;
00469    tr_ws->base.surface_alloc_storage = trace_winsys_surface_alloc_storage;
00470    tr_ws->base.surface_release = trace_winsys_surface_release;
00471    tr_ws->base.buffer_create = trace_winsys_buffer_create;
00472    tr_ws->base.user_buffer_create = trace_winsys_user_buffer_create;
00473    tr_ws->base.buffer_map = trace_winsys_buffer_map;
00474    tr_ws->base.buffer_unmap = trace_winsys_buffer_unmap;
00475    tr_ws->base.buffer_destroy = trace_winsys_buffer_destroy;
00476    tr_ws->base.fence_reference = trace_winsys_fence_reference;
00477    tr_ws->base.fence_signalled = trace_winsys_fence_signalled;
00478    tr_ws->base.fence_finish = trace_winsys_fence_finish;
00479    
00480    tr_ws->winsys = winsys;
00481 
00482    tr_ws->buffer_maps = hash_table_create(trace_buffer_hash, 
00483                                           trace_buffer_compare);
00484    if(!tr_ws->buffer_maps)
00485       goto error2;
00486    
00487    trace_dump_call_begin("", "pipe_winsys_create");
00488    trace_dump_ret(ptr, winsys);
00489    trace_dump_call_end();
00490 
00491    return &tr_ws->base;
00492    
00493 error2:
00494    FREE(tr_ws);
00495 error1:
00496    return winsys;
00497 }

static void trace_winsys_destroy ( struct pipe_winsys _winsys  )  [static]

Definition at line 432 of file tr_winsys.c.

References trace_winsys::buffer_maps, FREE, hash_table_destroy(), trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_winsys(), and trace_winsys::winsys.

00433 {
00434    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00435    struct pipe_winsys *winsys = tr_ws->winsys;
00436    
00437    trace_dump_call_begin("pipe_winsys", "destroy");
00438    
00439    trace_dump_arg(ptr, winsys);
00440 
00441    /* 
00442    winsys->destroy(winsys); 
00443    */
00444    
00445    trace_dump_call_end();
00446    
00447    hash_table_destroy(tr_ws->buffer_maps);
00448 
00449    FREE(tr_ws);
00450 }

static int trace_winsys_fence_finish ( struct pipe_winsys _winsys,
struct pipe_fence_handle *  fence,
unsigned  flag 
) [static]

Definition at line 407 of file tr_winsys.c.

References pipe_winsys::fence_finish, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_dump_ret, trace_winsys(), and trace_winsys::winsys.

00410 {
00411    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00412    struct pipe_winsys *winsys = tr_ws->winsys;
00413    int result;
00414    
00415    trace_dump_call_begin("pipe_winsys", "fence_finish");
00416    
00417    trace_dump_arg(ptr, winsys);
00418    trace_dump_arg(ptr, fence);
00419    trace_dump_arg(uint, flag);
00420 
00421    result = winsys->fence_finish(winsys, fence, flag);
00422    
00423    trace_dump_ret(int, result);
00424    
00425    trace_dump_call_end();
00426    
00427    return result;
00428 }

static void trace_winsys_fence_reference ( struct pipe_winsys _winsys,
struct pipe_fence_handle **  pdst,
struct pipe_fence_handle *  src 
) [static]

Definition at line 361 of file tr_winsys.c.

References pipe_winsys::fence_reference, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_winsys(), and trace_winsys::winsys.

00364 {
00365    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00366    struct pipe_winsys *winsys = tr_ws->winsys;
00367    struct pipe_fence_handle *dst = *pdst;
00368    
00369    trace_dump_call_begin("pipe_winsys", "fence_reference");
00370    
00371    trace_dump_arg(ptr, winsys);
00372    trace_dump_arg(ptr, dst);
00373    trace_dump_arg(ptr, src);
00374 
00375    winsys->fence_reference(winsys, pdst, src);
00376    
00377    trace_dump_call_end();
00378 }

static int trace_winsys_fence_signalled ( struct pipe_winsys _winsys,
struct pipe_fence_handle *  fence,
unsigned  flag 
) [static]

Definition at line 382 of file tr_winsys.c.

References pipe_winsys::fence_signalled, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_dump_ret, trace_winsys(), and trace_winsys::winsys.

00385 {
00386    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00387    struct pipe_winsys *winsys = tr_ws->winsys;
00388    int result;
00389    
00390    trace_dump_call_begin("pipe_winsys", "fence_signalled");
00391    
00392    trace_dump_arg(ptr, winsys);
00393    trace_dump_arg(ptr, fence);
00394    trace_dump_arg(uint, flag);
00395 
00396    result = winsys->fence_signalled(winsys, fence, flag);
00397    
00398    trace_dump_ret(int, result);
00399    
00400    trace_dump_call_end();
00401    
00402    return result;
00403 }

static void trace_winsys_flush_frontbuffer ( struct pipe_winsys _winsys,
struct pipe_surface surface,
void *  context_private 
) [static]

Definition at line 72 of file tr_winsys.c.

References assert, pipe_winsys::flush_frontbuffer, pipe_texture::screen, trace_surface::surface, pipe_surface::texture, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_screen(), trace_surface(), trace_texture(), trace_winsys(), and trace_winsys::winsys.

00075 {
00076    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00077    struct pipe_winsys *winsys = tr_ws->winsys;
00078 
00079    assert(surface);
00080    if(surface->texture) {
00081       struct trace_screen *tr_scr = trace_screen(surface->texture->screen);
00082       struct trace_texture *tr_tex = trace_texture(tr_scr, surface->texture);
00083       struct trace_surface *tr_surf = trace_surface(tr_tex, surface);
00084       surface = tr_surf->surface;
00085    }
00086    
00087    trace_dump_call_begin("pipe_winsys", "flush_frontbuffer");
00088    
00089    trace_dump_arg(ptr, winsys);
00090    trace_dump_arg(ptr, surface);
00091    /* XXX: hide, as there is nothing we can do with this
00092    trace_dump_arg(ptr, context_private);
00093    */
00094 
00095    winsys->flush_frontbuffer(winsys, surface, context_private);
00096    
00097    trace_dump_call_end();
00098 }

static const char* trace_winsys_get_name ( struct pipe_winsys _winsys  )  [static]

Definition at line 51 of file tr_winsys.c.

References pipe_winsys::get_name, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_dump_ret, trace_winsys(), and trace_winsys::winsys.

00052 {
00053    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00054    struct pipe_winsys *winsys = tr_ws->winsys;
00055    const char *result;
00056    
00057    trace_dump_call_begin("pipe_winsys", "get_name");
00058    
00059    trace_dump_arg(ptr, winsys);
00060 
00061    result = winsys->get_name(winsys);
00062    
00063    trace_dump_ret(string, result);
00064    
00065    trace_dump_call_end();
00066    
00067    return result;
00068 }

static struct pipe_surface* trace_winsys_surface_alloc ( struct pipe_winsys _winsys  )  [static, read]

Definition at line 102 of file tr_winsys.c.

References assert, pipe_winsys::surface_alloc, pipe_surface::texture, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_dump_ret, trace_winsys(), and trace_winsys::winsys.

00103 {
00104    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00105    struct pipe_winsys *winsys = tr_ws->winsys;
00106    struct pipe_surface *result;
00107    
00108    trace_dump_call_begin("pipe_winsys", "surface_alloc");
00109    
00110    trace_dump_arg(ptr, winsys);
00111 
00112    result = winsys->surface_alloc(winsys);
00113    
00114    trace_dump_ret(ptr, result);
00115    
00116    trace_dump_call_end();
00117    
00118    assert(!result || !result->texture);
00119 
00120    return result;
00121 }

static int trace_winsys_surface_alloc_storage ( struct pipe_winsys _winsys,
struct pipe_surface surface,
unsigned  width,
unsigned  height,
enum pipe_format  format,
unsigned  flags,
unsigned  tex_usage 
) [static]

Definition at line 125 of file tr_winsys.c.

References assert, pipe_winsys::surface_alloc_storage, pipe_surface::texture, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_dump_ret, trace_winsys(), and trace_winsys::winsys.

00131 {
00132    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00133    struct pipe_winsys *winsys = tr_ws->winsys;
00134    int result;
00135    
00136    assert(surface && !surface->texture);
00137 
00138    trace_dump_call_begin("pipe_winsys", "surface_alloc_storage");
00139    
00140    trace_dump_arg(ptr, winsys);
00141    trace_dump_arg(ptr, surface);
00142    trace_dump_arg(uint, width);
00143    trace_dump_arg(uint, height);
00144    trace_dump_arg(format, format);
00145    trace_dump_arg(uint, flags);
00146    trace_dump_arg(uint, tex_usage);
00147 
00148    result = winsys->surface_alloc_storage(winsys,
00149                                           surface,
00150                                           width, height,
00151                                           format,
00152                                           flags,
00153                                           tex_usage);
00154    
00155    trace_dump_ret(int, result);
00156    
00157    trace_dump_call_end();
00158    
00159    return result;
00160 }

static void trace_winsys_surface_release ( struct pipe_winsys _winsys,
struct pipe_surface **  psurface 
) [static]

Definition at line 164 of file tr_winsys.c.

References assert, pipe_winsys::surface_release, pipe_surface::texture, trace_dump_arg, trace_dump_call_begin(), trace_dump_call_end(), trace_winsys(), and trace_winsys::winsys.

00166 {
00167    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00168    struct pipe_winsys *winsys = tr_ws->winsys;
00169    struct pipe_surface *surface = *psurface;
00170    
00171    assert(psurface && *psurface && !(*psurface)->texture);
00172    
00173    trace_dump_call_begin("pipe_winsys", "surface_release");
00174    
00175    trace_dump_arg(ptr, winsys);
00176    trace_dump_arg(ptr, surface);
00177 
00178    winsys->surface_release(winsys, psurface);
00179    
00180    trace_dump_call_end();
00181 }

static struct pipe_buffer* trace_winsys_user_buffer_create ( struct pipe_winsys _winsys,
void *  data,
unsigned  size 
) [static, read]

Definition at line 222 of file tr_winsys.c.

References assert, TRACE_BUFFER_USAGE_USER, trace_dump_arg, trace_dump_arg_begin(), trace_dump_arg_end(), trace_dump_bytes(), trace_dump_call_begin(), trace_dump_call_end(), trace_dump_ret, trace_winsys(), pipe_buffer::usage, pipe_winsys::user_buffer_create, and trace_winsys::winsys.

00225 {
00226    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00227    struct pipe_winsys *winsys = tr_ws->winsys;
00228    struct pipe_buffer *result;
00229    
00230    trace_dump_call_begin("pipe_winsys", "user_buffer_create");
00231    
00232    trace_dump_arg(ptr, winsys);
00233    trace_dump_arg_begin("data");
00234    trace_dump_bytes(data, size);
00235    trace_dump_arg_end();
00236    trace_dump_arg(uint, size);
00237 
00238    result = winsys->user_buffer_create(winsys, data, size);
00239    
00240    trace_dump_ret(ptr, result);
00241    
00242    trace_dump_call_end();
00243    
00244    /* XXX: Mark the user buffers. (we should wrap pipe_buffers, but is is 
00245     * impossible to do so while texture-less surfaces are still around */
00246    if(result) {
00247       assert(!(result->usage & TRACE_BUFFER_USAGE_USER));
00248       result->usage |= TRACE_BUFFER_USAGE_USER;
00249    }
00250    
00251    return result;
00252 }

void trace_winsys_user_buffer_update ( struct pipe_winsys _winsys,
struct pipe_buffer buffer 
)

Definition at line 256 of file tr_winsys.c.

References pipe_winsys::buffer_map, pipe_winsys::buffer_unmap, PIPE_BUFFER_USAGE_CPU_READ, pipe_buffer::size, TRACE_BUFFER_USAGE_USER, trace_dump_arg, trace_dump_arg_begin(), trace_dump_arg_end(), trace_dump_bytes(), trace_dump_call_begin(), trace_dump_call_end(), trace_dump_uint(), trace_winsys(), pipe_buffer::usage, and trace_winsys::winsys.

00258 {
00259    struct trace_winsys *tr_ws = trace_winsys(_winsys);
00260    struct pipe_winsys *winsys = tr_ws->winsys;
00261    const void *map;
00262    
00263    if(buffer && buffer->usage & TRACE_BUFFER_USAGE_USER) {
00264       map = winsys->buffer_map(winsys, buffer, PIPE_BUFFER_USAGE_CPU_READ);
00265       if(map) {
00266          trace_dump_call_begin("pipe_winsys", "buffer_write");
00267          
00268          trace_dump_arg(ptr, winsys);
00269          
00270          trace_dump_arg(ptr, buffer);
00271          
00272          trace_dump_arg_begin("data");
00273          trace_dump_bytes(map, buffer->size);
00274          trace_dump_arg_end();
00275       
00276          trace_dump_arg_begin("size");
00277          trace_dump_uint(buffer->size);
00278          trace_dump_arg_end();
00279       
00280          trace_dump_call_end();
00281          
00282          winsys->buffer_unmap(winsys, buffer);
00283       }
00284    }
00285 }


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