pb_validate.c File Reference

Buffer validation. More...

Include dependency graph for pb_validate.c:

Go to the source code of this file.

Data Structures

struct  pb_validate

Defines

#define PB_VALIDATE_INITIAL_SIZE   1

Functions

enum pipe_error pb_validate_add_buffer (struct pb_validate *vl, struct pb_buffer *buf)
enum pipe_error pb_validate_validate (struct pb_validate *vl)
 Validate all buffers for hardware access.
void pb_validate_fence (struct pb_validate *vl, struct pipe_fence_handle *fence)
 Fence all buffers and clear the list.
void pb_validate_destroy (struct pb_validate *vl)
struct pb_validatepb_validate_create ()


Detailed Description

Buffer validation.

Author:
Jose Fonseca <jrfonseca@tungstengraphics.com>

Definition in file pb_validate.c.


Define Documentation

#define PB_VALIDATE_INITIAL_SIZE   1

Definition at line 46 of file pb_validate.c.


Function Documentation

enum pipe_error pb_validate_add_buffer ( struct pb_validate vl,
struct pb_buffer buf 
)

Definition at line 58 of file pb_validate.c.

References assert, pb_validate::buffers, pb_reference(), PIPE_ERROR, PIPE_ERROR_OUT_OF_MEMORY, PIPE_OK, REALLOC, pb_validate::size, and pb_validate::used.

00060 {
00061    assert(buf);
00062    if(!buf)
00063       return PIPE_ERROR;
00064 
00065    /* We only need to store one reference for each buffer, so avoid storing
00066     * consecutive references for the same buffer. It might not be the more 
00067     * common pasttern, but it is easy to implement.
00068     */
00069    if(vl->used && vl->buffers[vl->used - 1] == buf) {
00070       return PIPE_OK;
00071    }
00072    
00073    /* Grow the table */
00074    if(vl->used == vl->size) {
00075       unsigned new_size;
00076       struct pb_buffer **new_buffers;
00077       
00078       new_size = vl->size * 2;
00079       if(!new_size)
00080          return PIPE_ERROR_OUT_OF_MEMORY;
00081 
00082       new_buffers = (struct pb_buffer **)REALLOC(vl->buffers,
00083                                                  vl->size*sizeof(struct pb_buffer *),
00084                                                  new_size*sizeof(struct pb_buffer *));
00085       if(!new_buffers)
00086          return PIPE_ERROR_OUT_OF_MEMORY;
00087       
00088       memset(new_buffers + vl->size, 0, (new_size - vl->size)*sizeof(struct pb_buffer *));
00089       
00090       vl->size = new_size;
00091       vl->buffers = new_buffers;
00092    }
00093    
00094    assert(!vl->buffers[vl->used]);
00095    pb_reference(&vl->buffers[vl->used], buf);
00096    ++vl->used;
00097    
00098    return PIPE_OK;
00099 }

struct pb_validate* pb_validate_create ( void   )  [read]

Definition at line 136 of file pb_validate.c.

References pb_validate::buffers, CALLOC, CALLOC_STRUCT, FREE, PB_VALIDATE_INITIAL_SIZE, and pb_validate::size.

00137 {
00138    struct pb_validate *vl;
00139    
00140    vl = CALLOC_STRUCT(pb_validate);
00141    if(!vl)
00142       return NULL;
00143    
00144    vl->size = PB_VALIDATE_INITIAL_SIZE;
00145    vl->buffers = (struct pb_buffer **)CALLOC(vl->size, sizeof(struct pb_buffer *));
00146    if(!vl->buffers) {
00147       FREE(vl);
00148       return NULL;
00149    }
00150 
00151    return vl;
00152 }

void pb_validate_destroy ( struct pb_validate vl  ) 

Definition at line 125 of file pb_validate.c.

References pb_validate::buffers, FREE, pb_reference(), and pb_validate::used.

00126 {
00127    unsigned i;
00128    for(i = 0; i < vl->used; ++i)
00129       pb_reference(&vl->buffers[i], NULL);
00130    FREE(vl->buffers);
00131    FREE(vl);
00132 }

void pb_validate_fence ( struct pb_validate vl,
struct pipe_fence_handle *  fence 
)

Fence all buffers and clear the list.

Should be called right before issuing commands to the hardware.

Definition at line 112 of file pb_validate.c.

References buffer_fence(), pb_validate::buffers, pb_reference(), and pb_validate::used.

00114 {
00115    unsigned i;
00116    for(i = 0; i < vl->used; ++i) {
00117       buffer_fence(vl->buffers[i], fence);
00118       pb_reference(&vl->buffers[i], NULL);
00119    }
00120    vl->used = 0;
00121 }

enum pipe_error pb_validate_validate ( struct pb_validate vl  ) 

Validate all buffers for hardware access.

Should be called right before issuing commands to the hardware.

Definition at line 103 of file pb_validate.c.

References PIPE_OK.

00104 {
00105    /* FIXME: go through each buffer, ensure its not mapped, its address is 
00106     * available -- requires a new pb_buffer interface */
00107    return PIPE_OK;
00108 }


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