#include "main/imports.h"
#include "main/macros.h"
+#include "main/arrayobj.h"
#include "main/feedback.h"
#include "main/rastpos.h"
-#include "glformats.h"
+#include "main/state.h"
+#include "main/varray.h"
#include "st_context.h"
#include "st_atom.h"
struct gl_context *ctx; /**< Rendering context */
/* vertex attrib info we can setup once and re-use */
- struct gl_vertex_buffer_binding binding;
- struct gl_array_attributes attrib[VERT_ATTRIB_MAX];
- struct gl_vertex_array array[VERT_ATTRIB_MAX];
+ struct gl_vertex_array_object *VAO;
struct _mesa_prim prim;
};
static void
rastpos_destroy(struct draw_stage *stage)
{
+ struct rastpos_stage *rstage = (struct rastpos_stage*)stage;
+ _mesa_reference_vao(rstage->ctx, &rstage->VAO, NULL);
free(stage);
}
new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw)
{
struct rastpos_stage *rs = ST_CALLOC_STRUCT(rastpos_stage);
- GLuint i;
- GLuint elementSize;
rs->stage.draw = draw;
rs->stage.next = NULL;
rs->stage.destroy = rastpos_destroy;
rs->ctx = ctx;
- rs->binding.Stride = 0;
- rs->binding.BufferObj = NULL;
-
- elementSize = _mesa_bytes_per_vertex_attrib(4, GL_FLOAT);
- for (i = 0; i < ARRAY_SIZE(rs->array); i++) {
- rs->attrib[i].Size = 4;
- rs->attrib[i].Type = GL_FLOAT;
- rs->attrib[i].Format = GL_RGBA;
- rs->attrib[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];
- rs->attrib[i].Normalized = GL_TRUE;
- rs->attrib[i]._ElementSize = elementSize;
- rs->array[i].BufferBinding = &rs->binding;
- rs->array[i].VertexAttrib = &rs->attrib[i];
- }
+ rs->VAO = _mesa_new_vao(ctx, ~((GLuint)0));
+ _mesa_vertex_attrib_binding(ctx, rs->VAO, VERT_ATTRIB_POS, 0, false);
+ _mesa_update_array_format(ctx, rs->VAO, VERT_ATTRIB_POS, 4, GL_FLOAT,
+ GL_RGBA, GL_FALSE, GL_FALSE, GL_FALSE, 0);
+ _mesa_enable_vertex_array_attrib(ctx, rs->VAO, 0, false);
rs->prim.mode = GL_POINTS;
rs->prim.indexed = 0;
struct st_context *st = st_context(ctx);
struct draw_context *draw = st_get_draw_context(st);
struct rastpos_stage *rs;
- const struct gl_vertex_array *saved_arrays = ctx->Array._DrawArrays;
if (!st->draw)
return;
/* All vertex attribs but position were previously initialized above.
* Just plug in position pointer now.
*/
- rs->attrib[0].Ptr = (GLubyte *) v;
+ rs->VAO->VertexAttrib[VERT_ATTRIB_POS].Ptr = (GLubyte *) v;
+ rs->VAO->NewArrays |= VERT_BIT_POS;
+ _mesa_set_draw_vao(ctx, rs->VAO, VERT_BIT_POS);
- /* Draw the point.
- *
- * Don't set DriverFlags.NewArray.
- * st_feedback_draw_vbo doesn't check for that flag. */
- ctx->Array._DrawArrays = rs->array;
+ /* Draw the point. */
st_feedback_draw_vbo(ctx, &rs->prim, 1, NULL, GL_TRUE, 0, 1,
NULL, 0, NULL);
- ctx->Array._DrawArrays = saved_arrays;
/* restore draw's rasterization stage depending on rendermode */
if (ctx->RenderMode == GL_FEEDBACK) {
**************************************************************************/
#include "main/imports.h"
+#include "main/arrayobj.h"
#include "main/image.h"
#include "main/macros.h"
#include "main/varray.h"
struct pipe_vertex_element velements[PIPE_MAX_ATTRIBS];
struct pipe_transfer *vb_transfer[PIPE_MAX_ATTRIBS] = {NULL};
struct pipe_transfer *ib_transfer = NULL;
- const struct gl_vertex_array *arrays = ctx->Array._DrawArrays;
GLuint attr, i;
- const GLubyte *low_addr = NULL;
const void *mapped_indices = NULL;
if (!draw)
draw_bind_vertex_shader(draw, st->vp_variant->draw_shader);
set_feedback_vertex_format(ctx);
- /* Find the lowest address of the arrays we're drawing */
- if (vp->num_inputs) {
- const struct gl_vertex_array *array;
- const struct gl_vertex_buffer_binding *binding;
- const struct gl_array_attributes *attrib;
- array = &arrays[vp->index_to_input[0]];
- binding = array->BufferBinding;
- attrib = array->VertexAttrib;
-
- low_addr = _mesa_vertex_attrib_address(attrib, binding);
-
- for (attr = 1; attr < vp->num_inputs; attr++) {
- const GLubyte *start;
- array = &arrays[vp->index_to_input[attr]];
- binding = array->BufferBinding;
- attrib = array->VertexAttrib;
- start = _mesa_vertex_attrib_address(attrib, binding);
- low_addr = MIN2(low_addr, start);
- }
- }
-
/* loop over TGSI shader inputs to determine vertex buffer
* and attribute info
*/
for (attr = 0; attr < vp->num_inputs; attr++) {
const GLuint mesaAttr = vp->index_to_input[attr];
- const struct gl_vertex_array *array = &arrays[mesaAttr];
const struct gl_vertex_buffer_binding *binding;
const struct gl_array_attributes *attrib;
- struct gl_buffer_object *bufobj;
void *map;
- binding = array->BufferBinding;
- attrib = array->VertexAttrib;
- bufobj = binding->BufferObj;
+ _mesa_draw_attrib_and_binding(ctx, mesaAttr, &attrib, &binding);
- if (bufobj && bufobj->Name) {
- /* Attribute data is in a VBO.
- * Recall that for VBOs, the gl_vertex_array->Ptr field is
- * really an offset from the start of the VBO, not a pointer.
- */
- struct st_buffer_object *stobj = st_buffer_object(bufobj);
+ if (_mesa_is_bufferobj(binding->BufferObj)) {
+ /* Attribute data is in a VBO. */
+ struct st_buffer_object *stobj = st_buffer_object(binding->BufferObj);
assert(stobj->buffer);
vbuffers[attr].buffer.resource = NULL;
vbuffers[attr].is_user_buffer = false;
pipe_resource_reference(&vbuffers[attr].buffer.resource, stobj->buffer);
- vbuffers[attr].buffer_offset = pointer_to_offset(low_addr);
- velements[attr].src_offset = binding->Offset
- + attrib->RelativeOffset - pointer_to_offset(low_addr);
+ vbuffers[attr].buffer_offset = _mesa_draw_binding_offset(binding);
+ velements[attr].src_offset =
+ _mesa_draw_attributes_relative_offset(attrib);
/* map the attrib buffer */
map = pipe_buffer_map(pipe, vbuffers[attr].buffer.resource,
vbuffers[attr].buffer.resource->width0);
}
else {
+ /* Attribute data is in a user space array. */
vbuffers[attr].buffer.user = attrib->Ptr;
vbuffers[attr].is_user_buffer = true;
vbuffers[attr].buffer_offset = 0;