summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/drivers')
-rw-r--r--src/mesa/drivers/dri/i965/brw_context.h3
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw.c25
-rw-r--r--src/mesa/drivers/dri/i965/brw_draw_upload.c31
-rw-r--r--src/mesa/drivers/dri/i965/genX_state_upload.c12
4 files changed, 31 insertions, 40 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
index d8b0d94aaff..d3c2450a88a 100644
--- a/src/mesa/drivers/dri/i965/brw_context.h
+++ b/src/mesa/drivers/dri/i965/brw_context.h
@@ -440,7 +440,8 @@ struct brw_vertex_buffer {
GLuint step_rate;
};
struct brw_vertex_element {
- const struct gl_vertex_array *glarray;
+ const struct gl_array_attributes *glattrib;
+ const struct gl_vertex_buffer_binding *glbinding;
int buffer;
bool is_dual_slot;
diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c
index c5f04264fad..3b47dc7b26b 100644
--- a/src/mesa/drivers/dri/i965/brw_draw.c
+++ b/src/mesa/drivers/dri/i965/brw_draw.c
@@ -278,8 +278,7 @@ brw_emit_prim(struct brw_context *brw,
static void
-brw_merge_inputs(struct brw_context *brw,
- const struct gl_vertex_array *arrays)
+brw_merge_inputs(struct brw_context *brw)
{
const struct gen_device_info *devinfo = &brw->screen->devinfo;
const struct gl_context *ctx = &brw->ctx;
@@ -292,8 +291,10 @@ brw_merge_inputs(struct brw_context *brw,
brw->vb.nr_buffers = 0;
for (i = 0; i < VERT_ATTRIB_MAX; i++) {
- brw->vb.inputs[i].buffer = -1;
- brw->vb.inputs[i].glarray = &arrays[i];
+ struct brw_vertex_element *input = &brw->vb.inputs[i];
+ input->buffer = -1;
+ _mesa_draw_attrib_and_binding(ctx, i,
+ &input->glattrib, &input->glbinding);
}
if (devinfo->gen < 8 && !devinfo->is_haswell) {
@@ -306,7 +307,7 @@ brw_merge_inputs(struct brw_context *brw,
uint8_t wa_flags = 0;
i = u_bit_scan64(&mask);
- glattrib = brw->vb.inputs[i].glarray->VertexAttrib;
+ glattrib = brw->vb.inputs[i].glattrib;
switch (glattrib->Type) {
@@ -693,7 +694,6 @@ 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 _mesa_index_buffer *ib,
bool index_bounds_valid,
GLuint min_index,
@@ -746,7 +746,7 @@ brw_prepare_drawing(struct gl_context *ctx,
/* Bind all inputs, derive varying and size information:
*/
- brw_merge_inputs(brw, arrays);
+ brw_merge_inputs(brw);
brw->ib.ib = ib;
brw->ctx.NewDriverState |= BRW_NEW_INDICES;
@@ -780,7 +780,6 @@ 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 _mesa_prim *prim,
unsigned prim_id,
struct brw_transform_feedback_object *xfb_obj,
@@ -811,7 +810,7 @@ brw_draw_single_prim(struct gl_context *ctx,
brw->baseinstance = prim->base_instance;
if (prim_id > 0) { /* For i == 0 we just did this before the loop */
brw->ctx.NewDriverState |= BRW_NEW_VERTICES;
- brw_merge_inputs(brw, arrays);
+ brw_merge_inputs(brw);
}
}
@@ -933,14 +932,12 @@ brw_draw_prims(struct gl_context *ctx,
{
unsigned i;
struct brw_context *brw = brw_context(ctx);
- const struct gl_vertex_array *arrays;
int predicate_state = brw->predicate.state;
struct brw_transform_feedback_object *xfb_obj =
(struct brw_transform_feedback_object *) gl_xfb_obj;
/* The initial pushdown of the inputs array into the drivers */
_mesa_set_drawing_arrays(ctx, brw->vb.draw_arrays.inputs);
- arrays = ctx->Array._DrawArrays;
_vbo_update_inputs(ctx, &brw->vb.draw_arrays);
if (!brw_check_conditional_render(brw))
@@ -976,8 +973,7 @@ brw_draw_prims(struct gl_context *ctx,
index_bounds_valid = true;
}
- brw_prepare_drawing(ctx, arrays, ib, index_bounds_valid, min_index,
- max_index);
+ brw_prepare_drawing(ctx, ib, index_bounds_valid, min_index, max_index);
/* Try drawing with the hardware, but don't do anything else if we can't
* manage it. swrast doesn't support our featureset, so we can't fall back
* to it.
@@ -1014,8 +1010,7 @@ brw_draw_prims(struct gl_context *ctx,
brw->predicate.state = BRW_PREDICATE_STATE_USE_BIT;
}
- brw_draw_single_prim(ctx, arrays, &prims[i], i, xfb_obj, stream,
- indirect);
+ brw_draw_single_prim(ctx, &prims[i], i, xfb_obj, stream, indirect);
}
brw_finish_drawing(ctx);
diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c
index b1be269ca91..bc9b2566deb 100644
--- a/src/mesa/drivers/dri/i965/brw_draw_upload.c
+++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c
@@ -23,6 +23,7 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
+#include "main/arrayobj.h"
#include "main/bufferobj.h"
#include "main/context.h"
#include "main/enums.h"
@@ -403,9 +404,8 @@ copy_array_to_vbo_array(struct brw_context *brw,
struct brw_vertex_buffer *buffer,
GLuint dst_stride)
{
- 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 struct gl_vertex_buffer_binding *glbinding = element->glbinding;
+ const struct gl_array_attributes *glattrib = element->glattrib;
const int src_stride = glbinding->Stride;
/* If the source stride is zero, we just want to upload the current
@@ -512,15 +512,15 @@ 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;
+ const struct gl_vertex_buffer_binding *glbinding = input->glbinding;
+ const struct gl_array_attributes *glattrib = input->glattrib;
if (_mesa_is_bufferobj(glbinding->BufferObj)) {
struct intel_buffer_object *intel_buffer =
intel_buffer_object(glbinding->BufferObj);
- const uint32_t offset = glbinding->Offset + glattrib->RelativeOffset;
+ const uint32_t offset = _mesa_draw_binding_offset(glbinding) +
+ _mesa_draw_attributes_relative_offset(glattrib);
/* Start with the worst case */
uint32_t start = 0;
@@ -546,10 +546,11 @@ 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;
- 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;
+ struct brw_vertex_element *other = brw->vb.enabled[k];
+ const struct gl_vertex_buffer_binding *obind = other->glbinding;
+ const struct gl_array_attributes *oattrib = other->glattrib;
+ const uint32_t ooffset = _mesa_draw_binding_offset(obind) +
+ _mesa_draw_attributes_relative_offset(oattrib);
if (glbinding->BufferObj == obind->BufferObj &&
glbinding->Stride == obind->Stride &&
glbinding->InstanceDivisor == obind->InstanceDivisor &&
@@ -658,8 +659,7 @@ 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;
+ const struct gl_array_attributes *glattrib = upload[i]->glattrib;
/* Then, just point upload[i] at upload[0]'s buffer. */
upload[i]->offset = ((const unsigned char *)glattrib->Ptr - ptr);
upload[i]->buffer = j;
@@ -672,9 +672,8 @@ 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];
- 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;
+ const struct gl_vertex_buffer_binding *glbinding = upload[i]->glbinding;
+ const struct gl_array_attributes *glattrib = upload[i]->glattrib;
if (glbinding->InstanceDivisor == 0) {
copy_array_to_vbo_array(brw, upload[i], min_index, max_index,
buffer, glattrib->_ElementSize);
diff --git a/src/mesa/drivers/dri/i965/genX_state_upload.c b/src/mesa/drivers/dri/i965/genX_state_upload.c
index 091e4137aa1..6178bfa3f88 100644
--- a/src/mesa/drivers/dri/i965/genX_state_upload.c
+++ b/src/mesa/drivers/dri/i965/genX_state_upload.c
@@ -560,8 +560,7 @@ 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];
- const struct gl_vertex_array *glarray = input->glarray;
- const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
+ const struct gl_array_attributes *glattrib = input->glattrib;
uint32_t format = brw_get_vertex_surface_type(brw, glattrib);
if (uploads_needed(format, input->is_dual_slot) > 1)
@@ -652,8 +651,7 @@ 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];
- const struct gl_vertex_array *glarray = input->glarray;
- const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
+ const struct gl_array_attributes *glattrib = input->glattrib;
uint32_t format = brw_get_vertex_surface_type(brw, glattrib);
uint32_t comp0 = VFCOMP_STORE_SRC;
uint32_t comp1 = VFCOMP_STORE_SRC;
@@ -695,8 +693,7 @@ 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 struct gl_array_attributes *glattrib = input->glattrib;
const int size = (GEN_GEN < 8 && is_passthru_format(format)) ?
upload_format_size(upload_format) : glattrib->Size;
@@ -818,8 +815,7 @@ genX(emit_vertices)(struct brw_context *brw)
#if GEN_GEN >= 6
if (gen6_edgeflag_input) {
- const struct gl_vertex_array *glarray = gen6_edgeflag_input->glarray;
- const struct gl_array_attributes *glattrib = glarray->VertexAttrib;
+ const struct gl_array_attributes *glattrib = gen6_edgeflag_input->glattrib;
const uint32_t format = brw_get_vertex_surface_type(brw, glattrib);
struct GENX(VERTEX_ELEMENT_STATE) elem_state = {