[Mesa-dev] [PATCH 02/13] i965: Only call brw_upload_tcs/tes_prog when using tessellation.
eocallaghan at alterapraxis.com
eocallaghan at alterapraxis.com
Tue Dec 22 07:21:49 PST 2015
On 2015-12-22 21:20, Kenneth Graunke wrote:
> If there's no evaluation shader, tessellation is disabled. The upload
> functions would just bail. Instead, don't bother calling them.
>
> This will simplify the optional-TCS case a bit, as brw_upload_tcs can
> assume that we're doing tessellation.
>
> Signed-off-by: Kenneth Graunke <kenneth at whitecape.org>
> ---
> src/mesa/drivers/dri/i965/brw_state_upload.c | 11 +++++++++--
> src/mesa/drivers/dri/i965/brw_tcs.c | 17 ++++-------------
> src/mesa/drivers/dri/i965/brw_tes.c | 9 ---------
> 3 files changed, 13 insertions(+), 24 deletions(-)
>
> diff --git a/src/mesa/drivers/dri/i965/brw_state_upload.c
> b/src/mesa/drivers/dri/i965/brw_state_upload.c
> index 56962d5..af9fb5b 100644
> --- a/src/mesa/drivers/dri/i965/brw_state_upload.c
> +++ b/src/mesa/drivers/dri/i965/brw_state_upload.c
> @@ -678,8 +678,15 @@ brw_upload_programs(struct brw_context *brw,
> {
> if (pipeline == BRW_RENDER_PIPELINE) {
> brw_upload_vs_prog(brw);
> - brw_upload_tcs_prog(brw);
> - brw_upload_tes_prog(brw);
> + if (brw->tess_eval_program) {
> + brw_upload_tcs_prog(brw);
> + brw_upload_tes_prog(brw);
> + } else {
> + brw->tcs.prog_data = NULL;
> + brw->tcs.base.prog_data = NULL;
> + brw->tes.prog_data = NULL;
> + brw->tes.base.prog_data = NULL;
> + }
>
> if (brw->gen < 6)
> brw_upload_ff_gs_prog(brw);
> diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c
> b/src/mesa/drivers/dri/i965/brw_tcs.c
> index b5eb4cd..037a2da 100644
> --- a/src/mesa/drivers/dri/i965/brw_tcs.c
> +++ b/src/mesa/drivers/dri/i965/brw_tcs.c
> @@ -187,6 +187,10 @@ brw_upload_tcs_prog(struct brw_context *brw)
> /* BRW_NEW_TESS_CTRL_PROGRAM */
> struct brw_tess_ctrl_program *tcp =
> (struct brw_tess_ctrl_program *) brw->tess_ctrl_program;
> + /* BRW_NEW_TESS_EVAL_PROGRAM */
> + struct brw_tess_eval_program *tep =
> + (struct brw_tess_eval_program *) brw->tess_eval_program;
> + assert(tcp && tep);
>
> if (!brw_state_dirty(brw,
> _NEW_TEXTURE,
> @@ -195,15 +199,6 @@ brw_upload_tcs_prog(struct brw_context *brw)
> BRW_NEW_TESS_EVAL_PROGRAM))
> return;
>
> - if (tcp == NULL) {
> - /* Other state atoms had better not try to access prog_data,
> since
> - * there's no HS program.
> - */
> - brw->tcs.prog_data = NULL;
> - brw->tcs.base.prog_data = NULL;
> - return;
> - }
> -
> struct gl_program *prog = &tcp->program.Base;
>
> memset(&key, 0, sizeof(key));
> @@ -216,13 +211,9 @@ brw_upload_tcs_prog(struct brw_context *brw)
> brw_populate_sampler_prog_key_data(ctx, prog,
> stage_state->sampler_count,
> &key.tex);
>
> - /* BRW_NEW_TESS_EVAL_PROGRAM */
> /* We need to specialize our code generation for tessellation
> levels
> * based on the domain the DS is expecting to tessellate.
> */
> - struct brw_tess_eval_program *tep =
> - (struct brw_tess_eval_program *) brw->tess_eval_program;
> - assert(tep);
> key.tes_primitive_mode = tep->program.PrimitiveMode;
Does this compile? You've killed off *tep yet we still dereference it.
>
> if (!brw_search_cache(&brw->cache, BRW_CACHE_TCS_PROG,
> diff --git a/src/mesa/drivers/dri/i965/brw_tes.c
> b/src/mesa/drivers/dri/i965/brw_tes.c
> index 3c12706..4b2bf8c 100644
> --- a/src/mesa/drivers/dri/i965/brw_tes.c
> +++ b/src/mesa/drivers/dri/i965/brw_tes.c
> @@ -241,15 +241,6 @@ brw_upload_tes_prog(struct brw_context *brw)
> BRW_NEW_TESS_EVAL_PROGRAM))
> return;
>
> - if (tep == NULL) {
> - /* Other state atoms had better not try to access prog_data,
> since
> - * there's no TES program.
> - */
> - brw->tes.prog_data = NULL;
> - brw->tes.base.prog_data = NULL;
> - return;
> - }
> -
> struct gl_program *prog = &tep->program.Base;
>
> memset(&key, 0, sizeof(key));
More information about the mesa-dev
mailing list