4 #include "pipe/p_compiler.h"
5 #include "pipe/p_state.h"
6 #include "util/u_atomic.h"
8 struct util_hash_table
;
14 struct util_hash_table
*table
;
15 struct pipe_surface
**array
;
19 struct pipe_surface
*util_surfaces_do_get(struct util_surfaces
*us
, unsigned surface_struct_size
, struct pipe_screen
*pscreen
, struct pipe_resource
*pt
, unsigned face
, unsigned level
, unsigned zslice
, unsigned flags
);
21 /* fast inline path for the very common case */
22 static INLINE
struct pipe_surface
*
23 util_surfaces_get(struct util_surfaces
*us
, unsigned surface_struct_size
, struct pipe_screen
*pscreen
, struct pipe_resource
*pt
, unsigned face
, unsigned level
, unsigned zslice
, unsigned flags
)
25 if(likely(pt
->target
== PIPE_TEXTURE_2D
&& us
->u
.array
))
27 struct pipe_surface
*ps
= us
->u
.array
[level
];
30 p_atomic_inc(&ps
->reference
.count
);
35 return util_surfaces_do_get(us
, surface_struct_size
, pscreen
, pt
, face
, level
, zslice
, flags
);
38 void util_surfaces_do_detach(struct util_surfaces
*us
, struct pipe_surface
*ps
);
41 util_surfaces_detach(struct util_surfaces
*us
, struct pipe_surface
*ps
)
43 if(likely(ps
->texture
->target
== PIPE_TEXTURE_2D
))
45 us
->u
.array
[ps
->level
] = 0;
49 util_surfaces_do_detach(us
, ps
);
52 void util_surfaces_destroy(struct util_surfaces
*us
, struct pipe_resource
*pt
, void (*destroy_surface
) (struct pipe_surface
*));