1 /**************************************************************************
3 * Copyright 2008 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "util/u_inlines.h"
29 #include "util/u_hash_table.h"
30 #include "util/u_memory.h"
31 #include "util/simple_list.h"
33 #include "tr_screen.h"
34 #include "tr_context.h"
35 #include "tr_texture.h"
39 trace_surf_create(struct trace_context
*tr_ctx
,
40 struct pipe_resource
*res
,
41 struct pipe_surface
*surface
)
43 struct trace_surface
*tr_surf
;
48 assert(surface
->texture
== res
);
50 tr_surf
= CALLOC_STRUCT(trace_surface
);
54 memcpy(&tr_surf
->base
, surface
, sizeof(struct pipe_surface
));
55 tr_surf
->base
.context
= &tr_ctx
->base
;
57 pipe_reference_init(&tr_surf
->base
.reference
, 1);
58 tr_surf
->base
.texture
= NULL
;
59 pipe_resource_reference(&tr_surf
->base
.texture
, res
);
60 tr_surf
->surface
= surface
;
62 return &tr_surf
->base
;
65 pipe_surface_reference(&surface
, NULL
);
71 trace_surf_destroy(struct trace_surface
*tr_surf
)
73 trace_context_check(tr_surf
->base
.context
);
74 pipe_resource_reference(&tr_surf
->base
.texture
, NULL
);
75 pipe_surface_reference(&tr_surf
->surface
, NULL
);
80 struct pipe_transfer
*
81 trace_transfer_create(struct trace_context
*tr_ctx
,
82 struct pipe_resource
*res
,
83 struct pipe_transfer
*transfer
)
85 struct trace_transfer
*tr_trans
;
90 assert(transfer
->resource
== res
);
92 tr_trans
= CALLOC_STRUCT(trace_transfer
);
96 memcpy(&tr_trans
->base
, transfer
, sizeof(struct pipe_transfer
));
98 tr_trans
->base
.resource
= NULL
;
99 tr_trans
->transfer
= transfer
;
101 pipe_resource_reference(&tr_trans
->base
.resource
, res
);
102 assert(tr_trans
->base
.resource
== res
);
104 return &tr_trans
->base
;
107 tr_ctx
->pipe
->transfer_unmap(tr_ctx
->pipe
, transfer
);
113 trace_transfer_destroy(struct trace_context
*tr_context
,
114 struct trace_transfer
*tr_trans
)
116 pipe_resource_reference(&tr_trans
->base
.resource
, NULL
);