st_atom_constbuf.c File Reference

Include dependency graph for st_atom_constbuf.c:

Go to the source code of this file.

Functions

void st_upload_constants (struct st_context *st, struct gl_program_parameter_list *params, unsigned id)
 Pass the given program parameters to the graphics pipe as a constant buffer.
static void update_vs_constants (struct st_context *st)
static void update_fs_constants (struct st_context *st)

Variables

struct st_tracked_state st_update_vs_constants
struct st_tracked_state st_update_fs_constants


Function Documentation

void st_upload_constants ( struct st_context st,
struct gl_program_parameter_list *  params,
unsigned  id 
)

Pass the given program parameters to the graphics pipe as a constant buffer.

Parameters:
id either PIPE_SHADER_VERTEX or PIPE_SHADER_FRAGMENT

Definition at line 52 of file st_atom_constbuf.c.

References assert, pipe_constant_buffer::buffer, st_context::constants, st_context::ctx, st_context::pipe, pipe_buffer_create(), pipe_buffer_map(), pipe_buffer_reference(), pipe_buffer_unmap(), PIPE_BUFFER_USAGE_CONSTANT, PIPE_BUFFER_USAGE_CPU_WRITE, PIPE_SHADER_FRAGMENT, PIPE_SHADER_VERTEX, pipe_context::screen, pipe_context::set_constant_buffer, pipe_constant_buffer::size, and st_context::state.

00055 {
00056    struct pipe_context *pipe = st->pipe;
00057    struct pipe_constant_buffer *cbuf = &st->state.constants[id];
00058 
00059    assert(id == PIPE_SHADER_VERTEX || id == PIPE_SHADER_FRAGMENT);
00060 
00061    /* update constants */
00062    if (params && params->NumParameters) {
00063       const uint paramBytes = params->NumParameters * sizeof(GLfloat) * 4;
00064 
00065       /* Update our own dependency flags.  This works because this
00066        * function will also be called whenever the program changes.
00067        */
00068       st->constants.tracked_state[id].dirty.mesa =
00069          (params->StateFlags | _NEW_PROGRAM);
00070 
00071       _mesa_load_state_parameters(st->ctx, params);
00072 
00073       /* We always need to get a new buffer, to keep the drivers simple and
00074        * avoid gratuitous rendering synchronization.
00075        */
00076       pipe_buffer_reference(pipe->screen, &cbuf->buffer, NULL );
00077       cbuf->buffer = pipe_buffer_create(pipe->screen, 16, PIPE_BUFFER_USAGE_CONSTANT,
00078                                         paramBytes );
00079 
00080       if (0)
00081       {
00082          printf("%s(shader=%d, numParams=%d, stateFlags=0x%x)\n", 
00083                 __FUNCTION__, id, params->NumParameters, params->StateFlags);
00084          _mesa_print_parameter_list(params);
00085       }
00086 
00087       /* load Mesa constants into the constant buffer */
00088       if (cbuf->buffer) {
00089          void *map = pipe_buffer_map(pipe->screen, cbuf->buffer,
00090                                      PIPE_BUFFER_USAGE_CPU_WRITE);
00091          memcpy(map, params->ParameterValues, paramBytes);
00092          pipe_buffer_unmap(pipe->screen, cbuf->buffer);
00093       }
00094 
00095       cbuf->size = paramBytes;
00096 
00097       st->pipe->set_constant_buffer(st->pipe, id, 0, cbuf);
00098    }
00099    else {
00100       st->constants.tracked_state[id].dirty.mesa = 0;
00101       //  st->pipe->set_constant_buffer(st->pipe, id, 0, NULL);
00102    }
00103 }

static void update_fs_constants ( struct st_context st  )  [static]

Definition at line 126 of file st_atom_constbuf.c.

References st_fragment_program::Base, st_context::fp, PIPE_SHADER_FRAGMENT, and st_upload_constants().

00127 {
00128    struct st_fragment_program *fp = st->fp;
00129    struct gl_program_parameter_list *params = fp->Base.Base.Parameters;
00130 
00131    st_upload_constants( st, params, PIPE_SHADER_FRAGMENT );
00132 }

static void update_vs_constants ( struct st_context st  )  [static]

Definition at line 107 of file st_atom_constbuf.c.

References st_vertex_program::Base, PIPE_SHADER_VERTEX, st_upload_constants(), and st_context::vp.

00108 {
00109    struct st_vertex_program *vp = st->vp;
00110    struct gl_program_parameter_list *params = vp->Base.Base.Parameters;
00111 
00112    st_upload_constants( st, params, PIPE_SHADER_VERTEX );
00113 }


Variable Documentation

struct st_tracked_state st_update_fs_constants

Initial value:

 {
   "st_update_fs_constants",                            
   {                                                    
      0,                        
       0x2 ,                            
   },
   update_fs_constants                                  
}

Definition at line 134 of file st_atom_constbuf.c.

struct st_tracked_state st_update_vs_constants

Initial value:

 {
   "st_update_vs_constants",                            
   {                                                    
      0,                        
       0x4 ,                            
   },
   update_vs_constants                                  
}

Definition at line 115 of file st_atom_constbuf.c.


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