aboutsummaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/i965/brw_pipe_vertex.c
blob: e3c48e3149357d88dc11fd51653324280998898a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
#include "brw_context.h"


static void brw_set_vertex_elements( struct pipe_context *pipe,
				     unsigned count,
				     const struct pipe_vertex_element *elements )
{
   struct brw_context *brw = brw_context(pipe);

   memcpy(brw->curr.vertex_element, elements, count * sizeof(elements[0]));
   brw->curr.num_vertex_elements = count;

   brw->state.dirty.mesa |= PIPE_NEW_VERTEX_ELEMENT;
}


static void brw_set_vertex_buffers(struct pipe_context *pipe,
				   unsigned count,
				   const struct pipe_vertex_buffer *buffers)
{
   struct brw_context *brw = brw_context(pipe);
   unsigned i;

   /* Check for no change */
   if (count == brw->curr.num_vertex_buffers &&
       memcmp(brw->curr.vertex_buffer,
              buffers,
              count * sizeof buffers[0]) == 0)
      return;

   /* Adjust refcounts */
   for (i = 0; i < count; i++) 
      pipe_buffer_reference(&brw->curr.vertex_buffer[i].buffer, 
                            buffers[i].buffer);

   for ( ; i < brw->curr.num_vertex_buffers; i++)
      pipe_buffer_reference(&brw->curr.vertex_buffer[i].buffer,
                            NULL);

   /* Copy remaining data */
   memcpy(brw->curr.vertex_buffer, buffers, count * sizeof buffers[0]);
   brw->curr.num_vertex_buffers = count;

   brw->state.dirty.mesa |= PIPE_NEW_VERTEX_BUFFER;
}


void 
brw_pipe_vertex_init( struct brw_context *brw )
{
   brw->base.set_vertex_buffers = brw_set_vertex_buffers;
   brw->base.set_vertex_elements = brw_set_vertex_elements;
}


void 
brw_pipe_vertex_cleanup( struct brw_context *brw )
{

   /* Release bound pipe vertex_buffers
    */

   /* Release some other stuff
    */
#if 0
   for (i = 0; i < PIPE_MAX_ATTRIBS; i++) {
      bo_reference(&brw->vb.inputs[i].bo, NULL);
      brw->vb.inputs[i].bo = NULL;
   }
#endif
}