For now store binding and attrib in brw_vertex_element.
The i965 driver still provides lots of opportunity to make use
of the unique binding information in the VAO which is currently not
taken from the VAO.
Reviewed-by: Brian Paul <brianp@vmware.com>
Signed-off-by: Mathias Fröhlich <Mathias.Froehlich@web.de>
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;
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;
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) {
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) {
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,
/* 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;
*/
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,
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);
}
}
{
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))
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.
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);
* 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"
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
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;
*/
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 &&
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;
/* 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);
*/
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)
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;
* 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;
#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 = {