[Mesa-dev] [PATCH 4/7] i965: Add support for gl_BaseVertexARB and gl_BaseInstanceARB
We already have gl_BaseVertexARB in the .x component of the SGVS vec4 and plug gl_BaseInstanceARB into the last free component (.y). --- src/mesa/drivers/dri/i965/brw_compiler.h | 2 ++ src/mesa/drivers/dri/i965/brw_context.h | 9 -- src/mesa/drivers/dri/i965/brw_draw.c | 12 ++-- src/mesa/drivers/dri/i965/brw_draw_upload.c | 35 ++- src/mesa/drivers/dri/i965/brw_fs.cpp | 3 +- src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 10 ++- src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 +++- src/mesa/drivers/dri/i965/brw_vec4.cpp| 12 ++-- src/mesa/drivers/dri/i965/brw_vec4_nir.cpp| 10 ++- src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 6 +++- src/mesa/drivers/dri/i965/gen8_draw_upload.c | 35 ++- 11 files changed, 102 insertions(+), 38 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h b/src/mesa/drivers/dri/i965/brw_compiler.h index 218d9c7..58ee966 100644 --- a/src/mesa/drivers/dri/i965/brw_compiler.h +++ b/src/mesa/drivers/dri/i965/brw_compiler.h @@ -547,6 +547,8 @@ struct brw_vs_prog_data { bool uses_vertexid; bool uses_instanceid; + bool uses_basevertex; + bool uses_baseinstance; }; struct brw_tcs_prog_data diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index a845541..1378402 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -905,8 +905,13 @@ struct brw_context uint32_t pma_stall_bits; struct { - /** The value of gl_BaseVertex for the current _mesa_prim. */ - int gl_basevertex; + struct { + /** The value of gl_BaseVertex for the current _mesa_prim. */ + int gl_basevertex; + + /** The value of gl_BaseInstance for the current _mesa_prim. */ + int gl_baseinstance; + } params; /** * Buffer and offset used for GL_ARB_shader_draw_parameters diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 8398471..298ac06 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -491,9 +491,9 @@ brw_try_draw_prims(struct gl_context *ctx, } } - brw->draw.gl_basevertex = + brw->draw.params.gl_basevertex = prims[i].indexed ? prims[i].basevertex : prims[i].start; - + brw->draw.params.gl_baseinstance = prims[i].base_instance; drm_intel_bo_unreference(brw->draw.draw_params_bo); if (prims[i].is_indirect) { @@ -511,6 +511,14 @@ brw_try_draw_prims(struct gl_context *ctx, brw->draw.draw_params_offset = 0; } + /* gl_DrawID always needs its own vertex buffer since it's not part of + * the indirect parameter buffer. */ + if (brw->vs.prog_data->uses_drawid) { + brw->draw.gl_drawid = prims[i].drawid; + drm_intel_bo_unreference(brw->draw.draw_id_bo); + brw->ctx.NewDriverState |= BRW_NEW_VERTICES; + } + if (brw->gen < 6) brw_set_prim(brw, &prims[i]); else diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c b/src/mesa/drivers/dri/i965/brw_draw_upload.c index ea0f6f2..ccf963c 100644 --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c @@ -592,8 +592,10 @@ void brw_prepare_shader_draw_parameters(struct brw_context *brw) { /* For non-indirect draws, upload gl_BaseVertex. */ - if (brw->vs.prog_data->uses_vertexid && brw->draw.draw_params_bo == NULL) { - intel_upload_data(brw, &brw->draw.gl_basevertex, 4, 4, + if ((brw->vs.prog_data->uses_basevertex || +brw->vs.prog_data->uses_baseinstance) && + brw->draw.draw_params_bo == NULL) { + intel_upload_data(brw, &brw->draw.params, sizeof(brw->draw.params), 4, &brw->draw.draw_params_bo, &brw->draw.draw_params_offset); } @@ -658,7 +660,8 @@ brw_emit_vertices(struct brw_context *brw) brw_emit_query_begin(brw); unsigned nr_elements = brw->vb.nr_enabled; - if (brw->vs.prog_data->uses_vertexid || brw->vs.prog_data->uses_instanceid) + if (brw->vs.prog_data->uses_vertexid || brw->vs.prog_data->uses_instanceid || + brw->vs.prog_data->uses_basevertex || brw->vs.prog_data->uses_baseinstance) ++nr_elements; /* If the VS doesn't read any inputs (calculating vertex position from @@ -693,8 +696,10 @@ brw_emit_vertices(struct brw_context *brw) /* Now emit VB and VEP state packets. */ - unsigned nr_buffers = - brw->vb.nr_buffers + brw->vs.prog_data->uses_vertexid; + const bool uses_draw_params = + brw->vs.prog_data->uses_basevertex || + brw->vs.prog_data->uses_baseinstance; + const unsigned nr_buffers = brw->vb.nr_buffers + uses_draw_params; if (nr_buffers) { if (brw->gen >= 6) { @@ -713,7 +718,7 @@ brw_emit_vertic
Re: [Mesa-dev] [PATCH 4/7] i965: Add support for gl_BaseVertexARB and gl_BaseInstanceARB
On Tue, Dec 15, 2015 at 12:28 AM, Kristian Høgsberg Kristensen wrote: > We already have gl_BaseVertexARB in the .x component of the SGVS vec4 > and plug gl_BaseInstanceARB into the last free component (.y). > --- > src/mesa/drivers/dri/i965/brw_compiler.h | 2 ++ > src/mesa/drivers/dri/i965/brw_context.h | 9 -- > src/mesa/drivers/dri/i965/brw_draw.c | 12 ++-- > src/mesa/drivers/dri/i965/brw_draw_upload.c | 35 > ++- > src/mesa/drivers/dri/i965/brw_fs.cpp | 3 +- > src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 10 ++- > src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 +++- > src/mesa/drivers/dri/i965/brw_vec4.cpp| 12 ++-- > src/mesa/drivers/dri/i965/brw_vec4_nir.cpp| 10 ++- > src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 6 +++- > src/mesa/drivers/dri/i965/gen8_draw_upload.c | 35 > ++- > 11 files changed, 102 insertions(+), 38 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h > b/src/mesa/drivers/dri/i965/brw_compiler.h > index 218d9c7..58ee966 100644 > --- a/src/mesa/drivers/dri/i965/brw_compiler.h > +++ b/src/mesa/drivers/dri/i965/brw_compiler.h > @@ -547,6 +547,8 @@ struct brw_vs_prog_data { > > bool uses_vertexid; > bool uses_instanceid; > + bool uses_basevertex; > + bool uses_baseinstance; Missed bool uses_drawid ? > }; > > struct brw_tcs_prog_data > diff --git a/src/mesa/drivers/dri/i965/brw_context.h > b/src/mesa/drivers/dri/i965/brw_context.h > index a845541..1378402 100644 > --- a/src/mesa/drivers/dri/i965/brw_context.h > +++ b/src/mesa/drivers/dri/i965/brw_context.h > @@ -905,8 +905,13 @@ struct brw_context > uint32_t pma_stall_bits; > > struct { > - /** The value of gl_BaseVertex for the current _mesa_prim. */ > - int gl_basevertex; > + struct { > + /** The value of gl_BaseVertex for the current _mesa_prim. */ > + int gl_basevertex; > + > + /** The value of gl_BaseInstance for the current _mesa_prim. */ > + int gl_baseinstance; > + } params; Missed gl_drawid and gl_drawid_bo ? > >/** > * Buffer and offset used for GL_ARB_shader_draw_parameters > diff --git a/src/mesa/drivers/dri/i965/brw_draw.c > b/src/mesa/drivers/dri/i965/brw_draw.c > index 8398471..298ac06 100644 > --- a/src/mesa/drivers/dri/i965/brw_draw.c > +++ b/src/mesa/drivers/dri/i965/brw_draw.c > @@ -491,9 +491,9 @@ brw_try_draw_prims(struct gl_context *ctx, > } >} > > - brw->draw.gl_basevertex = > + brw->draw.params.gl_basevertex = > prims[i].indexed ? prims[i].basevertex : prims[i].start; > - > + brw->draw.params.gl_baseinstance = prims[i].base_instance; >drm_intel_bo_unreference(brw->draw.draw_params_bo); > >if (prims[i].is_indirect) { > @@ -511,6 +511,14 @@ brw_try_draw_prims(struct gl_context *ctx, > brw->draw.draw_params_offset = 0; >} > > + /* gl_DrawID always needs its own vertex buffer since it's not part of > + * the indirect parameter buffer. */ > + if (brw->vs.prog_data->uses_drawid) { > + brw->draw.gl_drawid = prims[i].drawid; brw->draw.gl_drawid = prims[i].draw_id; > + drm_intel_bo_unreference(brw->draw.draw_id_bo); > + brw->ctx.NewDriverState |= BRW_NEW_VERTICES; > + } > + >if (brw->gen < 6) > brw_set_prim(brw, &prims[i]); >else > diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c > b/src/mesa/drivers/dri/i965/brw_draw_upload.c > index ea0f6f2..ccf963c 100644 > --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c > +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c > @@ -592,8 +592,10 @@ void > brw_prepare_shader_draw_parameters(struct brw_context *brw) > { > /* For non-indirect draws, upload gl_BaseVertex. */ > - if (brw->vs.prog_data->uses_vertexid && brw->draw.draw_params_bo == NULL) > { > - intel_upload_data(brw, &brw->draw.gl_basevertex, 4, 4, > + if ((brw->vs.prog_data->uses_basevertex || > +brw->vs.prog_data->uses_baseinstance) && > + brw->draw.draw_params_bo == NULL) { > + intel_upload_data(brw, &brw->draw.params, sizeof(brw->draw.params), 4, > &brw->draw.draw_params_bo, > &brw->draw.draw_params_offset); > } > @@ -658,7 +660,8 @@ brw_emit_vertices(struct brw_context *brw) > brw_emit_query_begin(brw); > > unsigned nr_elements = brw->vb.nr_enabled; > - if (brw->vs.prog_data->uses_vertexid || > brw->vs.prog_data->uses_instanceid) > + if (brw->vs.prog_data->uses_vertexid || > brw->vs.prog_data->uses_instanceid || > + brw->vs.prog_data->uses_basevertex || > brw->vs.prog_data->uses_baseinstance) >++nr_elements; > > /* If the VS doesn't read any inputs (calculating vertex position from > @@ -693,8 +696,10 @@ brw_emit_vertices(struct brw_context *brw) > /* Now emit VB and VEP
Re: [Mesa-dev] [PATCH 4/7] i965: Add support for gl_BaseVertexARB and gl_BaseInstanceARB
On 12/15/2015 11:48 AM, Anuj Phogat wrote: > On Tue, Dec 15, 2015 at 12:28 AM, Kristian Høgsberg Kristensen > wrote: >> We already have gl_BaseVertexARB in the .x component of the SGVS vec4 >> and plug gl_BaseInstanceARB into the last free component (.y). >> --- >> src/mesa/drivers/dri/i965/brw_compiler.h | 2 ++ >> src/mesa/drivers/dri/i965/brw_context.h | 9 -- >> src/mesa/drivers/dri/i965/brw_draw.c | 12 ++-- >> src/mesa/drivers/dri/i965/brw_draw_upload.c | 35 >> ++- >> src/mesa/drivers/dri/i965/brw_fs.cpp | 3 +- >> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 10 ++- >> src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 +++- >> src/mesa/drivers/dri/i965/brw_vec4.cpp| 12 ++-- >> src/mesa/drivers/dri/i965/brw_vec4_nir.cpp| 10 ++- >> src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 6 +++- >> src/mesa/drivers/dri/i965/gen8_draw_upload.c | 35 >> ++- >> 11 files changed, 102 insertions(+), 38 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h >> b/src/mesa/drivers/dri/i965/brw_compiler.h >> index 218d9c7..58ee966 100644 >> --- a/src/mesa/drivers/dri/i965/brw_compiler.h >> +++ b/src/mesa/drivers/dri/i965/brw_compiler.h >> @@ -547,6 +547,8 @@ struct brw_vs_prog_data { >> >> bool uses_vertexid; >> bool uses_instanceid; >> + bool uses_basevertex; >> + bool uses_baseinstance; > Missed bool uses_drawid ? It looks like there may be some rebase or patch splitting issues. These are added in the next patch, but they are already used in this patch. I think it will compile after patch 5, but I don't think it will compile after patch 4. >> }; >> >> struct brw_tcs_prog_data >> diff --git a/src/mesa/drivers/dri/i965/brw_context.h >> b/src/mesa/drivers/dri/i965/brw_context.h >> index a845541..1378402 100644 >> --- a/src/mesa/drivers/dri/i965/brw_context.h >> +++ b/src/mesa/drivers/dri/i965/brw_context.h >> @@ -905,8 +905,13 @@ struct brw_context >> uint32_t pma_stall_bits; >> >> struct { >> - /** The value of gl_BaseVertex for the current _mesa_prim. */ >> - int gl_basevertex; >> + struct { >> + /** The value of gl_BaseVertex for the current _mesa_prim. */ >> + int gl_basevertex; >> + >> + /** The value of gl_BaseInstance for the current _mesa_prim. */ >> + int gl_baseinstance; >> + } params; > Missed gl_drawid and gl_drawid_bo ? >> >>/** >> * Buffer and offset used for GL_ARB_shader_draw_parameters >> diff --git a/src/mesa/drivers/dri/i965/brw_draw.c >> b/src/mesa/drivers/dri/i965/brw_draw.c >> index 8398471..298ac06 100644 >> --- a/src/mesa/drivers/dri/i965/brw_draw.c >> +++ b/src/mesa/drivers/dri/i965/brw_draw.c >> @@ -491,9 +491,9 @@ brw_try_draw_prims(struct gl_context *ctx, >> } >>} >> >> - brw->draw.gl_basevertex = >> + brw->draw.params.gl_basevertex = >> prims[i].indexed ? prims[i].basevertex : prims[i].start; >> - >> + brw->draw.params.gl_baseinstance = prims[i].base_instance; >>drm_intel_bo_unreference(brw->draw.draw_params_bo); >> >>if (prims[i].is_indirect) { >> @@ -511,6 +511,14 @@ brw_try_draw_prims(struct gl_context *ctx, >> brw->draw.draw_params_offset = 0; >>} >> >> + /* gl_DrawID always needs its own vertex buffer since it's not part of >> + * the indirect parameter buffer. */ >> + if (brw->vs.prog_data->uses_drawid) { >> + brw->draw.gl_drawid = prims[i].drawid; > brw->draw.gl_drawid = prims[i].draw_id; >> + drm_intel_bo_unreference(brw->draw.draw_id_bo); >> + brw->ctx.NewDriverState |= BRW_NEW_VERTICES; >> + } >> + >>if (brw->gen < 6) >> brw_set_prim(brw, &prims[i]); >>else >> diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c >> b/src/mesa/drivers/dri/i965/brw_draw_upload.c >> index ea0f6f2..ccf963c 100644 >> --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c >> +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c >> @@ -592,8 +592,10 @@ void >> brw_prepare_shader_draw_parameters(struct brw_context *brw) >> { >> /* For non-indirect draws, upload gl_BaseVertex. */ >> - if (brw->vs.prog_data->uses_vertexid && brw->draw.draw_params_bo == >> NULL) { >> - intel_upload_data(brw, &brw->draw.gl_basevertex, 4, 4, >> + if ((brw->vs.prog_data->uses_basevertex || >> +brw->vs.prog_data->uses_baseinstance) && >> + brw->draw.draw_params_bo == NULL) { >> + intel_upload_data(brw, &brw->draw.params, sizeof(brw->draw.params), 4, >> &brw->draw.draw_params_bo, >> &brw->draw.draw_params_offset); >> } >> @@ -658,7 +660,8 @@ brw_emit_vertices(struct brw_context *brw) >> brw_emit_query_begin(brw); >> >> unsigned nr_elements = brw->vb.nr_enabled; >> - if (brw->vs.prog_data->uses_vertexid || >> brw->vs.prog
Re: [Mesa-dev] [PATCH 4/7] i965: Add support for gl_BaseVertexARB and gl_BaseInstanceARB
This patch is really doing two different things. It changes the existing SYSTEM_VALUE_BASE_VERTEX to be independent from SYSTEM_VALUE_VERTEX_ID_ZERO. It also adds SYSTEM_VALUE_BASE_INSTANCE support. I was going to let that go, but because the two things happened in one patch, I overlooked the extra gl_DrawID related cruft that should have been in the next patch. Thankfully Anuj caught it. On 12/15/2015 12:28 AM, Kristian Høgsberg Kristensen wrote: > We already have gl_BaseVertexARB in the .x component of the SGVS vec4 > and plug gl_BaseInstanceARB into the last free component (.y). > --- > src/mesa/drivers/dri/i965/brw_compiler.h | 2 ++ > src/mesa/drivers/dri/i965/brw_context.h | 9 -- > src/mesa/drivers/dri/i965/brw_draw.c | 12 ++-- > src/mesa/drivers/dri/i965/brw_draw_upload.c | 35 > ++- > src/mesa/drivers/dri/i965/brw_fs.cpp | 3 +- > src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 10 ++- > src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 +++- > src/mesa/drivers/dri/i965/brw_vec4.cpp| 12 ++-- > src/mesa/drivers/dri/i965/brw_vec4_nir.cpp| 10 ++- > src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 6 +++- > src/mesa/drivers/dri/i965/gen8_draw_upload.c | 35 > ++- > 11 files changed, 102 insertions(+), 38 deletions(-) > > diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h > b/src/mesa/drivers/dri/i965/brw_compiler.h > index 218d9c7..58ee966 100644 > --- a/src/mesa/drivers/dri/i965/brw_compiler.h > +++ b/src/mesa/drivers/dri/i965/brw_compiler.h > @@ -547,6 +547,8 @@ struct brw_vs_prog_data { > > bool uses_vertexid; > bool uses_instanceid; > + bool uses_basevertex; > + bool uses_baseinstance; > }; > > struct brw_tcs_prog_data > diff --git a/src/mesa/drivers/dri/i965/brw_context.h > b/src/mesa/drivers/dri/i965/brw_context.h > index a845541..1378402 100644 > --- a/src/mesa/drivers/dri/i965/brw_context.h > +++ b/src/mesa/drivers/dri/i965/brw_context.h > @@ -905,8 +905,13 @@ struct brw_context > uint32_t pma_stall_bits; > > struct { > - /** The value of gl_BaseVertex for the current _mesa_prim. */ > - int gl_basevertex; > + struct { > + /** The value of gl_BaseVertex for the current _mesa_prim. */ > + int gl_basevertex; > + > + /** The value of gl_BaseInstance for the current _mesa_prim. */ > + int gl_baseinstance; > + } params; > >/** > * Buffer and offset used for GL_ARB_shader_draw_parameters > diff --git a/src/mesa/drivers/dri/i965/brw_draw.c > b/src/mesa/drivers/dri/i965/brw_draw.c > index 8398471..298ac06 100644 > --- a/src/mesa/drivers/dri/i965/brw_draw.c > +++ b/src/mesa/drivers/dri/i965/brw_draw.c > @@ -491,9 +491,9 @@ brw_try_draw_prims(struct gl_context *ctx, > } >} > > - brw->draw.gl_basevertex = > + brw->draw.params.gl_basevertex = > prims[i].indexed ? prims[i].basevertex : prims[i].start; > - > + brw->draw.params.gl_baseinstance = prims[i].base_instance; >drm_intel_bo_unreference(brw->draw.draw_params_bo); > >if (prims[i].is_indirect) { > @@ -511,6 +511,14 @@ brw_try_draw_prims(struct gl_context *ctx, > brw->draw.draw_params_offset = 0; >} > > + /* gl_DrawID always needs its own vertex buffer since it's not part of > + * the indirect parameter buffer. */ > + if (brw->vs.prog_data->uses_drawid) { > + brw->draw.gl_drawid = prims[i].drawid; > + drm_intel_bo_unreference(brw->draw.draw_id_bo); > + brw->ctx.NewDriverState |= BRW_NEW_VERTICES; > + } > + >if (brw->gen < 6) >brw_set_prim(brw, &prims[i]); >else > diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c > b/src/mesa/drivers/dri/i965/brw_draw_upload.c > index ea0f6f2..ccf963c 100644 > --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c > +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c > @@ -592,8 +592,10 @@ void > brw_prepare_shader_draw_parameters(struct brw_context *brw) > { > /* For non-indirect draws, upload gl_BaseVertex. */ > - if (brw->vs.prog_data->uses_vertexid && brw->draw.draw_params_bo == NULL) > { > - intel_upload_data(brw, &brw->draw.gl_basevertex, 4, 4, > + if ((brw->vs.prog_data->uses_basevertex || > +brw->vs.prog_data->uses_baseinstance) && > + brw->draw.draw_params_bo == NULL) { > + intel_upload_data(brw, &brw->draw.params, sizeof(brw->draw.params), 4, > &brw->draw.draw_params_bo, > &brw->draw.draw_params_offset); > } > @@ -658,7 +660,8 @@ brw_emit_vertices(struct brw_context *brw) > brw_emit_query_begin(brw); > > unsigned nr_elements = brw->vb.nr_enabled; > - if (brw->vs.prog_data->uses_vertexid || > brw->vs.prog_data->uses_instanceid) > + if (brw->vs.prog_data->uses_vertexid || > brw->vs.prog_data->uses_ins
Re: [Mesa-dev] [PATCH 4/7] i965: Add support for gl_BaseVertexARB and gl_BaseInstanceARB
Ian Romanick writes: > This patch is really doing two different things. It changes the > existing SYSTEM_VALUE_BASE_VERTEX to be independent from > SYSTEM_VALUE_VERTEX_ID_ZERO. It also adds SYSTEM_VALUE_BASE_INSTANCE > support. > > I was going to let that go, but because the two things happened in one > patch, I overlooked the extra gl_DrawID related cruft that should have > been in the next patch. Thankfully Anuj caught it. Yeah, I accidentally left a draw-id hunk in this patch when rebasing. All draw-id changes should be in the next patch. I'll send out a v2 with the rebasing fixed. Kristian > On 12/15/2015 12:28 AM, Kristian Høgsberg Kristensen wrote: >> We already have gl_BaseVertexARB in the .x component of the SGVS vec4 >> and plug gl_BaseInstanceARB into the last free component (.y). >> --- >> src/mesa/drivers/dri/i965/brw_compiler.h | 2 ++ >> src/mesa/drivers/dri/i965/brw_context.h | 9 -- >> src/mesa/drivers/dri/i965/brw_draw.c | 12 ++-- >> src/mesa/drivers/dri/i965/brw_draw_upload.c | 35 >> ++- >> src/mesa/drivers/dri/i965/brw_fs.cpp | 3 +- >> src/mesa/drivers/dri/i965/brw_fs_nir.cpp | 10 ++- >> src/mesa/drivers/dri/i965/brw_fs_visitor.cpp | 6 +++- >> src/mesa/drivers/dri/i965/brw_vec4.cpp| 12 ++-- >> src/mesa/drivers/dri/i965/brw_vec4_nir.cpp| 10 ++- >> src/mesa/drivers/dri/i965/brw_vec4_vs_visitor.cpp | 6 +++- >> src/mesa/drivers/dri/i965/gen8_draw_upload.c | 35 >> ++- >> 11 files changed, 102 insertions(+), 38 deletions(-) >> >> diff --git a/src/mesa/drivers/dri/i965/brw_compiler.h >> b/src/mesa/drivers/dri/i965/brw_compiler.h >> index 218d9c7..58ee966 100644 >> --- a/src/mesa/drivers/dri/i965/brw_compiler.h >> +++ b/src/mesa/drivers/dri/i965/brw_compiler.h >> @@ -547,6 +547,8 @@ struct brw_vs_prog_data { >> >> bool uses_vertexid; >> bool uses_instanceid; >> + bool uses_basevertex; >> + bool uses_baseinstance; >> }; >> >> struct brw_tcs_prog_data >> diff --git a/src/mesa/drivers/dri/i965/brw_context.h >> b/src/mesa/drivers/dri/i965/brw_context.h >> index a845541..1378402 100644 >> --- a/src/mesa/drivers/dri/i965/brw_context.h >> +++ b/src/mesa/drivers/dri/i965/brw_context.h >> @@ -905,8 +905,13 @@ struct brw_context >> uint32_t pma_stall_bits; >> >> struct { >> - /** The value of gl_BaseVertex for the current _mesa_prim. */ >> - int gl_basevertex; >> + struct { >> + /** The value of gl_BaseVertex for the current _mesa_prim. */ >> + int gl_basevertex; >> + >> + /** The value of gl_BaseInstance for the current _mesa_prim. */ >> + int gl_baseinstance; >> + } params; >> >>/** >> * Buffer and offset used for GL_ARB_shader_draw_parameters >> diff --git a/src/mesa/drivers/dri/i965/brw_draw.c >> b/src/mesa/drivers/dri/i965/brw_draw.c >> index 8398471..298ac06 100644 >> --- a/src/mesa/drivers/dri/i965/brw_draw.c >> +++ b/src/mesa/drivers/dri/i965/brw_draw.c >> @@ -491,9 +491,9 @@ brw_try_draw_prims(struct gl_context *ctx, >> } >>} >> >> - brw->draw.gl_basevertex = >> + brw->draw.params.gl_basevertex = >> prims[i].indexed ? prims[i].basevertex : prims[i].start; >> - >> + brw->draw.params.gl_baseinstance = prims[i].base_instance; >>drm_intel_bo_unreference(brw->draw.draw_params_bo); >> >>if (prims[i].is_indirect) { >> @@ -511,6 +511,14 @@ brw_try_draw_prims(struct gl_context *ctx, >> brw->draw.draw_params_offset = 0; >>} >> >> + /* gl_DrawID always needs its own vertex buffer since it's not part of >> + * the indirect parameter buffer. */ >> + if (brw->vs.prog_data->uses_drawid) { >> + brw->draw.gl_drawid = prims[i].drawid; >> + drm_intel_bo_unreference(brw->draw.draw_id_bo); >> + brw->ctx.NewDriverState |= BRW_NEW_VERTICES; >> + } >> + >>if (brw->gen < 6) >> brw_set_prim(brw, &prims[i]); >>else >> diff --git a/src/mesa/drivers/dri/i965/brw_draw_upload.c >> b/src/mesa/drivers/dri/i965/brw_draw_upload.c >> index ea0f6f2..ccf963c 100644 >> --- a/src/mesa/drivers/dri/i965/brw_draw_upload.c >> +++ b/src/mesa/drivers/dri/i965/brw_draw_upload.c >> @@ -592,8 +592,10 @@ void >> brw_prepare_shader_draw_parameters(struct brw_context *brw) >> { >> /* For non-indirect draws, upload gl_BaseVertex. */ >> - if (brw->vs.prog_data->uses_vertexid && brw->draw.draw_params_bo == >> NULL) { >> - intel_upload_data(brw, &brw->draw.gl_basevertex, 4, 4, >> + if ((brw->vs.prog_data->uses_basevertex || >> +brw->vs.prog_data->uses_baseinstance) && >> + brw->draw.draw_params_bo == NULL) { >> + intel_upload_data(brw, &brw->draw.params, sizeof(brw->draw.params), 4, >> &brw->draw.draw_params_bo, >> &brw->draw.draw_params_offset); >>