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 #include "util/u_memory.h"
00029
00030 #include "tr_dump.h"
00031 #include "tr_state.h"
00032 #include "tr_winsys.h"
00033 #include "tr_texture.h"
00034 #include "tr_screen.h"
00035
00036
00037 static const char *
00038 trace_screen_get_name(struct pipe_screen *_screen)
00039 {
00040 struct trace_screen *tr_scr = trace_screen(_screen);
00041 struct pipe_screen *screen = tr_scr->screen;
00042 const char *result;
00043
00044 trace_dump_call_begin("pipe_screen", "get_name");
00045
00046 trace_dump_arg(ptr, screen);
00047
00048 result = screen->get_name(screen);
00049
00050 trace_dump_ret(string, result);
00051
00052 trace_dump_call_end();
00053
00054 return result;
00055 }
00056
00057
00058 static const char *
00059 trace_screen_get_vendor(struct pipe_screen *_screen)
00060 {
00061 struct trace_screen *tr_scr = trace_screen(_screen);
00062 struct pipe_screen *screen = tr_scr->screen;
00063 const char *result;
00064
00065 trace_dump_call_begin("pipe_screen", "get_vendor");
00066
00067 trace_dump_arg(ptr, screen);
00068
00069 result = screen->get_vendor(screen);
00070
00071 trace_dump_ret(string, result);
00072
00073 trace_dump_call_end();
00074
00075 return result;
00076 }
00077
00078
00079 static int
00080 trace_screen_get_param(struct pipe_screen *_screen,
00081 int param)
00082 {
00083 struct trace_screen *tr_scr = trace_screen(_screen);
00084 struct pipe_screen *screen = tr_scr->screen;
00085 int result;
00086
00087 trace_dump_call_begin("pipe_screen", "get_param");
00088
00089 trace_dump_arg(ptr, screen);
00090 trace_dump_arg(int, param);
00091
00092 result = screen->get_param(screen, param);
00093
00094 trace_dump_ret(int, result);
00095
00096 trace_dump_call_end();
00097
00098 return result;
00099 }
00100
00101
00102 static float
00103 trace_screen_get_paramf(struct pipe_screen *_screen,
00104 int param)
00105 {
00106 struct trace_screen *tr_scr = trace_screen(_screen);
00107 struct pipe_screen *screen = tr_scr->screen;
00108 float result;
00109
00110 trace_dump_call_begin("pipe_screen", "get_paramf");
00111
00112 trace_dump_arg(ptr, screen);
00113 trace_dump_arg(int, param);
00114
00115 result = screen->get_paramf(screen, param);
00116
00117 trace_dump_ret(float, result);
00118
00119 trace_dump_call_end();
00120
00121 return result;
00122 }
00123
00124
00125 static boolean
00126 trace_screen_is_format_supported(struct pipe_screen *_screen,
00127 enum pipe_format format,
00128 enum pipe_texture_target target,
00129 unsigned tex_usage,
00130 unsigned geom_flags)
00131 {
00132 struct trace_screen *tr_scr = trace_screen(_screen);
00133 struct pipe_screen *screen = tr_scr->screen;
00134 boolean result;
00135
00136 trace_dump_call_begin("pipe_screen", "is_format_supported");
00137
00138 trace_dump_arg(ptr, screen);
00139 trace_dump_arg(format, format);
00140 trace_dump_arg(int, target);
00141 trace_dump_arg(uint, tex_usage);
00142 trace_dump_arg(uint, geom_flags);
00143
00144 result = screen->is_format_supported(screen, format, target, tex_usage, geom_flags);
00145
00146 trace_dump_ret(bool, result);
00147
00148 trace_dump_call_end();
00149
00150 return result;
00151 }
00152
00153
00154 static struct pipe_texture *
00155 trace_screen_texture_create(struct pipe_screen *_screen,
00156 const struct pipe_texture *templat)
00157 {
00158 struct trace_screen *tr_scr = trace_screen(_screen);
00159 struct pipe_screen *screen = tr_scr->screen;
00160 struct pipe_texture *result;
00161
00162 trace_dump_call_begin("pipe_screen", "texture_create");
00163
00164 trace_dump_arg(ptr, screen);
00165 trace_dump_arg(template, templat);
00166
00167 result = screen->texture_create(screen, templat);
00168
00169 trace_dump_ret(ptr, result);
00170
00171 trace_dump_call_end();
00172
00173 result = trace_texture_create(tr_scr, result);
00174
00175 return result;
00176 }
00177
00178
00179 static struct pipe_texture *
00180 trace_screen_texture_blanket(struct pipe_screen *_screen,
00181 const struct pipe_texture *templat,
00182 const unsigned *ppitch,
00183 struct pipe_buffer *buffer)
00184 {
00185 struct trace_screen *tr_scr = trace_screen(_screen);
00186 struct pipe_screen *screen = tr_scr->screen;
00187 unsigned pitch = *ppitch;
00188 struct pipe_texture *result;
00189
00190 trace_dump_call_begin("pipe_screen", "texture_blanket");
00191
00192 trace_dump_arg(ptr, screen);
00193 trace_dump_arg(template, templat);
00194 trace_dump_arg(uint, pitch);
00195 trace_dump_arg(ptr, buffer);
00196
00197 result = screen->texture_blanket(screen, templat, ppitch, buffer);
00198
00199 trace_dump_ret(ptr, result);
00200
00201 trace_dump_call_end();
00202
00203 result = trace_texture_create(tr_scr, result);
00204
00205 return result;
00206 }
00207
00208
00209 static void
00210 trace_screen_texture_release(struct pipe_screen *_screen,
00211 struct pipe_texture **ptexture)
00212 {
00213 struct trace_screen *tr_scr = trace_screen(_screen);
00214 struct pipe_screen *screen = tr_scr->screen;
00215 struct trace_texture *tr_tex;
00216 struct pipe_texture *texture;
00217
00218 assert(ptexture);
00219 if(*ptexture) {
00220 tr_tex = trace_texture(tr_scr, *ptexture);
00221 texture = tr_tex->texture;
00222 assert(texture->screen == screen);
00223 }
00224 else
00225 texture = NULL;
00226
00227 if (*ptexture) {
00228 if (!--(*ptexture)->refcount) {
00229 trace_dump_call_begin("pipe_screen", "texture_destroy");
00230
00231 trace_dump_arg(ptr, screen);
00232 trace_dump_arg(ptr, texture);
00233
00234 trace_texture_destroy(tr_scr, *ptexture);
00235
00236 trace_dump_call_end();
00237 }
00238
00239 *ptexture = NULL;
00240 }
00241 }
00242
00243
00244 static struct pipe_surface *
00245 trace_screen_get_tex_surface(struct pipe_screen *_screen,
00246 struct pipe_texture *texture,
00247 unsigned face, unsigned level,
00248 unsigned zslice,
00249 unsigned usage)
00250 {
00251 struct trace_screen *tr_scr = trace_screen(_screen);
00252 struct pipe_screen *screen = tr_scr->screen;
00253 struct trace_texture *tr_tex;
00254 struct pipe_surface *result;
00255
00256 assert(texture);
00257 tr_tex = trace_texture(tr_scr, texture);
00258 texture = tr_tex->texture;
00259 assert(texture->screen == screen);
00260
00261 trace_dump_call_begin("pipe_screen", "get_tex_surface");
00262
00263 trace_dump_arg(ptr, screen);
00264 trace_dump_arg(ptr, texture);
00265 trace_dump_arg(uint, face);
00266 trace_dump_arg(uint, level);
00267 trace_dump_arg(uint, zslice);
00268 trace_dump_arg(uint, usage);
00269
00270 result = screen->get_tex_surface(screen, texture, face, level, zslice, usage);
00271
00272 trace_dump_ret(ptr, result);
00273
00274 trace_dump_call_end();
00275
00276 result = trace_surface_create(tr_tex, result);
00277
00278 return result;
00279 }
00280
00281
00282 static void
00283 trace_screen_tex_surface_release(struct pipe_screen *_screen,
00284 struct pipe_surface **psurface)
00285 {
00286 struct trace_screen *tr_scr = trace_screen(_screen);
00287 struct pipe_screen *screen = tr_scr->screen;
00288 struct trace_texture *tr_tex;
00289 struct trace_surface *tr_surf;
00290 struct pipe_surface *surface;
00291
00292 assert(psurface);
00293 if(*psurface) {
00294 tr_tex = trace_texture(tr_scr, (*psurface)->texture);
00295 tr_surf = trace_surface(tr_tex, *psurface);
00296 surface = tr_surf->surface;
00297 }
00298 else
00299 surface = NULL;
00300
00301 if (*psurface) {
00302 if (!--(*psurface)->refcount) {
00303 trace_dump_call_begin("pipe_screen", "tex_surface_destroy");
00304
00305 trace_dump_arg(ptr, screen);
00306 trace_dump_arg(ptr, surface);
00307
00308 trace_surface_destroy(tr_tex, *psurface);
00309
00310 trace_dump_call_end();
00311 }
00312
00313 *psurface = NULL;
00314 }
00315 }
00316
00317
00318 static void *
00319 trace_screen_surface_map(struct pipe_screen *_screen,
00320 struct pipe_surface *surface,
00321 unsigned flags)
00322 {
00323 struct trace_screen *tr_scr = trace_screen(_screen);
00324 struct pipe_screen *screen = tr_scr->screen;
00325 struct trace_texture *tr_tex;
00326 struct trace_surface *tr_surf;
00327 void *map;
00328
00329 tr_tex = trace_texture(tr_scr, surface->texture);
00330 tr_surf = trace_surface(tr_tex, surface);
00331 surface = tr_surf->surface;
00332
00333 map = screen->surface_map(screen, surface, flags);
00334 if(map) {
00335 if(flags & PIPE_BUFFER_USAGE_CPU_WRITE) {
00336 assert(!tr_surf->map);
00337 tr_surf->map = map;
00338 }
00339 }
00340
00341 return map;
00342 }
00343
00344
00345 static void
00346 trace_screen_surface_unmap(struct pipe_screen *_screen,
00347 struct pipe_surface *surface)
00348 {
00349 struct trace_screen *tr_scr = trace_screen(_screen);
00350 struct pipe_screen *screen = tr_scr->screen;
00351 struct trace_texture *tr_tex;
00352 struct trace_surface *tr_surf;
00353
00354 tr_tex = trace_texture(tr_scr, surface->texture);
00355 tr_surf = trace_surface(tr_tex, surface);
00356 surface = tr_surf->surface;
00357
00358 if(tr_surf->map) {
00359 size_t size = surface->nblocksy * surface->stride;
00360
00361 trace_dump_call_begin("pipe_winsys", "surface_write");
00362
00363 trace_dump_arg(ptr, screen);
00364
00365 trace_dump_arg(ptr, surface);
00366
00367 trace_dump_arg_begin("data");
00368 trace_dump_bytes(tr_surf->map, size);
00369 trace_dump_arg_end();
00370
00371 trace_dump_arg_begin("stride");
00372 trace_dump_uint(surface->stride);
00373 trace_dump_arg_end();
00374
00375 trace_dump_arg_begin("size");
00376 trace_dump_uint(size);
00377 trace_dump_arg_end();
00378
00379 trace_dump_call_end();
00380
00381 tr_surf->map = NULL;
00382 }
00383
00384 screen->surface_unmap(screen, surface);
00385 }
00386
00387
00388 static void
00389 trace_screen_destroy(struct pipe_screen *_screen)
00390 {
00391 struct trace_screen *tr_scr = trace_screen(_screen);
00392 struct pipe_screen *screen = tr_scr->screen;
00393
00394 trace_dump_call_begin("pipe_screen", "destroy");
00395
00396 trace_dump_arg(ptr, screen);
00397
00398 screen->destroy(screen);
00399
00400 trace_dump_call_end();
00401
00402 trace_dump_trace_end();
00403
00404 FREE(tr_scr);
00405 }
00406
00407
00408 struct pipe_screen *
00409 trace_screen_create(struct pipe_screen *screen)
00410 {
00411 struct trace_screen *tr_scr;
00412 struct pipe_winsys *winsys;
00413
00414 if(!screen)
00415 goto error1;
00416
00417 if(!trace_dump_trace_begin())
00418 goto error1;
00419
00420 tr_scr = CALLOC_STRUCT(trace_screen);
00421 if(!tr_scr)
00422 goto error2;
00423
00424 winsys = trace_winsys_create(screen->winsys);
00425 if(!winsys)
00426 goto error3;
00427
00428 tr_scr->base.winsys = winsys;
00429 tr_scr->base.destroy = trace_screen_destroy;
00430 tr_scr->base.get_name = trace_screen_get_name;
00431 tr_scr->base.get_vendor = trace_screen_get_vendor;
00432 tr_scr->base.get_param = trace_screen_get_param;
00433 tr_scr->base.get_paramf = trace_screen_get_paramf;
00434 tr_scr->base.is_format_supported = trace_screen_is_format_supported;
00435 tr_scr->base.texture_create = trace_screen_texture_create;
00436 tr_scr->base.texture_blanket = trace_screen_texture_blanket;
00437 tr_scr->base.texture_release = trace_screen_texture_release;
00438 tr_scr->base.get_tex_surface = trace_screen_get_tex_surface;
00439 tr_scr->base.tex_surface_release = trace_screen_tex_surface_release;
00440 tr_scr->base.surface_map = trace_screen_surface_map;
00441 tr_scr->base.surface_unmap = trace_screen_surface_unmap;
00442
00443 tr_scr->screen = screen;
00444
00445 trace_dump_call_begin("", "pipe_screen_create");
00446 trace_dump_arg_begin("winsys");
00447 trace_dump_ptr(screen->winsys);
00448 trace_dump_arg_end();
00449 trace_dump_ret(ptr, screen);
00450 trace_dump_call_end();
00451
00452 return &tr_scr->base;
00453
00454 error3:
00455 FREE(tr_scr);
00456 error2:
00457 trace_dump_trace_end();
00458 error1:
00459 return screen;
00460 }
00461
00462
00463 struct trace_screen *
00464 trace_screen(struct pipe_screen *screen)
00465 {
00466 assert(screen);
00467 assert(screen->destroy == trace_screen_destroy);
00468 return (struct trace_screen *)screen;
00469 }