i965: Introduce brw_prepare_drawing.

In order to add our ARB_indirect_parameters implementation we
need to refactor brw_try_draw_prims so that it operates on a
per primitive basis and move the loop into brw_draw_prims.
This commit introduces the brw_prepare_drawing function where
we move the code that executes once before the loop.

Signed-off-by: Plamena Manolova <plamena.manolova@intel.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Plamena Manolova 2017-10-02 23:58:24 +03:00 committed by Kenneth Graunke
parent 765e1fa372
commit c63c8f5135
1 changed files with 27 additions and 19 deletions

View File

@ -593,26 +593,15 @@ brw_postdraw_reconcile_align_wa_slices(struct brw_context *brw)
}
}
/* May fail if out of video memory for texture or vbo upload, or on
* fallback conditions.
*/
static void
brw_try_draw_prims(struct gl_context *ctx,
const struct gl_vertex_array *arrays[],
const struct _mesa_prim *prims,
GLuint nr_prims,
const struct _mesa_index_buffer *ib,
bool index_bounds_valid,
GLuint min_index,
GLuint max_index,
struct brw_transform_feedback_object *xfb_obj,
unsigned stream,
struct gl_buffer_object *indirect)
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,
GLuint max_index)
{
struct brw_context *brw = brw_context(ctx);
const struct gen_device_info *devinfo = &brw->screen->devinfo;
GLuint i;
bool fail_next = false;
if (ctx->NewState)
_mesa_update_state(ctx);
@ -667,6 +656,24 @@ brw_try_draw_prims(struct gl_context *ctx,
brw->vb.min_index = min_index;
brw->vb.max_index = max_index;
brw->ctx.NewDriverState |= BRW_NEW_VERTICES;
}
/* May fail if out of video memory for texture or vbo upload, or on
* fallback conditions.
*/
static void
brw_try_draw_prims(struct gl_context *ctx,
const struct gl_vertex_array *arrays[],
const struct _mesa_prim *prims,
GLuint nr_prims,
struct brw_transform_feedback_object *xfb_obj,
unsigned stream,
struct gl_buffer_object *indirect)
{
struct brw_context *brw = brw_context(ctx);
const struct gen_device_info *devinfo = &brw->screen->devinfo;
GLuint i;
bool fail_next = false;
for (i = 0; i < nr_prims; i++) {
/* Flag BRW_NEW_DRAW_CALL on every draw. This allows us to have
@ -849,12 +856,13 @@ brw_draw_prims(struct gl_context *ctx,
index_bounds_valid = true;
}
brw_prepare_drawing(ctx, arrays, 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_try_draw_prims(ctx, arrays, prims, nr_prims, ib, index_bounds_valid,
min_index, max_index, xfb_obj, stream, indirect);
brw_try_draw_prims(ctx, arrays, prims, nr_prims, xfb_obj, stream, indirect);
}
void