sct.h File Reference

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  surface_context_tracker
 Per-device info, basically. More...
struct  sct_context_list
 Simple linked list of contexts. More...

Functions

void sct_bind_surfaces (struct surface_context_tracker *sct, struct pipe_context *context, uint num_surf, struct pipe_surface **surfaces)
 Bind context to a set of surfaces (color + Z).
void sct_bind_texture (struct surface_context_tracker *sct, struct pipe_context *context, uint unit, struct pipe_texture *texture)
 Bind a texture to a rendering context.
void sct_update_texture (struct pipe_texture *tex)
 To be called when the image contents of a texture are changed, such as for gl[Copy]TexSubImage().
boolean sct_is_texture_used (struct surface_context_tracker *sct, const struct pipe_context *context, const struct pipe_texture *texture)
 Check if the given texture has been used by the rendering context since the last call to sct_flush_textures().
void sct_flush_textures (struct surface_context_tracker *sct, struct pipe_context *context)
 When a scene is flushed/rendered we can release the list of used textures.
struct sct_context_listsct_get_surface_contexts (struct surface_context_tracker *sct, const struct pipe_surface *surf)
 Return list of contexts bound to a surface.
void sct_destroy_context (struct surface_context_tracker *sct, struct pipe_context *context)
void sct_destroy_surface (struct surface_context_tracker *sct, struct pipe_surface *surface)


Function Documentation

void sct_bind_surfaces ( struct surface_context_tracker sct,
struct pipe_context context,
uint  num_surf,
struct pipe_surface **  surfaces 
)

Bind context to a set of surfaces (color + Z).

Like MakeCurrent().

Definition at line 238 of file sct.c.

References add_context_to_surface(), find_create_context_info(), find_create_surface_info(), find_surface_context(), MAX_SURFACES, sct_context::surfaces, and unbind_context_surface().

00242 {
00243    struct sct_context *ci = find_create_context_info(sct, context);
00244    uint i;
00245 
00246    if (!ci) {
00247       return; /* out of memory */
00248    }
00249 
00250    /* unbind currently bound surfaces */
00251    for (i = 0; i < MAX_SURFACES; i++) {
00252       if (ci->surfaces[i]) {
00253          unbind_context_surface(sct, context, ci->surfaces[i]);
00254       }
00255    }
00256 
00257    /* bind new surfaces */
00258    for (i = 0; i < num_surf; i++) {
00259       struct sct_surface *si = find_create_surface_info(sct, surfaces[i]);
00260       if (!find_surface_context(si, context)) {
00261          add_context_to_surface(si, context);
00262       }
00263    }
00264 }

void sct_bind_texture ( struct surface_context_tracker sct,
struct pipe_context context,
uint  unit,
struct pipe_texture texture 
)

Bind a texture to a rendering context.

Definition at line 319 of file sct.c.

References add_texture_used(), find_context_info(), pipe_texture_reference(), and sct_context::textures.

00323 {
00324    struct sct_context *ci = find_context_info(sct, context);
00325 
00326    if (ci->textures[unit] != tex) {
00327       /* put texture on the 'used' list */
00328       add_texture_used(ci, tex);
00329       /* bind new */
00330       pipe_texture_reference(&ci->textures[unit], tex);
00331    }
00332 }

void sct_destroy_context ( struct surface_context_tracker sct,
struct pipe_context context 
)

Definition at line 389 of file sct.c.

References sct_context::context, surface_context_tracker::contexts, FREE, sct_context::next, sct_surface::next, remove_context_from_surface(), and surface_context_tracker::surfaces.

00391 {
00392    /* XXX should we require an unbinding first? */
00393    {
00394       struct sct_surface *si;
00395       for (si = sct->surfaces; si; si = si->next) {
00396          remove_context_from_surface(si, context);
00397       }
00398    }
00399 
00400    /* remove context from context_info list */
00401    {
00402       struct sct_context *ci, *next, *prev = NULL;
00403       for (ci = sct->contexts; ci; ci = next) {
00404          next = ci->next;
00405          if (ci->context == context) {
00406             if (prev)
00407                prev->next = ci->next;
00408             else
00409                sct->contexts = ci->next;
00410             FREE(ci);
00411          }
00412          else {
00413             prev = ci;
00414          }
00415       }
00416    }
00417 
00418 }

void sct_destroy_surface ( struct surface_context_tracker sct,
struct pipe_surface surface 
)

Definition at line 422 of file sct.c.

References assert, surface_context_tracker::contexts, FREE, MAX_SURFACES, sct_surface::next, sct_context::next, sct_surface::surface, surface_context_tracker::surfaces, and sct_context::surfaces.

00424 {
00425    if (1) {
00426       /* debug/sanity: no context should be bound to surface */
00427       struct sct_context *ci;
00428       uint i;
00429       for (ci = sct->contexts; ci; ci = ci->next) {
00430          for (i = 0; i < MAX_SURFACES; i++) {
00431             assert(ci->surfaces[i] != surface);
00432          }
00433       }
00434    }
00435 
00436    /* remove surface from sct_surface list */
00437    {
00438       struct sct_surface *si, *next, *prev = NULL;
00439       for (si = sct->surfaces; si; si = next) {
00440          next = si->next;
00441          if (si->surface == surface) {
00442             /* unlink */
00443             if (prev)
00444                prev->next = si->next;
00445             else
00446                sct->surfaces = si->next;
00447             FREE(si);
00448          }
00449          else {
00450             prev = si;
00451          }
00452       }
00453    }
00454 }

void sct_flush_textures ( struct surface_context_tracker sct,
struct pipe_context context 
)

When a scene is flushed/rendered we can release the list of used textures.

Definition at line 366 of file sct.c.

References add_texture_used(), find_context_info(), FREE, texture_list::next, PIPE_MAX_SAMPLERS, pipe_texture_release(), texture_list::texture, sct_context::textures, and sct_context::textures_used.

00368 {
00369    struct sct_context *ci = find_context_info(sct, context);
00370    struct texture_list *tl, *next;
00371    uint i;
00372 
00373    for (tl = ci->textures_used; tl; tl = next) {
00374       next = tl->next;
00375       pipe_texture_release(&tl->texture);
00376       FREE(tl);
00377    }
00378    ci->textures_used = NULL;
00379 
00380    /* put the currently bound textures on the 'used' list */
00381    for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
00382       add_texture_used(ci, ci->textures[i]);
00383    }
00384 }

struct sct_context_list* sct_get_surface_contexts ( struct surface_context_tracker sct,
const struct pipe_surface surf 
) [read]

Return list of contexts bound to a surface.

Definition at line 271 of file sct.c.

References sct_surface::contexts, and find_surface_info().

00273 {
00274    const struct sct_surface *si = find_surface_info(sct, surface);
00275    return si->contexts;
00276 }

boolean sct_is_texture_used ( struct surface_context_tracker sct,
const struct pipe_context context,
const struct pipe_texture texture 
)

Check if the given texture has been used by the rendering context since the last call to sct_flush_textures().

Definition at line 340 of file sct.c.

References find_context_info(), and find_texture().

00343 {
00344    const struct sct_context *ci = find_context_info(sct, context);
00345    return find_texture(ci, texture);
00346 }

void sct_update_texture ( struct pipe_texture tex  ) 

To be called when the image contents of a texture are changed, such as for gl[Copy]TexSubImage().

XXX this may not be needed

Definition at line 355 of file sct.c.

00356 {
00357 
00358 }


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