1 /**************************************************************************
3 * Copyright 2010 VMware, Inc.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the
8 * "Software"), to deal in the Software without restriction, including
9 * without limitation the rights to use, copy, modify, merge, publish,
10 * distribute, sub license, and/or sell copies of the Software, and to
11 * permit persons to whom the Software is furnished to do so, subject to
12 * the following conditions:
14 * The above copyright notice and this permission notice (including the
15 * next paragraph) shall be included in all copies or substantial portions
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
19 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
20 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.
21 * IN NO EVENT SHALL VMWARE AND/OR ITS SUPPLIERS BE LIABLE FOR
22 * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
23 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
24 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
26 **************************************************************************/
28 #include "lp_context.h"
30 #include "lp_texture.h"
32 #include "util/u_memory.h"
33 #include "draw/draw_context.h"
37 llvmpipe_create_stream_output_state(struct pipe_context
*pipe
,
38 const struct pipe_stream_output_state
*templ
)
40 struct lp_so_state
*so
;
41 so
= (struct lp_so_state
*) CALLOC_STRUCT(lp_so_state
);
44 so
->base
.num_outputs
= templ
->num_outputs
;
45 so
->base
.stride
= templ
->stride
;
46 memcpy(so
->base
.output_buffer
,
48 sizeof(int) * templ
->num_outputs
);
49 memcpy(so
->base
.register_index
,
50 templ
->register_index
,
51 sizeof(int) * templ
->num_outputs
);
52 memcpy(so
->base
.register_mask
,
54 sizeof(ubyte
) * templ
->num_outputs
);
60 llvmpipe_bind_stream_output_state(struct pipe_context
*pipe
,
63 struct llvmpipe_context
*lp
= llvmpipe_context(pipe
);
64 struct lp_so_state
*lp_so
= (struct lp_so_state
*) so
;
68 lp
->dirty
|= LP_NEW_SO
;
71 draw_set_so_state(lp
->draw
, &lp_so
->base
);
75 llvmpipe_delete_stream_output_state(struct pipe_context
*pipe
, void *so
)
81 llvmpipe_set_stream_output_buffers(struct pipe_context
*pipe
,
82 struct pipe_resource
**buffers
,
86 struct llvmpipe_context
*lp
= llvmpipe_context(pipe
);
88 void *map_buffers
[PIPE_MAX_SO_BUFFERS
];
90 assert(num_buffers
<= PIPE_MAX_SO_BUFFERS
);
91 if (num_buffers
> PIPE_MAX_SO_BUFFERS
)
92 num_buffers
= PIPE_MAX_SO_BUFFERS
;
94 lp
->dirty
|= LP_NEW_SO_BUFFERS
;
96 for (i
= 0; i
< num_buffers
; ++i
) {
98 struct llvmpipe_resource
*res
= llvmpipe_resource(buffers
[i
]);
101 /* the whole call is invalid, bail out */
102 lp
->so_target
.num_buffers
= 0;
103 draw_set_mapped_so_buffers(lp
->draw
, 0, 0);
107 lp
->so_target
.buffer
[i
] = res
;
108 lp
->so_target
.offset
[i
] = offsets
[i
];
109 lp
->so_target
.so_count
[i
] = 0;
113 map_buffers
[i
] = ((char*)mapped
) + offsets
[i
];
115 /* this is a buffer append */
116 assert(!"appending not implemented");
117 map_buffers
[i
] = mapped
;
120 lp
->so_target
.num_buffers
= num_buffers
;
122 draw_set_mapped_so_buffers(lp
->draw
, map_buffers
, num_buffers
);
126 llvmpipe_init_so_funcs(struct llvmpipe_context
*llvmpipe
)
128 llvmpipe
->pipe
.create_stream_output_state
=
129 llvmpipe_create_stream_output_state
;
130 llvmpipe
->pipe
.bind_stream_output_state
=
131 llvmpipe_bind_stream_output_state
;
132 llvmpipe
->pipe
.delete_stream_output_state
=
133 llvmpipe_delete_stream_output_state
;
135 llvmpipe
->pipe
.set_stream_output_buffers
=
136 llvmpipe_set_stream_output_buffers
;