Commit 64d2a204 authored by Mathias Fröhlich's avatar Mathias Fröhlich

mesa: Make gl_vertex_array contain pointers to first order VAO members.

Instead of keeping a copy of the vertex array content in
struct gl_vertex_array only keep pointers to the first order
information originaly in the VAO.
For that represent the current values by struct gl_array_attributes
and struct gl_vertex_buffer_binding.

v2: Change comments.
    Remove gl... prefix from variables except in the i965 directory where
    it was like that before. Reindent because of that.
Reviewed-by: Brian Paul's avatarBrian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich's avatarMathias Fröhlich <Mathias.Froehlich@web.de>
parent d62f0df3
......@@ -1459,7 +1459,7 @@ gl_clip_plane *brw_select_clip_planes(struct gl_context *ctx);
/* brw_draw_upload.c */
unsigned brw_get_vertex_surface_type(struct brw_context *brw,
const struct gl_vertex_array *glarray);
const struct gl_array_attributes *glattr);
static inline unsigned
brw_get_index_type(unsigned index_size)
......
......@@ -277,7 +277,7 @@ brw_emit_prim(struct brw_context *brw,
static void
brw_merge_inputs(struct brw_context *brw,
const struct gl_vertex_array *arrays[])
const struct gl_vertex_array *arrays)
{
const struct gen_device_info *devinfo = &brw->screen->devinfo;
const struct gl_context *ctx = &brw->ctx;
......@@ -291,7 +291,7 @@ brw_merge_inputs(struct brw_context *brw,
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
brw->vb.inputs[i].buffer = -1;
brw->vb.inputs[i].glarray = arrays[i];
brw->vb.inputs[i].glarray = &arrays[i];
}
if (devinfo->gen < 8 && !devinfo->is_haswell) {
......@@ -300,14 +300,16 @@ brw_merge_inputs(struct brw_context *brw,
* 2_10_10_10_REV vertex formats. Set appropriate workaround flags.
*/
while (mask) {
const struct gl_array_attributes *glattrib;
uint8_t wa_flags = 0;
i = u_bit_scan64(&mask);
glattrib = brw->vb.inputs[i].glarray->VertexAttrib;
switch (brw->vb.inputs[i].glarray->Type) {
switch (glattrib->Type) {
case GL_FIXED:
wa_flags = brw->vb.inputs[i].glarray->Size;
wa_flags = glattrib->Size;
break;
case GL_INT_2_10_10_10_REV:
......@@ -315,12 +317,12 @@ brw_merge_inputs(struct brw_context *brw,
/* fallthough */
case GL_UNSIGNED_INT_2_10_10_10_REV:
if (brw->vb.inputs[i].glarray->Format == GL_BGRA)
if (glattrib->Format == GL_BGRA)
wa_flags |= BRW_ATTRIB_WA_BGRA;
if (brw->vb.inputs[i].glarray->Normalized)
if (glattrib->Normalized)
wa_flags |= BRW_ATTRIB_WA_NORMALIZE;
else if (!brw->vb.inputs[i].glarray->Integer)
else if (!glattrib->Integer)
wa_flags |= BRW_ATTRIB_WA_SCALE;
break;
......@@ -689,7 +691,7 @@ brw_postdraw_reconcile_align_wa_slices(struct brw_context *brw)
static void
brw_prepare_drawing(struct gl_context *ctx,
const struct gl_vertex_array *arrays[],
const struct gl_vertex_array *arrays,
const struct _mesa_index_buffer *ib,
bool index_bounds_valid,
GLuint min_index,
......@@ -776,7 +778,7 @@ brw_finish_drawing(struct gl_context *ctx)
*/
static void
brw_draw_single_prim(struct gl_context *ctx,
const struct gl_vertex_array *arrays[],
const struct gl_vertex_array *arrays,
const struct _mesa_prim *prim,
unsigned prim_id,
struct brw_transform_feedback_object *xfb_obj,
......@@ -911,13 +913,13 @@ retry:
static bool
all_varyings_in_vbos(const struct gl_vertex_array *arrays[])
all_varyings_in_vbos(const struct gl_vertex_array *arrays)
{
GLuint i;
for (i = 0; i < VERT_ATTRIB_MAX; i++)
if (arrays[i]->StrideB &&
arrays[i]->BufferObj->Name == 0)
if (arrays[i].BufferBinding->Stride &&
arrays[i].BufferBinding->BufferObj->Name == 0)
return false;
return true;
......@@ -939,7 +941,7 @@ brw_draw_prims(struct gl_context *ctx,
{
unsigned i;
struct brw_context *brw = brw_context(ctx);
const struct gl_vertex_array **arrays = ctx->Array._DrawArrays;
const struct gl_vertex_array *arrays = ctx->Array._DrawArrays;
int predicate_state = brw->predicate.state;
struct brw_transform_feedback_object *xfb_obj =
(struct brw_transform_feedback_object *) gl_xfb_obj;
......
This diff is collapsed.
......@@ -553,7 +553,9 @@ genX(emit_vertices)(struct brw_context *brw)
*/
for (unsigned i = 0; i < brw->vb.nr_enabled; i++) {
struct brw_vertex_element *input = brw->vb.enabled[i];
uint32_t format = brw_get_vertex_surface_type(brw, input->glarray);
const struct gl_vertex_array *glarray = input->glarray;
const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
uint32_t format = brw_get_vertex_surface_type(brw, glattrib);
if (uploads_needed(format, input->is_dual_slot) > 1)
nr_elements++;
......@@ -646,7 +648,9 @@ genX(emit_vertices)(struct brw_context *brw)
unsigned i;
for (i = 0; i < brw->vb.nr_enabled; i++) {
const struct brw_vertex_element *input = brw->vb.enabled[i];
uint32_t format = brw_get_vertex_surface_type(brw, input->glarray);
const struct gl_vertex_array *glarray = input->glarray;
const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
uint32_t format = brw_get_vertex_surface_type(brw, glattrib);
uint32_t comp0 = VFCOMP_STORE_SRC;
uint32_t comp1 = VFCOMP_STORE_SRC;
uint32_t comp2 = VFCOMP_STORE_SRC;
......@@ -687,17 +691,19 @@ genX(emit_vertices)(struct brw_context *brw)
* entry. */
const unsigned offset = input->offset + c * 16;
const struct gl_vertex_array *glarray = input->glarray;
const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
const int size = (GEN_GEN < 8 && is_passthru_format(format)) ?
upload_format_size(upload_format) : input->glarray->Size;
upload_format_size(upload_format) : glattrib->Size;
switch (size) {
case 0: comp0 = VFCOMP_STORE_0;
case 1: comp1 = VFCOMP_STORE_0;
case 2: comp2 = VFCOMP_STORE_0;
case 3:
if (GEN_GEN >= 8 && input->glarray->Doubles) {
if (GEN_GEN >= 8 && glattrib->Doubles) {
comp3 = VFCOMP_STORE_0;
} else if (input->glarray->Integer) {
} else if (glattrib->Integer) {
comp3 = VFCOMP_STORE_1_INT;
} else {
comp3 = VFCOMP_STORE_1_FP;
......@@ -722,7 +728,7 @@ genX(emit_vertices)(struct brw_context *brw)
* to be specified as VFCOMP_STORE_0 in order to output a 256-bit
* vertex element."
*/
if (input->glarray->Doubles && !input->is_dual_slot) {
if (glattrib->Doubles && !input->is_dual_slot) {
/* Store vertex elements which correspond to double and dvec2 vertex
* shader inputs as 128-bit vertex elements, instead of 256-bits.
*/
......@@ -810,8 +816,9 @@ genX(emit_vertices)(struct brw_context *brw)
#if GEN_GEN >= 6
if (gen6_edgeflag_input) {
const uint32_t format =
brw_get_vertex_surface_type(brw, gen6_edgeflag_input->glarray);
const struct gl_vertex_array *glarray = gen6_edgeflag_input->glarray;
const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
const uint32_t format = brw_get_vertex_surface_type(brw, glattrib);
struct GENX(VERTEX_ELEMENT_STATE) elem_state = {
.Valid = true,
......
......@@ -30,6 +30,7 @@
#include "main/bufferobj.h"
#include "main/glformats.h"
#include "main/varray.h"
#include "main/image.h"
/* Arbitrary pushbuf length we can assume we can get with a single
......@@ -43,17 +44,20 @@ static int
get_array_stride(struct gl_context *ctx, const struct gl_vertex_array *a)
{
struct nouveau_render_state *render = to_render_state(ctx);
const struct gl_vertex_buffer_binding *binding = a->BufferBinding;
if (render->mode == VBO && !_mesa_is_bufferobj(a->BufferObj))
if (render->mode == VBO && !_mesa_is_bufferobj(binding->BufferObj)) {
const struct gl_array_attributes *attrib = a->VertexAttrib;
/* Pack client buffers. */
return align(_mesa_sizeof_type(a->Type) * a->Size, 4);
else
return a->StrideB;
return align(_mesa_sizeof_type(attrib->Type) * attrib->Size, 4);
} else {
return binding->Stride;
}
}
static void
vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
const struct gl_vertex_array **arrays)
const struct gl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
GLboolean imm = (render->mode == IMM);
......@@ -74,19 +78,23 @@ vbo_init_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
}
FOR_EACH_BOUND_ATTR(render, i, attr) {
const struct gl_vertex_array *array = arrays[attr];
const struct gl_vertex_array *array = &arrays[attr];
const struct gl_vertex_buffer_binding *binding =
array->BufferBinding;
const struct gl_array_attributes *attrib = array->VertexAttrib;
const GLubyte *p = _mesa_vertex_attrib_address(attrib, binding);
nouveau_init_array(&render->attrs[attr], attr,
get_array_stride(ctx, array),
array->Size, array->Type,
imm ? array->BufferObj : NULL,
array->Ptr, imm, ctx);
attrib->Size, attrib->Type,
imm ? binding->BufferObj : NULL,
p, imm, ctx);
}
}
static void
vbo_deinit_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
const struct gl_vertex_array **arrays)
const struct gl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i, attr;
......@@ -110,7 +118,7 @@ vbo_deinit_arrays(struct gl_context *ctx, const struct _mesa_index_buffer *ib,
/* Make some rendering decisions from the GL context. */
static void
vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array **arrays)
vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i;
......@@ -119,7 +127,7 @@ vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array **ar
if (ctx->Light.Enabled) {
for (i = 0; i < VERT_ATTRIB_MAT_MAX; i++) {
if (arrays[VERT_ATTRIB_MAT(i)]->StrideB) {
if (arrays[VERT_ATTRIB_MAT(i)].BufferBinding->Stride) {
render->mode = IMM;
break;
}
......@@ -128,23 +136,26 @@ vbo_choose_render_mode(struct gl_context *ctx, const struct gl_vertex_array **ar
}
static void
vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array **arrays,
vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array *arrays,
int attr)
{
struct nouveau_pushbuf *push = context_push(ctx);
struct nouveau_render_state *render = to_render_state(ctx);
const struct gl_vertex_array *array = arrays[attr];
const struct gl_vertex_array *array = &arrays[attr];
const struct gl_vertex_buffer_binding *binding = array->BufferBinding;
const struct gl_array_attributes *attrib = array->VertexAttrib;
const GLubyte *p = _mesa_vertex_attrib_address(attrib, binding);
struct nouveau_array *a = &render->attrs[attr];
RENDER_LOCALS(ctx);
if (!array->StrideB) {
if (!binding->Stride) {
if (attr >= VERT_ATTRIB_MAT(0))
/* nouveau_update_state takes care of materials. */
return;
/* Constant attribute. */
nouveau_init_array(a, attr, array->StrideB, array->Size,
array->Type, array->BufferObj, array->Ptr,
nouveau_init_array(a, attr, binding->Stride, attrib->Size,
attrib->Type, binding->BufferObj, p,
GL_TRUE, ctx);
EMIT_IMM(ctx, a, 0);
nouveau_deinit_array(a);
......@@ -155,7 +166,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array **arrays,
if (render->mode == VBO) {
render->map[info->vbo_index] = attr;
render->vertex_size += array->_ElementSize;
render->vertex_size += attrib->_ElementSize;
render->attr_count = MAX2(render->attr_count,
info->vbo_index + 1);
} else {
......@@ -168,7 +179,7 @@ vbo_emit_attr(struct gl_context *ctx, const struct gl_vertex_array **arrays,
#define MAT(a) VERT_ATTRIB_MAT(MAT_ATTRIB_##a)
static void
vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array **arrays)
vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i;
......@@ -211,15 +222,15 @@ vbo_choose_attrs(struct gl_context *ctx, const struct gl_vertex_array **arrays)
}
static int
get_max_client_stride(struct gl_context *ctx, const struct gl_vertex_array **arrays)
get_max_client_stride(struct gl_context *ctx, const struct gl_vertex_array *arrays)
{
struct nouveau_render_state *render = to_render_state(ctx);
int i, attr, s = 0;
FOR_EACH_BOUND_ATTR(render, i, attr) {
const struct gl_vertex_array *a = arrays[attr];
const struct gl_vertex_array *a = &arrays[attr];
if (!_mesa_is_bufferobj(a->BufferObj))
if (!_mesa_is_bufferobj(a->BufferBinding->BufferObj))
s = MAX2(s, get_array_stride(ctx, a));
}
......@@ -237,7 +248,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
struct gl_buffer_object *indirect);
static GLboolean
vbo_maybe_split(struct gl_context *ctx, const struct gl_vertex_array **arrays,
vbo_maybe_split(struct gl_context *ctx, const struct gl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib,
GLuint min_index, GLuint max_index)
......@@ -297,7 +308,7 @@ check_update_array(struct nouveau_array *a, unsigned offset,
}
static void
vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array **arrays,
vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array *arrays,
int base, unsigned min_index, unsigned max_index, int *pdelta)
{
struct nouveau_render_state *render = to_render_state(ctx);
......@@ -311,22 +322,26 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array **arrays,
*pdelta = -1;
FOR_EACH_BOUND_ATTR(render, i, attr) {
const struct gl_vertex_array *array = arrays[attr];
struct gl_buffer_object *obj = array->BufferObj;
const struct gl_vertex_array *array = &arrays[attr];
const struct gl_vertex_buffer_binding *binding =
array->BufferBinding;
const struct gl_array_attributes *attrib = array->VertexAttrib;
const GLubyte *p = _mesa_vertex_attrib_address(attrib, binding);
struct gl_buffer_object *obj = binding->BufferObj;
struct nouveau_array *a = &render->attrs[attr];
unsigned delta = (base + min_index) * array->StrideB;
unsigned delta = (base + min_index) * binding->Stride;
bo[i] = NULL;
if (nouveau_bufferobj_hw(obj)) {
/* Array in a buffer obj. */
nouveau_bo_ref(to_nouveau_bufferobj(obj)->bo, &bo[i]);
offset[i] = delta + (intptr_t)array->Ptr;
offset[i] = delta + (intptr_t)p;
} else {
int n = max_index - min_index + 1;
char *sp = (char *)ADD_POINTERS(
nouveau_bufferobj_sys(obj), array->Ptr) + delta;
nouveau_bufferobj_sys(obj), p) + delta;
char *dp = nouveau_get_scratch(ctx, n * a->stride,
&bo[i], &offset[i]);
......@@ -334,7 +349,7 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array **arrays,
* scratch buffer obj. */
for (j = 0; j < n; j++)
memcpy(dp + j * a->stride,
sp + j * array->StrideB,
sp + j * binding->Stride,
a->stride);
}
......@@ -365,7 +380,7 @@ vbo_bind_vertices(struct gl_context *ctx, const struct gl_vertex_array **arrays,
}
static void
vbo_draw_vbo(struct gl_context *ctx, const struct gl_vertex_array **arrays,
vbo_draw_vbo(struct gl_context *ctx, const struct gl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib, GLuint min_index,
GLuint max_index)
......@@ -415,7 +430,7 @@ extract_id(struct nouveau_array *a, int i, int j)
}
static void
vbo_draw_imm(struct gl_context *ctx, const struct gl_vertex_array **arrays,
vbo_draw_imm(struct gl_context *ctx, const struct gl_vertex_array *arrays,
const struct _mesa_prim *prims, GLuint nr_prims,
const struct _mesa_index_buffer *ib, GLuint min_index,
GLuint max_index)
......@@ -470,7 +485,7 @@ TAG(vbo_render_prims)(struct gl_context *ctx,
struct gl_buffer_object *indirect)
{
struct nouveau_render_state *render = to_render_state(ctx);
const struct gl_vertex_array **arrays = ctx->Array._DrawArrays;
const struct gl_vertex_array *arrays = ctx->Array._DrawArrays;
if (!index_bounds_valid)
vbo_get_minmax_indices(ctx, prims, ib, &min_index, &max_index,
......
......@@ -284,9 +284,6 @@ unbind_array_object_vbos(struct gl_context *ctx, struct gl_vertex_array_object *
for (i = 0; i < ARRAY_SIZE(obj->BufferBinding); i++)
_mesa_reference_buffer_object(ctx, &obj->BufferBinding[i].BufferObj, NULL);
for (i = 0; i < ARRAY_SIZE(obj->_VertexArray); i++)
_mesa_reference_buffer_object(ctx, &obj->_VertexArray[i].BufferObj, NULL);
}
......@@ -462,21 +459,8 @@ void
_mesa_update_vao_derived_arrays(struct gl_context *ctx,
struct gl_vertex_array_object *vao)
{
GLbitfield arrays = vao->NewArrays;
/* Make sure we do not run into problems with shared objects */
assert(!vao->SharedAndImmutable || vao->NewArrays == 0);
while (arrays) {
const int attrib = u_bit_scan(&arrays);
struct gl_vertex_array *array = &vao->_VertexArray[attrib];
const struct gl_array_attributes *attribs =
&vao->VertexAttrib[attrib];
const struct gl_vertex_buffer_binding *buffer_binding =
&vao->BufferBinding[attribs->BufferBindingIndex];
_mesa_update_vertex_array(ctx, array, attribs, buffer_binding);
}
}
......
......@@ -1507,7 +1507,6 @@ copy_array_object(struct gl_context *ctx,
/* skip RefCount */
for (i = 0; i < ARRAY_SIZE(src->VertexAttrib); i++) {
_mesa_copy_vertex_array(ctx, &dest->_VertexArray[i], &src->_VertexArray[i]);
_mesa_copy_vertex_attrib_array(ctx, &dest->VertexAttrib[i], &src->VertexAttrib[i]);
_mesa_copy_vertex_buffer_binding(ctx, &dest->BufferBinding[i], &src->BufferBinding[i]);
}
......
......@@ -1503,29 +1503,6 @@ struct gl_pixelstore_attrib
};
/**
* Vertex array information which is derived from gl_array_attributes
* and gl_vertex_buffer_binding information. Used by the VBO module and
* device drivers.
*/
struct gl_vertex_array
{
/** if NULL, vertex data are in user memory */
struct gl_buffer_object *BufferObj;
/** Pointer into user memory, or offset into the BufferObj */
const GLubyte *Ptr;
GLsizei StrideB; /**< actual stride in bytes */
GLuint InstanceDivisor; /**< GL_ARB_instanced_arrays */
GLenum16 Type; /**< datatype: GL_FLOAT, GL_INT, etc */
GLenum16 Format; /**< default: GL_RGBA, but may be GL_BGRA */
unsigned Size:4; /**< components per element (1,2,3,4) */
unsigned _ElementSize:8; /**< in bytes, up to 4*sizeof(GLdouble) */
unsigned Normalized:1; /**< GL_ARB_vertex_program */
unsigned Integer:1; /**< Integer-valued? */
unsigned Doubles:1; /**< doubles not converted to floats */
};
/**
* Enum for defining the mapping for the position/generic0 attribute.
*
......@@ -1589,6 +1566,20 @@ struct gl_vertex_buffer_binding
};
/**
* Vertex array information which is derived from gl_array_attributes
* and gl_vertex_buffer_binding information. Used by the VBO module and
* device drivers.
*/
struct gl_vertex_array
{
/** Vertex attribute array */
const struct gl_array_attributes *VertexAttrib;
/** Vertex buffer binding */
const struct gl_vertex_buffer_binding *BufferBinding;
};
/**
* A representation of "Vertex Array Objects" (VAOs) from OpenGL 3.1+ /
* the GL_ARB_vertex_array_object extension.
......@@ -1614,14 +1605,6 @@ struct gl_vertex_array_object
*/
bool SharedAndImmutable;
/**
* Derived vertex attribute arrays
*
* This is a legacy data structure created from gl_array_attributes and
* gl_vertex_buffer_binding, only used by the VBO module at this time.
*/
struct gl_vertex_array _VertexArray[VERT_ATTRIB_MAX];
/** Vertex attribute arrays */
struct gl_array_attributes VertexAttrib[VERT_ATTRIB_MAX];
......@@ -1724,7 +1707,7 @@ struct gl_array_attrib
* Vertex arrays as consumed by a driver.
* The array pointer is set up only by the VBO module.
*/
const struct gl_vertex_array **_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */
const struct gl_vertex_array *_DrawArrays; /**< 0..VERT_ATTRIB_MAX-1 */
/** Legal array datatypes and the API for which they have been computed */
GLbitfield LegalTypesMask;
......
......@@ -2845,27 +2845,6 @@ _mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex,
}
/**
* Copy one vertex array to another.
*/
void
_mesa_copy_vertex_array(struct gl_context *ctx,
struct gl_vertex_array *dst,
struct gl_vertex_array *src)
{
dst->Size = src->Size;
dst->Type = src->Type;
dst->Format = src->Format;
dst->StrideB = src->StrideB;
dst->Ptr = src->Ptr;
dst->Normalized = src->Normalized;
dst->Integer = src->Integer;
dst->Doubles = src->Doubles;
dst->InstanceDivisor = src->InstanceDivisor;
dst->_ElementSize = src->_ElementSize;
_mesa_reference_buffer_object(ctx, &dst->BufferObj, src->BufferObj);
}
void
_mesa_copy_vertex_attrib_array(struct gl_context *ctx,
struct gl_array_attributes *dst,
......
......@@ -48,37 +48,6 @@ _mesa_vertex_attrib_address(const struct gl_array_attributes *array,
}
/**
* Sets the fields in a gl_vertex_array to values derived from a
* gl_array_attributes and a gl_vertex_buffer_binding.
*/
static inline void
_mesa_update_vertex_array(struct gl_context *ctx,
struct gl_vertex_array *dst,
const struct gl_array_attributes *attribs,
const struct gl_vertex_buffer_binding *binding)
{
if (attribs->Enabled) {
dst->Size = attribs->Size;
dst->Type = attribs->Type;
dst->Format = attribs->Format;
dst->StrideB = binding->Stride;
dst->Ptr = _mesa_vertex_attrib_address(attribs, binding);
dst->Normalized = attribs->Normalized;
dst->Integer = attribs->Integer;
dst->Doubles = attribs->Doubles;
dst->InstanceDivisor = binding->InstanceDivisor;
dst->_ElementSize = attribs->_ElementSize;
_mesa_reference_buffer_object(ctx, &dst->BufferObj, binding->BufferObj);
} else {
/* Disabled arrays shall not be consumed */
dst->Size = 0;
dst->Ptr = NULL;
_mesa_reference_buffer_object(ctx, &dst->BufferObj, NULL);
}
}
static inline bool
_mesa_attr_zero_aliases_vertex(const struct gl_context *ctx)
{
......@@ -91,7 +60,7 @@ _mesa_attr_zero_aliases_vertex(const struct gl_context *ctx)
*/
static inline void
_mesa_set_drawing_arrays(struct gl_context *ctx,
const struct gl_vertex_array **arrays)
const struct gl_vertex_array *arrays)
{
if (ctx->Array._DrawArrays != arrays) {
ctx->Array._DrawArrays = arrays;
......@@ -495,10 +464,18 @@ extern void GLAPIENTRY
_mesa_VertexArrayBindingDivisor(GLuint vaobj, GLuint bindingIndex,
GLuint divisor);
extern void
_mesa_copy_vertex_array(struct gl_context *ctx,
struct gl_vertex_array *dst,
struct gl_vertex_array *src);
/**
* Shallow copy one vertex array to another.
*/
static inline void
_mesa_copy_vertex_array(struct gl_vertex_array *dst,
const struct gl_vertex_array *src)
{
dst->VertexAttrib = src->VertexAttrib;
dst->BufferBinding = src->BufferBinding;
}
extern void
_mesa_copy_vertex_attrib_array(struct gl_context *ctx,
......
......@@ -138,7 +138,8 @@ static void check_program_state( struct st_context *st )
static void check_attrib_edgeflag(struct st_context *st)
{
const struct gl_vertex_array **arrays = st->ctx->Array._DrawArrays;
const struct gl_vertex_array *arrays = st->ctx->Array._DrawArrays;
const struct gl_vertex_buffer_binding *binding;
GLboolean vertdata_edgeflags, edgeflag_culls_prims, edgeflags_enabled;
struct gl_program *vp = st->ctx->VertexProgram._Current;
......@@ -148,8 +149,8 @@ static void check_attrib_edgeflag(struct st_context *st)
edgeflags_enabled = st->ctx->Polygon.FrontMode != GL_FILL ||
st->ctx->Polygon.BackMode != GL_FILL;
vertdata_edgeflags = edgeflags_enabled &&
arrays[VERT_ATTRIB_EDGEFLAG]->StrideB != 0;
binding = arrays[VERT_ATTRIB_EDGEFLAG].BufferBinding;
vertdata_edgeflags = edgeflags_enabled && binding->Stride != 0;
if (vertdata_edgeflags != st->vertdata_edgeflags) {
st->vertdata_edgeflags = vertdata_edgeflags;
if (vp)
......
This diff is collapsed.
......@@ -60,8 +60,9 @@ struct rastpos_stage
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];
const struct gl_vertex_array *arrays[VERT_ATTRIB_MAX];
struct _mesa_prim prim;
};
......@@ -193,15 +194,16 @@ new_draw_rastpos_stage(struct gl_context *ctx, struct draw_context *draw)
rs->stage.destroy = rastpos_destroy;
rs->ctx = ctx;
rs->binding.Stride = 0;
rs->binding.BufferObj = NULL;
for (i = 0; i < ARRAY_SIZE(rs->array); i++) {
rs->array[i].Size = 4;
rs->array[i].Type = GL_FLOAT;
rs->array[i].Format = GL_RGBA;
rs->array[i].StrideB = 0;
rs->array[i].Ptr = (GLubyte *) ctx->Current.Attrib[i];
rs->array[i].Normalized = GL_TRUE;
rs->array[i].BufferObj = NULL;
rs->arrays[i] = &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->array[i].BufferBinding = &rs->binding;
rs->array[i].VertexAttrib = &rs->attrib[i];
}
rs->prim.mode = GL_POINTS;
......@@ -222,7 +224,7 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
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;
const struct gl_vertex_array *saved_arrays = ctx->Array._DrawArrays;
if (!st->draw)
return;
......@@ -258,13 +260,13 @@ st_RasterPos(struct gl_context *ctx, const GLfloat v[4])
/* All vertex attribs but position were previously initialized above.
* Just plug in position pointer now.
*/
rs->array[0].Ptr = (GLubyte *) v;
rs->attrib[0].Ptr = (GLubyte *) v;
/* Draw the point.
*
* Don't set DriverFlags.NewArray.
* st_feedback_draw_vbo doesn't check for that flag. */
ctx->Array._DrawArrays = rs->arrays;
ctx->Array._DrawArrays = rs->array;
st_feedback_draw_vbo(ctx, &rs->prim, 1, NULL, GL_TRUE, 0, 1,
NULL, 0, NULL);
ctx->Array._DrawArrays = saved_arrays;
......
......@@ -28,6 +28,7 @@
#include "main/imports.h"
#include "main/image.h"
#include "main/macros.h"
#include "main/varray.h"
#include "vbo/vbo.h"