summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
authorMathias Fröhlich <[email protected]>2018-03-04 18:15:53 +0100
committerMathias Fröhlich <[email protected]>2018-03-10 07:33:51 +0100
commit64d2a20480547d5897fd9d7b8fd306f2625138cb (patch)
tree15d831310fe0a2e2ff7d3c58eac8fceecc738f15 /src/mesa/drivers
parentd62f0df3541ab9ee7a4999f0ecedc52f8d1ab8cc (diff)
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 <[email protected]> Signed-off-by: Mathias Fröhlich <[email protected]>
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h2
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c28
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c130
-rw-r--r--src/mesa/drivers/dri/i965/genX_state_upload.c23
-rw-r--r--src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c81
5 files changed, 149 insertions, 115 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index d3e7c71207b..177273c3645 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -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)
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index 299e7f929e7..0d1ae8982cb 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -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;
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index c058064403e..4ede33aea17 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -249,21 +249,21 @@ double_types(struct brw_context *brw,
*/
unsigned
brw_get_vertex_surface_type(struct brw_context *brw,
- const struct gl_vertex_array *glarray)
+ const struct gl_array_attributes *glattrib)
{
- int size = glarray->Size;
+ int size = glattrib->Size;
const struct gen_device_info *devinfo = &brw->screen->devinfo;
const bool is_ivybridge_or_older =
devinfo->gen <= 7 && !devinfo->is_baytrail && !devinfo->is_haswell;
if (unlikely(INTEL_DEBUG & DEBUG_VERTS))
fprintf(stderr, "type %s size %d normalized %d\n",
- _mesa_enum_to_string(glarray->Type),
- glarray->Size, glarray->Normalized);
+ _mesa_enum_to_string(glattrib->Type),
+ glattrib->Size, glattrib->Normalized);
- if (glarray->Integer) {
- assert(glarray->Format == GL_RGBA); /* sanity check */
- switch (glarray->Type) {
+ if (glattrib->Integer) {
+ assert(glattrib->Format == GL_RGBA); /* sanity check */
+ switch (glattrib->Type) {
case GL_INT: return int_types_direct[size];
case GL_SHORT:
if (is_ivybridge_or_older && size == 3)
@@ -288,11 +288,11 @@ brw_get_vertex_surface_type(struct brw_context *brw,
return ubyte_types_direct[size];
default: unreachable("not reached");
}
- } else if (glarray->Type == GL_UNSIGNED_INT_10F_11F_11F_REV) {
+ } else if (glattrib->Type == GL_UNSIGNED_INT_10F_11F_11F_REV) {
return ISL_FORMAT_R11G11B10_FLOAT;
- } else if (glarray->Normalized) {
- switch (glarray->Type) {
- case GL_DOUBLE: return double_types(brw, size, glarray->Doubles);
+ } else if (glattrib->Normalized) {
+ switch (glattrib->Type) {
+ case GL_DOUBLE: return double_types(brw, size, glattrib->Doubles);
case GL_FLOAT: return float_types[size];
case GL_HALF_FLOAT:
case GL_HALF_FLOAT_OES:
@@ -306,7 +306,7 @@ brw_get_vertex_surface_type(struct brw_context *brw,
case GL_UNSIGNED_INT: return uint_types_norm[size];
case GL_UNSIGNED_SHORT: return ushort_types_norm[size];
case GL_UNSIGNED_BYTE:
- if (glarray->Format == GL_BGRA) {
+ if (glattrib->Format == GL_BGRA) {
/* See GL_EXT_vertex_array_bgra */
assert(size == 4);
return ISL_FORMAT_B8G8R8A8_UNORM;
@@ -330,7 +330,7 @@ brw_get_vertex_surface_type(struct brw_context *brw,
case GL_INT_2_10_10_10_REV:
assert(size == 4);
if (devinfo->gen >= 8 || devinfo->is_haswell) {
- return glarray->Format == GL_BGRA
+ return glattrib->Format == GL_BGRA
? ISL_FORMAT_B10G10R10A2_SNORM
: ISL_FORMAT_R10G10B10A2_SNORM;
}
@@ -338,7 +338,7 @@ brw_get_vertex_surface_type(struct brw_context *brw,
case GL_UNSIGNED_INT_2_10_10_10_REV:
assert(size == 4);
if (devinfo->gen >= 8 || devinfo->is_haswell) {
- return glarray->Format == GL_BGRA
+ return glattrib->Format == GL_BGRA
? ISL_FORMAT_B10G10R10A2_UNORM
: ISL_FORMAT_R10G10B10A2_UNORM;
}
@@ -352,26 +352,26 @@ brw_get_vertex_surface_type(struct brw_context *brw,
* like to use here, so upload everything as UINT and fix
* it in the shader
*/
- if (glarray->Type == GL_INT_2_10_10_10_REV) {
+ if (glattrib->Type == GL_INT_2_10_10_10_REV) {
assert(size == 4);
if (devinfo->gen >= 8 || devinfo->is_haswell) {
- return glarray->Format == GL_BGRA
+ return glattrib->Format == GL_BGRA
? ISL_FORMAT_B10G10R10A2_SSCALED
: ISL_FORMAT_R10G10B10A2_SSCALED;
}
return ISL_FORMAT_R10G10B10A2_UINT;
- } else if (glarray->Type == GL_UNSIGNED_INT_2_10_10_10_REV) {
+ } else if (glattrib->Type == GL_UNSIGNED_INT_2_10_10_10_REV) {
assert(size == 4);
if (devinfo->gen >= 8 || devinfo->is_haswell) {
- return glarray->Format == GL_BGRA
+ return glattrib->Format == GL_BGRA
? ISL_FORMAT_B10G10R10A2_USCALED
: ISL_FORMAT_R10G10B10A2_USCALED;
}
return ISL_FORMAT_R10G10B10A2_UINT;
}
- assert(glarray->Format == GL_RGBA); /* sanity check */
- switch (glarray->Type) {
- case GL_DOUBLE: return double_types(brw, size, glarray->Doubles);
+ assert(glattrib->Format == GL_RGBA); /* sanity check */
+ switch (glattrib->Type) {
+ case GL_DOUBLE: return double_types(brw, size, glattrib->Doubles);
case GL_FLOAT: return float_types[size];
case GL_HALF_FLOAT:
case GL_HALF_FLOAT_OES:
@@ -405,24 +405,25 @@ copy_array_to_vbo_array(struct brw_context *brw,
struct brw_vertex_buffer *buffer,
GLuint dst_stride)
{
- const int src_stride = element->glarray->StrideB;
+ const struct gl_vertex_array *glarray = element->glarray;
+ const struct gl_vertex_buffer_binding *glbinding = glarray->BufferBinding;
+ const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
+ const int src_stride = glbinding->Stride;
/* If the source stride is zero, we just want to upload the current
* attribute once and set the buffer's stride to 0. There's no need
* to replicate it out.
*/
if (src_stride == 0) {
- brw_upload_data(&brw->upload, element->glarray->Ptr,
- element->glarray->_ElementSize,
- element->glarray->_ElementSize,
- &buffer->bo, &buffer->offset);
+ brw_upload_data(&brw->upload, glattrib->Ptr, glattrib->_ElementSize,
+ glattrib->_ElementSize, &buffer->bo, &buffer->offset);
buffer->stride = 0;
- buffer->size = element->glarray->_ElementSize;
+ buffer->size = glattrib->_ElementSize;
return;
}
- const unsigned char *src = element->glarray->Ptr + min * src_stride;
+ const unsigned char *src = glattrib->Ptr + min * src_stride;
int count = max - min + 1;
GLuint size = count * dst_stride;
uint8_t *dst = brw_upload_space(&brw->upload, size, dst_stride,
@@ -514,28 +515,30 @@ brw_prepare_vertices(struct brw_context *brw)
for (i = j = 0; i < brw->vb.nr_enabled; i++) {
struct brw_vertex_element *input = brw->vb.enabled[i];
const struct gl_vertex_array *glarray = input->glarray;
+ const struct gl_vertex_buffer_binding *glbinding = glarray->BufferBinding;
+ const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
- if (_mesa_is_bufferobj(glarray->BufferObj)) {
+ if (_mesa_is_bufferobj(glbinding->BufferObj)) {
struct intel_buffer_object *intel_buffer =
- intel_buffer_object(glarray->BufferObj);
+ intel_buffer_object(glbinding->BufferObj);
- const uint32_t offset = (uintptr_t)glarray->Ptr;
+ const uint32_t offset = glbinding->Offset + glattrib->RelativeOffset;
/* Start with the worst case */
uint32_t start = 0;
uint32_t range = intel_buffer->Base.Size;
- if (glarray->InstanceDivisor) {
+ if (glbinding->InstanceDivisor) {
if (brw->num_instances) {
- start = offset + glarray->StrideB * brw->baseinstance;
- range = (glarray->StrideB * ((brw->num_instances - 1) /
- glarray->InstanceDivisor) +
- glarray->_ElementSize);
+ start = offset + glbinding->Stride * brw->baseinstance;
+ range = (glbinding->Stride * ((brw->num_instances - 1) /
+ glbinding->InstanceDivisor) +
+ glattrib->_ElementSize);
}
} else {
if (brw->vb.index_bounds_valid) {
- start = offset + min_index * glarray->StrideB;
- range = (glarray->StrideB * (max_index - min_index) +
- glarray->_ElementSize);
+ start = offset + min_index * glbinding->Stride;
+ range = (glbinding->Stride * (max_index - min_index) +
+ glattrib->_ElementSize);
}
}
@@ -546,13 +549,16 @@ brw_prepare_vertices(struct brw_context *brw)
unsigned k;
for (k = 0; k < i; k++) {
const struct gl_vertex_array *other = brw->vb.enabled[k]->glarray;
- if (glarray->BufferObj == other->BufferObj &&
- glarray->StrideB == other->StrideB &&
- glarray->InstanceDivisor == other->InstanceDivisor &&
- (uintptr_t)(glarray->Ptr - other->Ptr) < glarray->StrideB)
+ const struct gl_vertex_buffer_binding *obind = other->BufferBinding;
+ const struct gl_array_attributes *oattrib = other->VertexAttrib;
+ const uint32_t ooffset = obind->Offset + oattrib->RelativeOffset;
+ if (glbinding->BufferObj == obind->BufferObj &&
+ glbinding->Stride == obind->Stride &&
+ glbinding->InstanceDivisor == obind->InstanceDivisor &&
+ (offset - ooffset) < glbinding->Stride)
{
input->buffer = brw->vb.enabled[k]->buffer;
- input->offset = glarray->Ptr - other->Ptr;
+ input->offset = offset - ooffset;
buffer_range_start[input->buffer] =
MIN2(buffer_range_start[input->buffer], start);
@@ -566,9 +572,9 @@ brw_prepare_vertices(struct brw_context *brw)
/* Named buffer object: Just reference its contents directly. */
buffer->offset = offset;
- buffer->stride = glarray->StrideB;
- buffer->step_rate = glarray->InstanceDivisor;
- buffer->size = glarray->BufferObj->Size - offset;
+ buffer->stride = glbinding->Stride;
+ buffer->step_rate = glbinding->InstanceDivisor;
+ buffer->size = glbinding->BufferObj->Size - offset;
enabled_buffer[j] = intel_buffer;
buffer_range_start[j] = start;
@@ -582,13 +588,13 @@ brw_prepare_vertices(struct brw_context *brw)
* when we've decided if we're doing interleaved or not.
*/
if (nr_uploads == 0) {
- interleaved = glarray->StrideB;
- ptr = glarray->Ptr;
+ interleaved = glbinding->Stride;
+ ptr = glattrib->Ptr;
}
- else if (interleaved != glarray->StrideB ||
- glarray->InstanceDivisor != 0 ||
- glarray->Ptr < ptr ||
- (uintptr_t)(glarray->Ptr - ptr) + glarray->_ElementSize > interleaved)
+ else if (interleaved != glbinding->Stride ||
+ glbinding->InstanceDivisor != 0 ||
+ glattrib->Ptr < ptr ||
+ (uintptr_t)(glattrib->Ptr - ptr) + glattrib->_ElementSize > interleaved)
{
/* If our stride is different from the first attribute's stride,
* or if we are using an instance divisor or if the first
@@ -654,9 +660,10 @@ brw_prepare_vertices(struct brw_context *brw)
buffer->step_rate = 0;
for (i = 0; i < nr_uploads; i++) {
+ const struct gl_vertex_array *glarray = upload[i]->glarray;
+ const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
/* Then, just point upload[i] at upload[0]'s buffer. */
- upload[i]->offset =
- ((const unsigned char *)upload[i]->glarray->Ptr - ptr);
+ upload[i]->offset = ((const unsigned char *)glattrib->Ptr - ptr);
upload[i]->buffer = j;
}
j++;
@@ -667,22 +674,25 @@ brw_prepare_vertices(struct brw_context *brw)
/* Upload non-interleaved arrays */
for (i = 0; i < nr_uploads; i++) {
struct brw_vertex_buffer *buffer = &brw->vb.buffers[j];
- if (upload[i]->glarray->InstanceDivisor == 0) {
+ const struct gl_vertex_array *glarray = upload[i]->glarray;
+ const struct gl_vertex_buffer_binding *glbinding = glarray->BufferBinding;
+ const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
+ if (glbinding->InstanceDivisor == 0) {
copy_array_to_vbo_array(brw, upload[i], min_index, max_index,
- buffer, upload[i]->glarray->_ElementSize);
+ buffer, glattrib->_ElementSize);
} else {
/* This is an instanced attribute, since its InstanceDivisor
* is not zero. Therefore, its data will be stepped after the
* instanced draw has been run InstanceDivisor times.
*/
uint32_t instanced_attr_max_index =
- (brw->num_instances - 1) / upload[i]->glarray->InstanceDivisor;
+ (brw->num_instances - 1) / glbinding->InstanceDivisor;
copy_array_to_vbo_array(brw, upload[i], 0, instanced_attr_max_index,
- buffer, upload[i]->glarray->_ElementSize);
+ buffer, glattrib->_ElementSize);
}
buffer->offset -= delta * buffer->stride;
buffer->size += delta * buffer->stride;
- buffer->step_rate = upload[i]->glarray->InstanceDivisor;
+ buffer->step_rate = glbinding->InstanceDivisor;
upload[i]->buffer = j++;
upload[i]->offset = 0;
}
diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 211fae58e9d..a69a496f1db 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -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,
diff --git a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
index b9145e6851a..a7b911c50ea 100644
--- a/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
+++ b/src/mesa/drivers/dri/nouveau/nouveau_vbo_t.c
@@ -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,