tr_context.c

Go to the documentation of this file.
00001 /**************************************************************************
00002  *
00003  * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas.
00004  * All Rights Reserved.
00005  *
00006  * Permission is hereby granted, free of charge, to any person obtaining a
00007  * copy of this software and associated documentation files (the
00008  * "Software"), to deal in the Software without restriction, including
00009  * without limitation the rights to use, copy, modify, merge, publish,
00010  * distribute, sub license, and/or sell copies of the Software, and to
00011  * permit persons to whom the Software is furnished to do so, subject to
00012  * the following conditions:
00013  *
00014  * The above copyright notice and this permission notice (including the
00015  * next paragraph) shall be included in all copies or substantial portions
00016  * of the Software.
00017  *
00018  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
00019  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
00020  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
00021  * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR
00022  * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
00023  * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
00024  * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
00025  *
00026  **************************************************************************/
00027 
00028 #include "util/u_memory.h"
00029 #include "pipe/p_screen.h"
00030 
00031 #include "tr_dump.h"
00032 #include "tr_state.h"
00033 #include "tr_screen.h"
00034 #include "tr_texture.h"
00035 #include "tr_winsys.h"
00036 #include "tr_context.h"
00037 
00038 
00039 static INLINE struct pipe_texture * 
00040 trace_texture_unwrap(struct trace_context *tr_ctx,
00041                      struct pipe_texture *texture)
00042 {
00043    struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); 
00044    struct trace_texture *tr_tex;
00045    
00046    if(!texture)
00047       return NULL;
00048    
00049    tr_tex = trace_texture(tr_scr, texture);
00050    
00051    assert(tr_tex->texture);
00052    assert(tr_tex->texture->screen == tr_scr->screen);
00053    return tr_tex->texture;
00054 }
00055 
00056 
00057 static INLINE struct pipe_surface * 
00058 trace_surface_unwrap(struct trace_context *tr_ctx,
00059                      struct pipe_surface *surface)
00060 {
00061    struct trace_screen *tr_scr = trace_screen(tr_ctx->base.screen); 
00062    struct trace_texture *tr_tex;
00063    struct trace_surface *tr_surf;
00064    
00065    if(!surface)
00066       return NULL;
00067 
00068    assert(surface->texture);
00069    if(!surface->texture)
00070       return surface;
00071    
00072    tr_tex = trace_texture(tr_scr, surface->texture);
00073    tr_surf = trace_surface(tr_tex, surface);
00074    
00075    assert(tr_surf->surface);
00076    assert(tr_surf->surface->texture->screen == tr_scr->screen);
00077    return tr_surf->surface;
00078 }
00079 
00080 
00081 static INLINE void
00082 trace_context_set_edgeflags(struct pipe_context *_pipe,
00083                             const unsigned *bitfield)
00084 {
00085    struct trace_context *tr_ctx = trace_context(_pipe);
00086    struct pipe_context *pipe = tr_ctx->pipe;
00087 
00088    trace_dump_call_begin("pipe_context", "set_edgeflags");
00089    
00090    trace_dump_arg(ptr, pipe);
00091    /* FIXME: we don't know how big this array is */
00092    trace_dump_arg(ptr, bitfield);
00093 
00094    pipe->set_edgeflags(pipe, bitfield);;
00095 
00096    trace_dump_call_end();
00097 }
00098 
00099 
00100 static INLINE boolean
00101 trace_context_draw_arrays(struct pipe_context *_pipe,
00102                           unsigned mode, unsigned start, unsigned count)
00103 {
00104    struct trace_context *tr_ctx = trace_context(_pipe);
00105    struct pipe_context *pipe = tr_ctx->pipe;
00106    boolean result;
00107 
00108    trace_dump_call_begin("pipe_context", "draw_arrays");
00109 
00110    trace_dump_arg(ptr, pipe);
00111    trace_dump_arg(uint, mode);
00112    trace_dump_arg(uint, start);
00113    trace_dump_arg(uint, count);
00114 
00115    result = pipe->draw_arrays(pipe, mode, start, count);;
00116 
00117    trace_dump_ret(bool, result);
00118    
00119    trace_dump_call_end();
00120    
00121    return result;
00122 }
00123 
00124 
00125 static INLINE boolean
00126 trace_context_draw_elements(struct pipe_context *_pipe,
00127                           struct pipe_buffer *indexBuffer,
00128                           unsigned indexSize,
00129                           unsigned mode, unsigned start, unsigned count)
00130 {
00131    struct trace_context *tr_ctx = trace_context(_pipe);
00132    struct pipe_context *pipe = tr_ctx->pipe;
00133    boolean result;
00134 
00135    trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
00136 
00137    trace_dump_call_begin("pipe_context", "draw_elements");
00138 
00139    trace_dump_arg(ptr, pipe);
00140    trace_dump_arg(ptr, indexBuffer);
00141    trace_dump_arg(uint, indexSize);
00142    trace_dump_arg(uint, mode);
00143    trace_dump_arg(uint, start);
00144    trace_dump_arg(uint, count);
00145 
00146    result = pipe->draw_elements(pipe, indexBuffer, indexSize, mode, start, count);;
00147 
00148    trace_dump_ret(bool, result);
00149    
00150    trace_dump_call_end();
00151    
00152    return result;
00153 }
00154 
00155 
00156 static INLINE boolean
00157 trace_context_draw_range_elements(struct pipe_context *_pipe,
00158                                   struct pipe_buffer *indexBuffer,
00159                                   unsigned indexSize,
00160                                   unsigned minIndex,
00161                                   unsigned maxIndex,
00162                                   unsigned mode, 
00163                                   unsigned start, 
00164                                   unsigned count)
00165 {
00166    struct trace_context *tr_ctx = trace_context(_pipe);
00167    struct pipe_context *pipe = tr_ctx->pipe;
00168    boolean result;
00169 
00170    trace_winsys_user_buffer_update(_pipe->winsys, indexBuffer);
00171 
00172    trace_dump_call_begin("pipe_context", "draw_range_elements");
00173 
00174    trace_dump_arg(ptr, pipe);
00175    trace_dump_arg(ptr, indexBuffer);
00176    trace_dump_arg(uint, indexSize);
00177    trace_dump_arg(uint, minIndex);
00178    trace_dump_arg(uint, maxIndex);
00179    trace_dump_arg(uint, mode);
00180    trace_dump_arg(uint, start);
00181    trace_dump_arg(uint, count);
00182 
00183    result = pipe->draw_range_elements(pipe, 
00184                                       indexBuffer, 
00185                                       indexSize, minIndex, maxIndex, 
00186                                       mode, start, count);
00187    
00188    trace_dump_ret(bool, result);
00189    
00190    trace_dump_call_end();
00191    
00192    return result;
00193 }
00194 
00195 
00196 static INLINE struct pipe_query *
00197 trace_context_create_query(struct pipe_context *_pipe,
00198                            unsigned query_type)
00199 {
00200    struct trace_context *tr_ctx = trace_context(_pipe);
00201    struct pipe_context *pipe = tr_ctx->pipe;
00202    struct pipe_query *result;
00203 
00204    trace_dump_call_begin("pipe_context", "create_query");
00205 
00206    trace_dump_arg(ptr, pipe);
00207    trace_dump_arg(uint, query_type);
00208 
00209    result = pipe->create_query(pipe, query_type);;
00210 
00211    trace_dump_ret(ptr, result);
00212    
00213    trace_dump_call_end();
00214    
00215    return result;
00216 }
00217 
00218 
00219 static INLINE void
00220 trace_context_destroy_query(struct pipe_context *_pipe,
00221                             struct pipe_query *query)
00222 {
00223    struct trace_context *tr_ctx = trace_context(_pipe);
00224    struct pipe_context *pipe = tr_ctx->pipe;
00225 
00226    trace_dump_call_begin("pipe_context", "destroy_query");
00227 
00228    trace_dump_arg(ptr, pipe);
00229    trace_dump_arg(ptr, query);
00230 
00231    pipe->destroy_query(pipe, query);;
00232 
00233    trace_dump_call_end();
00234 }
00235 
00236 
00237 static INLINE void
00238 trace_context_begin_query(struct pipe_context *_pipe, 
00239                           struct pipe_query *query)
00240 {
00241    struct trace_context *tr_ctx = trace_context(_pipe);
00242    struct pipe_context *pipe = tr_ctx->pipe;
00243 
00244    trace_dump_call_begin("pipe_context", "begin_query");
00245 
00246    trace_dump_arg(ptr, pipe);
00247    trace_dump_arg(ptr, query);
00248 
00249    pipe->begin_query(pipe, query);;
00250 
00251    trace_dump_call_end();
00252 }
00253 
00254 
00255 static INLINE void
00256 trace_context_end_query(struct pipe_context *_pipe, 
00257                         struct pipe_query *query)
00258 {
00259    struct trace_context *tr_ctx = trace_context(_pipe);
00260    struct pipe_context *pipe = tr_ctx->pipe;
00261 
00262    trace_dump_call_begin("pipe_context", "end_query");
00263 
00264    trace_dump_arg(ptr, pipe);
00265    trace_dump_arg(ptr, query);
00266 
00267    pipe->end_query(pipe, query);
00268 
00269    trace_dump_call_end();
00270 }
00271 
00272 
00273 static INLINE boolean
00274 trace_context_get_query_result(struct pipe_context *_pipe, 
00275                                struct pipe_query *query,
00276                                boolean wait,
00277                                uint64 *presult)
00278 {
00279    struct trace_context *tr_ctx = trace_context(_pipe);
00280    struct pipe_context *pipe = tr_ctx->pipe;
00281    uint64 result;
00282    boolean _result;
00283 
00284    trace_dump_call_begin("pipe_context", "get_query_result");
00285 
00286    trace_dump_arg(ptr, pipe);
00287 
00288    _result = pipe->get_query_result(pipe, query, wait, presult);;
00289    result = *presult;
00290 
00291    trace_dump_arg(uint, result);
00292    trace_dump_ret(bool, _result);
00293    
00294    trace_dump_call_end();
00295    
00296    return _result;
00297 }
00298 
00299 
00300 static INLINE void *
00301 trace_context_create_blend_state(struct pipe_context *_pipe,
00302                                  const struct pipe_blend_state *state)
00303 {
00304    struct trace_context *tr_ctx = trace_context(_pipe);
00305    struct pipe_context *pipe = tr_ctx->pipe;
00306    void * result;
00307 
00308    trace_dump_call_begin("pipe_context", "create_blend_state");
00309 
00310    trace_dump_arg(ptr, pipe);
00311    trace_dump_arg(blend_state, state);
00312 
00313    result = pipe->create_blend_state(pipe, state);;
00314 
00315    trace_dump_ret(ptr, result);
00316 
00317    trace_dump_call_end();
00318    
00319    return result;
00320 }
00321 
00322 
00323 static INLINE void
00324 trace_context_bind_blend_state(struct pipe_context *_pipe, 
00325                                void *state)
00326 {
00327    struct trace_context *tr_ctx = trace_context(_pipe);
00328    struct pipe_context *pipe = tr_ctx->pipe;
00329 
00330    trace_dump_call_begin("pipe_context", "bind_blend_state");
00331 
00332    trace_dump_arg(ptr, pipe);
00333    trace_dump_arg(ptr, state);
00334 
00335    pipe->bind_blend_state(pipe, state);;
00336 
00337    trace_dump_call_end();
00338 }
00339 
00340 
00341 static INLINE void
00342 trace_context_delete_blend_state(struct pipe_context *_pipe, 
00343                                  void *state)
00344 {
00345    struct trace_context *tr_ctx = trace_context(_pipe);
00346    struct pipe_context *pipe = tr_ctx->pipe;
00347 
00348    trace_dump_call_begin("pipe_context", "delete_blend_state");
00349 
00350    trace_dump_arg(ptr, pipe);
00351    trace_dump_arg(ptr, state);
00352 
00353    pipe->delete_blend_state(pipe, state);;
00354 
00355    trace_dump_call_end();
00356 }
00357 
00358 
00359 static INLINE void *
00360 trace_context_create_sampler_state(struct pipe_context *_pipe,
00361                                    const struct pipe_sampler_state *state)
00362 {
00363    struct trace_context *tr_ctx = trace_context(_pipe);
00364    struct pipe_context *pipe = tr_ctx->pipe;
00365    void * result;
00366 
00367    trace_dump_call_begin("pipe_context", "create_sampler_state");
00368 
00369    trace_dump_arg(ptr, pipe);
00370    trace_dump_arg(sampler_state, state);
00371 
00372    result = pipe->create_sampler_state(pipe, state);;
00373 
00374    trace_dump_ret(ptr, result);
00375    
00376    trace_dump_call_end();
00377    
00378    return result;
00379 }
00380 
00381 
00382 static INLINE void
00383 trace_context_bind_sampler_states(struct pipe_context *_pipe, 
00384                                   unsigned num_states, void **states)
00385 {
00386    struct trace_context *tr_ctx = trace_context(_pipe);
00387    struct pipe_context *pipe = tr_ctx->pipe;
00388 
00389    trace_dump_call_begin("pipe_context", "bind_sampler_states");
00390 
00391    trace_dump_arg(ptr, pipe);
00392    trace_dump_arg(uint, num_states);
00393    trace_dump_arg_array(ptr, states, num_states);
00394 
00395    pipe->bind_sampler_states(pipe, num_states, states);;
00396 
00397    trace_dump_call_end();
00398 }
00399 
00400 
00401 static INLINE void
00402 trace_context_delete_sampler_state(struct pipe_context *_pipe, 
00403                                    void *state)
00404 {
00405    struct trace_context *tr_ctx = trace_context(_pipe);
00406    struct pipe_context *pipe = tr_ctx->pipe;
00407 
00408    trace_dump_call_begin("pipe_context", "delete_sampler_state");
00409 
00410    trace_dump_arg(ptr, pipe);
00411    trace_dump_arg(ptr, state);
00412 
00413    pipe->delete_sampler_state(pipe, state);;
00414 
00415    trace_dump_call_end();
00416 }
00417 
00418 
00419 static INLINE void *
00420 trace_context_create_rasterizer_state(struct pipe_context *_pipe,
00421                                       const struct pipe_rasterizer_state *state)
00422 {
00423    struct trace_context *tr_ctx = trace_context(_pipe);
00424    struct pipe_context *pipe = tr_ctx->pipe;
00425    void * result;
00426 
00427    trace_dump_call_begin("pipe_context", "create_rasterizer_state");
00428 
00429    trace_dump_arg(ptr, pipe);
00430    trace_dump_arg(rasterizer_state, state);
00431 
00432    result = pipe->create_rasterizer_state(pipe, state);;
00433 
00434    trace_dump_ret(ptr, result);
00435    
00436    trace_dump_call_end();
00437    
00438    return result;
00439 }
00440 
00441 
00442 static INLINE void
00443 trace_context_bind_rasterizer_state(struct pipe_context *_pipe, 
00444                                     void *state)
00445 {
00446    struct trace_context *tr_ctx = trace_context(_pipe);
00447    struct pipe_context *pipe = tr_ctx->pipe;
00448 
00449    trace_dump_call_begin("pipe_context", "bind_rasterizer_state");
00450 
00451    trace_dump_arg(ptr, pipe);
00452    trace_dump_arg(ptr, state);
00453 
00454    pipe->bind_rasterizer_state(pipe, state);;
00455 
00456    trace_dump_call_end();
00457 }
00458 
00459 
00460 static INLINE void
00461 trace_context_delete_rasterizer_state(struct pipe_context *_pipe, 
00462                                       void *state)
00463 {
00464    struct trace_context *tr_ctx = trace_context(_pipe);
00465    struct pipe_context *pipe = tr_ctx->pipe;
00466 
00467    trace_dump_call_begin("pipe_context", "delete_rasterizer_state");
00468 
00469    trace_dump_arg(ptr, pipe);
00470    trace_dump_arg(ptr, state);
00471 
00472    pipe->delete_rasterizer_state(pipe, state);;
00473 
00474    trace_dump_call_end();
00475 }
00476 
00477 
00478 static INLINE void *
00479 trace_context_create_depth_stencil_alpha_state(struct pipe_context *_pipe,
00480                                                const struct pipe_depth_stencil_alpha_state *state)
00481 {
00482    struct trace_context *tr_ctx = trace_context(_pipe);
00483    struct pipe_context *pipe = tr_ctx->pipe;
00484    void * result;
00485 
00486    trace_dump_call_begin("pipe_context", "create_depth_stencil_alpha_state");
00487 
00488    result = pipe->create_depth_stencil_alpha_state(pipe, state);;
00489 
00490    trace_dump_arg(ptr, pipe);
00491    trace_dump_arg(depth_stencil_alpha_state, state);
00492    
00493    trace_dump_ret(ptr, result);
00494 
00495    trace_dump_call_end();
00496    
00497    return result;
00498 }
00499 
00500 
00501 static INLINE void
00502 trace_context_bind_depth_stencil_alpha_state(struct pipe_context *_pipe, 
00503                                              void *state)
00504 {
00505    struct trace_context *tr_ctx = trace_context(_pipe);
00506    struct pipe_context *pipe = tr_ctx->pipe;
00507 
00508    trace_dump_call_begin("pipe_context", "bind_depth_stencil_alpha_state");
00509 
00510    trace_dump_arg(ptr, pipe);
00511    trace_dump_arg(ptr, state);
00512 
00513    pipe->bind_depth_stencil_alpha_state(pipe, state);;
00514 
00515    trace_dump_call_end();
00516 }
00517 
00518 
00519 static INLINE void
00520 trace_context_delete_depth_stencil_alpha_state(struct pipe_context *_pipe, 
00521                                                void *state)
00522 {
00523    struct trace_context *tr_ctx = trace_context(_pipe);
00524    struct pipe_context *pipe = tr_ctx->pipe;
00525 
00526    trace_dump_call_begin("pipe_context", "delete_depth_stencil_alpha_state");
00527 
00528    trace_dump_arg(ptr, pipe);
00529    trace_dump_arg(ptr, state);
00530 
00531    pipe->delete_depth_stencil_alpha_state(pipe, state);;
00532 
00533    trace_dump_call_end();
00534 }
00535 
00536 
00537 static INLINE void *
00538 trace_context_create_fs_state(struct pipe_context *_pipe,
00539                               const struct pipe_shader_state *state)
00540 {
00541    struct trace_context *tr_ctx = trace_context(_pipe);
00542    struct pipe_context *pipe = tr_ctx->pipe;
00543    void * result;
00544 
00545    trace_dump_call_begin("pipe_context", "create_fs_state");
00546 
00547    trace_dump_arg(ptr, pipe);
00548    trace_dump_arg(shader_state, state);
00549 
00550    result = pipe->create_fs_state(pipe, state);;
00551 
00552    trace_dump_ret(ptr, result);
00553    
00554    trace_dump_call_end();
00555    
00556    return result;
00557 }
00558 
00559 
00560 static INLINE void
00561 trace_context_bind_fs_state(struct pipe_context *_pipe, 
00562                             void *state)
00563 {
00564    struct trace_context *tr_ctx = trace_context(_pipe);
00565    struct pipe_context *pipe = tr_ctx->pipe;
00566 
00567    trace_dump_call_begin("pipe_context", "bind_fs_state");
00568 
00569    trace_dump_arg(ptr, pipe);
00570    trace_dump_arg(ptr, state);
00571 
00572    pipe->bind_fs_state(pipe, state);;
00573 
00574    trace_dump_call_end();
00575 }
00576 
00577 
00578 static INLINE void
00579 trace_context_delete_fs_state(struct pipe_context *_pipe, 
00580                               void *state)
00581 {
00582    struct trace_context *tr_ctx = trace_context(_pipe);
00583    struct pipe_context *pipe = tr_ctx->pipe;
00584 
00585    trace_dump_call_begin("pipe_context", "delete_fs_state");
00586 
00587    trace_dump_arg(ptr, pipe);
00588    trace_dump_arg(ptr, state);
00589 
00590    pipe->delete_fs_state(pipe, state);;
00591 
00592    trace_dump_call_end();
00593 }
00594 
00595 
00596 static INLINE void *
00597 trace_context_create_vs_state(struct pipe_context *_pipe,
00598                               const struct pipe_shader_state *state)
00599 {
00600    struct trace_context *tr_ctx = trace_context(_pipe);
00601    struct pipe_context *pipe = tr_ctx->pipe;
00602    void * result;
00603 
00604    trace_dump_call_begin("pipe_context", "create_vs_state");
00605 
00606    trace_dump_arg(ptr, pipe);
00607    trace_dump_arg(shader_state, state);
00608 
00609    result = pipe->create_vs_state(pipe, state);;
00610 
00611    trace_dump_ret(ptr, result);
00612    
00613    trace_dump_call_end();
00614    
00615    return result;
00616 }
00617 
00618 
00619 static INLINE void
00620 trace_context_bind_vs_state(struct pipe_context *_pipe, 
00621                             void *state)
00622 {
00623    struct trace_context *tr_ctx = trace_context(_pipe);
00624    struct pipe_context *pipe = tr_ctx->pipe;
00625 
00626    trace_dump_call_begin("pipe_context", "bind_vs_state");
00627 
00628    trace_dump_arg(ptr, pipe);
00629    trace_dump_arg(ptr, state);
00630 
00631    pipe->bind_vs_state(pipe, state);;
00632 
00633    trace_dump_call_end();
00634 }
00635 
00636 
00637 static INLINE void
00638 trace_context_delete_vs_state(struct pipe_context *_pipe, 
00639                               void *state)
00640 {
00641    struct trace_context *tr_ctx = trace_context(_pipe);
00642    struct pipe_context *pipe = tr_ctx->pipe;
00643 
00644    trace_dump_call_begin("pipe_context", "delete_vs_state");
00645 
00646    trace_dump_arg(ptr, pipe);
00647    trace_dump_arg(ptr, state);
00648 
00649    pipe->delete_vs_state(pipe, state);;
00650 
00651    trace_dump_call_end();
00652 }
00653 
00654 
00655 static INLINE void
00656 trace_context_set_blend_color(struct pipe_context *_pipe,
00657                               const struct pipe_blend_color *state)
00658 {
00659    struct trace_context *tr_ctx = trace_context(_pipe);
00660    struct pipe_context *pipe = tr_ctx->pipe;
00661 
00662    trace_dump_call_begin("pipe_context", "set_blend_color");
00663 
00664    trace_dump_arg(ptr, pipe);
00665    trace_dump_arg(blend_color, state);
00666 
00667    pipe->set_blend_color(pipe, state);;
00668 
00669    trace_dump_call_end();
00670 }
00671 
00672 
00673 static INLINE void
00674 trace_context_set_clip_state(struct pipe_context *_pipe,
00675                              const struct pipe_clip_state *state)
00676 {
00677    struct trace_context *tr_ctx = trace_context(_pipe);
00678    struct pipe_context *pipe = tr_ctx->pipe;
00679 
00680    trace_dump_call_begin("pipe_context", "set_clip_state");
00681 
00682    trace_dump_arg(ptr, pipe);
00683    trace_dump_arg(clip_state, state);
00684 
00685    pipe->set_clip_state(pipe, state);;
00686 
00687    trace_dump_call_end();
00688 }
00689 
00690 
00691 static INLINE void
00692 trace_context_set_constant_buffer(struct pipe_context *_pipe,
00693                                   uint shader, uint index,
00694                                   const struct pipe_constant_buffer *buffer)
00695 {
00696    struct trace_context *tr_ctx = trace_context(_pipe);
00697    struct pipe_context *pipe = tr_ctx->pipe;
00698 
00699    trace_winsys_user_buffer_update(_pipe->winsys, (struct pipe_buffer *)buffer);
00700    
00701    trace_dump_call_begin("pipe_context", "set_constant_buffer");
00702 
00703    trace_dump_arg(ptr, pipe);
00704    trace_dump_arg(uint, shader);
00705    trace_dump_arg(uint, index);
00706    trace_dump_arg(constant_buffer, buffer);
00707 
00708    pipe->set_constant_buffer(pipe, shader, index, buffer);;
00709 
00710    trace_dump_call_end();
00711 }
00712 
00713 
00714 static INLINE void
00715 trace_context_set_framebuffer_state(struct pipe_context *_pipe,
00716                                     const struct pipe_framebuffer_state *state)
00717 {
00718    struct trace_context *tr_ctx = trace_context(_pipe);
00719    struct pipe_context *pipe = tr_ctx->pipe;
00720    struct pipe_framebuffer_state unwrapped_state;
00721    unsigned i;
00722    
00723    /* Unwrap the input state */
00724    memcpy(&unwrapped_state, state, sizeof(unwrapped_state));
00725    for(i = 0; i < state->num_cbufs; ++i)
00726       unwrapped_state.cbufs[i] = trace_surface_unwrap(tr_ctx, state->cbufs[i]);
00727    for(i = state->num_cbufs; i < PIPE_MAX_COLOR_BUFS; ++i)
00728       unwrapped_state.cbufs[i] = NULL;
00729    unwrapped_state.zsbuf = trace_surface_unwrap(tr_ctx, state->zsbuf);
00730    state = &unwrapped_state;
00731    
00732    trace_dump_call_begin("pipe_context", "set_framebuffer_state");
00733 
00734    trace_dump_arg(ptr, pipe);
00735    trace_dump_arg(framebuffer_state, state);
00736 
00737    pipe->set_framebuffer_state(pipe, state);;
00738 
00739    trace_dump_call_end();
00740 }
00741 
00742 
00743 static INLINE void
00744 trace_context_set_polygon_stipple(struct pipe_context *_pipe,
00745                                   const struct pipe_poly_stipple *state)
00746 {
00747    struct trace_context *tr_ctx = trace_context(_pipe);
00748    struct pipe_context *pipe = tr_ctx->pipe;
00749 
00750    trace_dump_call_begin("pipe_context", "set_polygon_stipple");
00751 
00752    trace_dump_arg(ptr, pipe);
00753    trace_dump_arg(poly_stipple, state);
00754 
00755    pipe->set_polygon_stipple(pipe, state);;
00756 
00757    trace_dump_call_end();
00758 }
00759 
00760 
00761 static INLINE void
00762 trace_context_set_scissor_state(struct pipe_context *_pipe,
00763                                 const struct pipe_scissor_state *state)
00764 {
00765    struct trace_context *tr_ctx = trace_context(_pipe);
00766    struct pipe_context *pipe = tr_ctx->pipe;
00767 
00768    trace_dump_call_begin("pipe_context", "set_scissor_state");
00769 
00770    trace_dump_arg(ptr, pipe);
00771    trace_dump_arg(scissor_state, state);
00772 
00773    pipe->set_scissor_state(pipe, state);;
00774 
00775    trace_dump_call_end();
00776 }
00777 
00778 
00779 static INLINE void
00780 trace_context_set_viewport_state(struct pipe_context *_pipe,
00781                                  const struct pipe_viewport_state *state)
00782 {
00783    struct trace_context *tr_ctx = trace_context(_pipe);
00784    struct pipe_context *pipe = tr_ctx->pipe;
00785 
00786    trace_dump_call_begin("pipe_context", "set_viewport_state");
00787 
00788    trace_dump_arg(ptr, pipe);
00789    trace_dump_arg(viewport_state, state);
00790 
00791    pipe->set_viewport_state(pipe, state);;
00792 
00793    trace_dump_call_end();
00794 }
00795 
00796 
00797 static INLINE void
00798 trace_context_set_sampler_textures(struct pipe_context *_pipe,
00799                                    unsigned num_textures,
00800                                    struct pipe_texture **textures)
00801 {
00802    struct trace_context *tr_ctx = trace_context(_pipe);
00803    struct pipe_context *pipe = tr_ctx->pipe;
00804    struct pipe_texture *unwrapped_textures[PIPE_MAX_SAMPLERS];
00805    unsigned i;
00806    
00807    for(i = 0; i < num_textures; ++i)
00808       unwrapped_textures[i] = trace_texture_unwrap(tr_ctx, textures[i]);
00809    textures = unwrapped_textures;
00810 
00811    trace_dump_call_begin("pipe_context", "set_sampler_textures");
00812 
00813    trace_dump_arg(ptr, pipe);
00814    trace_dump_arg(uint, num_textures);
00815    trace_dump_arg_array(ptr, textures, num_textures);
00816 
00817    pipe->set_sampler_textures(pipe, num_textures, textures);;
00818 
00819    trace_dump_call_end();
00820 }
00821 
00822 
00823 static INLINE void
00824 trace_context_set_vertex_buffers(struct pipe_context *_pipe,
00825                                  unsigned num_buffers,
00826                                  const struct pipe_vertex_buffer *buffers)
00827 {
00828    struct trace_context *tr_ctx = trace_context(_pipe);
00829    struct pipe_context *pipe = tr_ctx->pipe;
00830    unsigned i;
00831 
00832    for(i = 0; i < num_buffers; ++i)
00833       trace_winsys_user_buffer_update(_pipe->winsys, buffers[i].buffer);
00834 
00835    trace_dump_call_begin("pipe_context", "set_vertex_buffers");
00836 
00837    trace_dump_arg(ptr, pipe);
00838    trace_dump_arg(uint, num_buffers);
00839    
00840    trace_dump_arg_begin("buffers");
00841    trace_dump_struct_array(vertex_buffer, buffers, num_buffers);
00842    trace_dump_arg_end();
00843 
00844    pipe->set_vertex_buffers(pipe, num_buffers, buffers);;
00845 
00846    trace_dump_call_end();
00847 }
00848 
00849 
00850 static INLINE void
00851 trace_context_set_vertex_elements(struct pipe_context *_pipe,
00852                                   unsigned num_elements,
00853                                   const struct pipe_vertex_element *elements)
00854 {
00855    struct trace_context *tr_ctx = trace_context(_pipe);
00856    struct pipe_context *pipe = tr_ctx->pipe;
00857 
00858    trace_dump_call_begin("pipe_context", "set_vertex_elements");
00859 
00860    trace_dump_arg(ptr, pipe);
00861    trace_dump_arg(uint, num_elements);
00862 
00863    trace_dump_arg_begin("elements");
00864    trace_dump_struct_array(vertex_element, elements, num_elements);
00865    trace_dump_arg_end();
00866 
00867    pipe->set_vertex_elements(pipe, num_elements, elements);;
00868 
00869    trace_dump_call_end();
00870 }
00871 
00872 
00873 static INLINE void
00874 trace_context_surface_copy(struct pipe_context *_pipe,
00875                            boolean do_flip,
00876                            struct pipe_surface *dest,
00877                            unsigned destx, unsigned desty,
00878                            struct pipe_surface *src,
00879                            unsigned srcx, unsigned srcy,
00880                            unsigned width, unsigned height)
00881 {
00882    struct trace_context *tr_ctx = trace_context(_pipe);
00883    struct pipe_context *pipe = tr_ctx->pipe;
00884 
00885    dest = trace_surface_unwrap(tr_ctx, dest);
00886    src = trace_surface_unwrap(tr_ctx, src);
00887    
00888    trace_dump_call_begin("pipe_context", "surface_copy");
00889 
00890    trace_dump_arg(ptr, pipe);
00891    trace_dump_arg(bool, do_flip);
00892    trace_dump_arg(ptr, dest);
00893    trace_dump_arg(uint, destx);
00894    trace_dump_arg(uint, desty);
00895    trace_dump_arg(ptr, src);
00896    trace_dump_arg(uint, srcx);
00897    trace_dump_arg(uint, srcy);
00898    trace_dump_arg(uint, width);
00899    trace_dump_arg(uint, height);
00900 
00901    pipe->surface_copy(pipe, do_flip, 
00902                       dest, destx, desty, 
00903                       src, srcx, srcy, width, height);
00904    
00905    trace_dump_call_end();
00906 }
00907 
00908 
00909 static INLINE void
00910 trace_context_surface_fill(struct pipe_context *_pipe,
00911                            struct pipe_surface *dst,
00912                            unsigned dstx, unsigned dsty,
00913                            unsigned width, unsigned height,
00914                            unsigned value)
00915 {
00916    struct trace_context *tr_ctx = trace_context(_pipe);
00917    struct pipe_context *pipe = tr_ctx->pipe;
00918 
00919    dst = trace_surface_unwrap(tr_ctx, dst);
00920 
00921    trace_dump_call_begin("pipe_context", "surface_fill");
00922 
00923    trace_dump_arg(ptr, pipe);
00924    trace_dump_arg(ptr, dst);
00925    trace_dump_arg(uint, dstx);
00926    trace_dump_arg(uint, dsty);
00927    trace_dump_arg(uint, width);
00928    trace_dump_arg(uint, height);
00929 
00930    pipe->surface_fill(pipe, dst, dstx, dsty, width, height, value);;
00931 
00932    trace_dump_call_end();
00933 }
00934 
00935 
00936 static INLINE void
00937 trace_context_clear(struct pipe_context *_pipe, 
00938                     struct pipe_surface *surface,
00939                     unsigned clearValue)
00940 {
00941    struct trace_context *tr_ctx = trace_context(_pipe);
00942    struct pipe_context *pipe = tr_ctx->pipe;
00943 
00944    surface = trace_surface_unwrap(tr_ctx, surface);
00945 
00946    trace_dump_call_begin("pipe_context", "clear");
00947 
00948    trace_dump_arg(ptr, pipe);
00949    trace_dump_arg(ptr, surface);
00950    trace_dump_arg(uint, clearValue);
00951 
00952    pipe->clear(pipe, surface, clearValue);;
00953 
00954    trace_dump_call_end();
00955 }
00956 
00957 
00958 static INLINE void
00959 trace_context_flush(struct pipe_context *_pipe,
00960                     unsigned flags,
00961                     struct pipe_fence_handle **fence)
00962 {
00963    struct trace_context *tr_ctx = trace_context(_pipe);
00964    struct pipe_context *pipe = tr_ctx->pipe;
00965 
00966    trace_dump_call_begin("pipe_context", "flush");
00967 
00968    trace_dump_arg(ptr, pipe);
00969    trace_dump_arg(uint, flags);
00970 
00971    pipe->flush(pipe, flags, fence);;
00972 
00973    if(fence)
00974       trace_dump_ret(ptr, *fence);
00975 
00976    trace_dump_call_end();
00977 }
00978 
00979 
00980 static INLINE void
00981 trace_context_destroy(struct pipe_context *_pipe)
00982 {
00983    struct trace_context *tr_ctx = trace_context(_pipe);
00984    struct pipe_context *pipe = tr_ctx->pipe;
00985 
00986    trace_dump_call_begin("pipe_context", "destroy");
00987 
00988    trace_dump_arg(ptr, pipe);
00989 
00990    pipe->destroy(pipe);
00991    
00992    trace_dump_call_end();
00993 
00994    FREE(tr_ctx);
00995 }
00996 
00997 
00998 struct pipe_context *
00999 trace_context_create(struct pipe_screen *screen, 
01000                      struct pipe_context *pipe)
01001 {
01002    struct trace_context *tr_ctx;
01003    
01004    if(!pipe)
01005       goto error1;
01006    
01007    if(!trace_dump_enabled())
01008       goto error1;
01009    
01010    tr_ctx = CALLOC_STRUCT(trace_context);
01011    if(!tr_ctx)
01012       goto error1;
01013 
01014    tr_ctx->base.winsys = screen->winsys;
01015    tr_ctx->base.screen = screen;
01016    tr_ctx->base.destroy = trace_context_destroy;
01017    tr_ctx->base.set_edgeflags = trace_context_set_edgeflags;
01018    tr_ctx->base.draw_arrays = trace_context_draw_arrays;
01019    tr_ctx->base.draw_elements = trace_context_draw_elements;
01020    tr_ctx->base.draw_range_elements = trace_context_draw_range_elements;
01021    tr_ctx->base.create_query = trace_context_create_query;
01022    tr_ctx->base.destroy_query = trace_context_destroy_query;
01023    tr_ctx->base.begin_query = trace_context_begin_query;
01024    tr_ctx->base.end_query = trace_context_end_query;
01025    tr_ctx->base.get_query_result = trace_context_get_query_result;
01026    tr_ctx->base.create_blend_state = trace_context_create_blend_state;
01027    tr_ctx->base.bind_blend_state = trace_context_bind_blend_state;
01028    tr_ctx->base.delete_blend_state = trace_context_delete_blend_state;
01029    tr_ctx->base.create_sampler_state = trace_context_create_sampler_state;
01030    tr_ctx->base.bind_sampler_states = trace_context_bind_sampler_states;
01031    tr_ctx->base.delete_sampler_state = trace_context_delete_sampler_state;
01032    tr_ctx->base.create_rasterizer_state = trace_context_create_rasterizer_state;
01033    tr_ctx->base.bind_rasterizer_state = trace_context_bind_rasterizer_state;
01034    tr_ctx->base.delete_rasterizer_state = trace_context_delete_rasterizer_state;
01035    tr_ctx->base.create_depth_stencil_alpha_state = trace_context_create_depth_stencil_alpha_state;
01036    tr_ctx->base.bind_depth_stencil_alpha_state = trace_context_bind_depth_stencil_alpha_state;
01037    tr_ctx->base.delete_depth_stencil_alpha_state = trace_context_delete_depth_stencil_alpha_state;
01038    tr_ctx->base.create_fs_state = trace_context_create_fs_state;
01039    tr_ctx->base.bind_fs_state = trace_context_bind_fs_state;
01040    tr_ctx->base.delete_fs_state = trace_context_delete_fs_state;
01041    tr_ctx->base.create_vs_state = trace_context_create_vs_state;
01042    tr_ctx->base.bind_vs_state = trace_context_bind_vs_state;
01043    tr_ctx->base.delete_vs_state = trace_context_delete_vs_state;
01044    tr_ctx->base.set_blend_color = trace_context_set_blend_color;
01045    tr_ctx->base.set_clip_state = trace_context_set_clip_state;
01046    tr_ctx->base.set_constant_buffer = trace_context_set_constant_buffer;
01047    tr_ctx->base.set_framebuffer_state = trace_context_set_framebuffer_state;
01048    tr_ctx->base.set_polygon_stipple = trace_context_set_polygon_stipple;
01049    tr_ctx->base.set_scissor_state = trace_context_set_scissor_state;
01050    tr_ctx->base.set_viewport_state = trace_context_set_viewport_state;
01051    tr_ctx->base.set_sampler_textures = trace_context_set_sampler_textures;
01052    tr_ctx->base.set_vertex_buffers = trace_context_set_vertex_buffers;
01053    tr_ctx->base.set_vertex_elements = trace_context_set_vertex_elements;
01054    tr_ctx->base.surface_copy = trace_context_surface_copy;
01055    tr_ctx->base.surface_fill = trace_context_surface_fill;
01056    tr_ctx->base.clear = trace_context_clear;
01057    tr_ctx->base.flush = trace_context_flush;
01058 
01059    tr_ctx->pipe = pipe;
01060    
01061    trace_dump_call_begin("", "pipe_context_create");
01062    trace_dump_arg_begin("screen");
01063    trace_dump_ptr(pipe->screen);
01064    trace_dump_arg_end();
01065    trace_dump_ret(ptr, pipe);
01066    trace_dump_call_end();
01067 
01068    return &tr_ctx->base;
01069    
01070 error1:
01071    return pipe;
01072 }

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