From 4db9d83a2dd5611776577bacdbdbf483b6bea937 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Mathias=20Fr=C3=B6hlich?= Date: Sun, 25 Mar 2018 19:16:54 +0200 Subject: [PATCH] i965: Push down the gl_vertex_array inputs into i965. MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Let the i965 backend have its own gl_vertex_array array and basically reimplement the way _vbo_draw works. Note that brw_draw_indirect_prims calls brw_draw_prims internally and gets its update to Array._DrawArray by this way. Reviewed-by: Brian Paul Signed-off-by: Mathias Fröhlich --- src/mesa/drivers/dri/i965/brw_context.c | 1 + src/mesa/drivers/dri/i965/brw_context.h | 4 ++++ src/mesa/drivers/dri/i965/brw_draw.c | 23 +++++++++++++++++------ src/mesa/drivers/dri/i965/brw_draw.h | 1 + 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c index 2e961a1ef6e..01a3e16583d 100644 --- a/src/mesa/drivers/dri/i965/brw_context.c +++ b/src/mesa/drivers/dri/i965/brw_context.c @@ -284,6 +284,7 @@ brw_init_driver_functions(struct brw_context *brw, functions->GetString = intel_get_string; functions->UpdateState = intel_update_state; + brw_init_draw_functions(functions); intelInitTextureFuncs(functions); intelInitTextureImageFuncs(functions); intelInitTextureCopyImageFuncs(functions); diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index 177273c3645..f049d086492 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -36,6 +36,7 @@ #include #include "main/macros.h" #include "main/mtypes.h" +#include "vbo/vbo.h" #include "brw_structs.h" #include "brw_pipe_control.h" #include "compiler/brw_compiler.h" @@ -954,6 +955,9 @@ struct brw_context * These bitfields indicate which workarounds are needed. */ uint8_t attrib_wa_flags[VERT_ATTRIB_MAX]; + + /* For the initial pushdown, keep the list of vbo inputs. */ + struct vbo_inputs draw_arrays; } vb; struct { diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 0d1ae8982cb..5f52404bd6e 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -34,6 +34,7 @@ #include "main/macros.h" #include "main/transformfeedback.h" #include "main/framebuffer.h" +#include "main/varray.h" #include "tnl/tnl.h" #include "vbo/vbo.h" #include "swrast/swrast.h" @@ -941,11 +942,16 @@ 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; 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)) return; @@ -1075,14 +1081,19 @@ brw_draw_indirect_prims(struct gl_context *ctx, } void -brw_draw_init(struct brw_context *brw) +brw_init_draw_functions(struct dd_function_table *functions) { - struct gl_context *ctx = &brw->ctx; - /* Register our drawing function: */ - vbo_set_draw_func(ctx, brw_draw_prims); - vbo_set_indirect_draw_func(ctx, brw_draw_indirect_prims); + functions->Draw = brw_draw_prims; + functions->DrawIndirect = brw_draw_indirect_prims; +} + +void +brw_draw_init(struct brw_context *brw) +{ + /* Keep our list of gl_vertex_array inputs */ + _vbo_init_inputs(&brw->vb.draw_arrays); for (int i = 0; i < VERT_ATTRIB_MAX; i++) brw->vb.inputs[i].buffer = -1; diff --git a/src/mesa/drivers/dri/i965/brw_draw.h b/src/mesa/drivers/dri/i965/brw_draw.h index c3a972c2765..c74a2536aa1 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.h +++ b/src/mesa/drivers/dri/i965/brw_draw.h @@ -55,6 +55,7 @@ void brw_draw_prims(struct gl_context *ctx, unsigned stream, struct gl_buffer_object *indirect ); +void brw_init_draw_functions(struct dd_function_table *functions); void brw_draw_init( struct brw_context *brw ); void brw_draw_destroy( struct brw_context *brw ); -- 2.30.2