From: Timothy Arceri Date: Wed, 19 Oct 2016 00:13:52 +0000 (+1100) Subject: i965/mesa/st: eliminate gl_tess_ctrl_program X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=64d9773cfebded42691a70e3b233cadf896e53ba;p=mesa.git i965/mesa/st: eliminate gl_tess_ctrl_program We now get all the tcs metadata from shader_info. Reviewed-by: Jason Ekstrand --- diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index c92bb9f8431..9b7e1846680 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -337,7 +337,7 @@ struct brw_vertex_program { /** Subclass of Mesa tessellation control program */ struct brw_tess_ctrl_program { - struct gl_tess_ctrl_program program; + struct gl_program program; unsigned id; /**< serial no. to identify tess ctrl progs, never re-used */ }; @@ -1008,7 +1008,7 @@ struct brw_context */ const struct gl_vertex_program *vertex_program; const struct gl_geometry_program *geometry_program; - const struct gl_tess_ctrl_program *tess_ctrl_program; + const struct gl_program *tess_ctrl_program; const struct gl_tess_eval_program *tess_eval_program; const struct gl_fragment_program *fragment_program; const struct gl_compute_program *compute_program; @@ -1730,7 +1730,7 @@ brw_vertex_program_const(const struct gl_vertex_program *p) } static inline struct brw_tess_ctrl_program * -brw_tess_ctrl_program(struct gl_tess_ctrl_program *p) +brw_tess_ctrl_program(struct gl_program *p) { return (struct brw_tess_ctrl_program *) p; } diff --git a/src/mesa/drivers/dri/i965/brw_draw.c b/src/mesa/drivers/dri/i965/brw_draw.c index 5d176efb53c..5485de3692a 100644 --- a/src/mesa/drivers/dri/i965/brw_draw.c +++ b/src/mesa/drivers/dri/i965/brw_draw.c @@ -458,7 +458,7 @@ brw_try_draw_prims(struct gl_context *ctx, brw->tes.base.sampler_count = ctx->TessEvalProgram._Current ? util_last_bit(ctx->TessEvalProgram._Current->Base.SamplersUsed) : 0; brw->tcs.base.sampler_count = ctx->TessCtrlProgram._Current ? - util_last_bit(ctx->TessCtrlProgram._Current->Base.SamplersUsed) : 0; + util_last_bit(ctx->TessCtrlProgram._Current->SamplersUsed) : 0; brw->vs.base.sampler_count = util_last_bit(ctx->VertexProgram._Current->Base.SamplersUsed); diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index a41f36e766b..4e0df5a77ff 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -168,7 +168,7 @@ static struct gl_program *brwNewProgram( struct gl_context *ctx, if (prog) { prog->id = get_new_program_id(brw->screen); - return _mesa_init_gl_program(&prog->program.Base, target, id); + return _mesa_init_gl_program(&prog->program, target, id); } else { return NULL; } diff --git a/src/mesa/drivers/dri/i965/brw_tcs.c b/src/mesa/drivers/dri/i965/brw_tcs.c index 20ea4f1d57c..8a78a40f690 100644 --- a/src/mesa/drivers/dri/i965/brw_tcs.c +++ b/src/mesa/drivers/dri/i965/brw_tcs.c @@ -178,7 +178,7 @@ brw_codegen_tcs_prog(struct brw_context *brw, double start_time = 0; if (tcp) { - nir = tcp->program.Base.nir; + nir = tcp->program.nir; } else { /* Create a dummy nir_shader. We won't actually use NIR code to * generate assembly (it's easier to generate assembly directly), @@ -211,14 +211,14 @@ brw_codegen_tcs_prog(struct brw_context *brw, if (tcs) { brw_assign_common_binding_table_offsets(MESA_SHADER_TESS_CTRL, devinfo, - shader_prog, &tcp->program.Base, + shader_prog, &tcp->program, &prog_data.base.base, 0); prog_data.base.base.image_param = rzalloc_array(NULL, struct brw_image_param, tcs->NumImages); prog_data.base.base.nr_image_params = tcs->NumImages; - brw_nir_setup_glsl_uniforms(nir, shader_prog, &tcp->program.Base, + brw_nir_setup_glsl_uniforms(nir, shader_prog, &tcp->program, &prog_data.base.base, compiler->scalar_stage[MESA_SHADER_TESS_CTRL]); } else { @@ -320,7 +320,6 @@ brw_tcs_populate_key(struct brw_context *brw, (struct brw_tess_ctrl_program *) brw->tess_ctrl_program; struct brw_tess_eval_program *tep = (struct brw_tess_eval_program *) brw->tess_eval_program; - struct gl_program *prog = &tcp->program.Base; struct gl_program *tes_prog = &tep->program.Base; uint64_t per_vertex_slots = tes_prog->info.inputs_read; @@ -329,6 +328,7 @@ brw_tcs_populate_key(struct brw_context *brw, memset(key, 0, sizeof(*key)); if (tcp) { + struct gl_program *prog = &tcp->program; per_vertex_slots |= prog->info.outputs_written; per_patch_slots |= prog->info.patch_outputs_written; } @@ -350,7 +350,7 @@ brw_tcs_populate_key(struct brw_context *brw, key->program_string_id = tcp->id; /* _NEW_TEXTURE */ - brw_populate_sampler_prog_key_data(&brw->ctx, prog, &key->tex); + brw_populate_sampler_prog_key_data(&brw->ctx, &tcp->program, &key->tex); } else { key->outputs_written = tes_prog->info.inputs_read; } @@ -400,8 +400,7 @@ brw_tcs_precompile(struct gl_context *ctx, struct brw_stage_prog_data *old_prog_data = brw->tcs.base.prog_data; bool success; - struct gl_tess_ctrl_program *tcp = (struct gl_tess_ctrl_program *)prog; - struct brw_tess_ctrl_program *btcp = brw_tess_ctrl_program(tcp); + struct brw_tess_ctrl_program *btcp = brw_tess_ctrl_program(prog); const struct gl_linked_shader *tes = shader_prog->_LinkedShaders[MESA_SHADER_TESS_EVAL]; diff --git a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c index 5021e10e134..e91488fb492 100644 --- a/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c +++ b/src/mesa/drivers/dri/i965/brw_tcs_surface_state.c @@ -52,7 +52,7 @@ brw_upload_tcs_pull_constants(struct brw_context *brw) _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_TESS_CTRL); /* _NEW_PROGRAM_CONSTANTS */ - brw_upload_pull_constants(brw, BRW_NEW_TCS_CONSTBUF, &tcp->program.Base, + brw_upload_pull_constants(brw, BRW_NEW_TCS_CONSTBUF, &tcp->program, stage_state, prog_data); } diff --git a/src/mesa/drivers/dri/i965/brw_tes.c b/src/mesa/drivers/dri/i965/brw_tes.c index 3f01c07dffb..fe03816b548 100644 --- a/src/mesa/drivers/dri/i965/brw_tes.c +++ b/src/mesa/drivers/dri/i965/brw_tes.c @@ -251,7 +251,7 @@ brw_tes_populate_key(struct brw_context *brw, * be stored in the Patch URB Entry as well. */ if (tcp) { - struct gl_program *tcp_prog = &tcp->program.Base; + struct gl_program *tcp_prog = &tcp->program; per_vertex_slots |= tcp_prog->info.outputs_written; per_patch_slots |= tcp_prog->info.patch_outputs_written; } diff --git a/src/mesa/drivers/dri/i965/gen7_hs_state.c b/src/mesa/drivers/dri/i965/gen7_hs_state.c index f16af287dce..290aea23924 100644 --- a/src/mesa/drivers/dri/i965/gen7_hs_state.c +++ b/src/mesa/drivers/dri/i965/gen7_hs_state.c @@ -41,8 +41,8 @@ gen7_upload_tcs_push_constants(struct brw_context *brw) const struct brw_stage_prog_data *prog_data = brw->tcs.base.prog_data; _mesa_shader_write_subroutine_indices(&brw->ctx, MESA_SHADER_TESS_CTRL); - gen6_upload_push_constants(brw, &tcp->program.Base, prog_data, - stage_state, AUB_TRACE_VS_CONSTANTS); + gen6_upload_push_constants(brw, &tcp->program, prog_data, stage_state, + AUB_TRACE_VS_CONSTANTS); } gen7_upload_constant_state(brw, stage_state, active, _3DSTATE_CONSTANT_HS); diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 47fd4a0919f..1e4f87d6536 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1297,7 +1297,7 @@ _mesa_free_context_data( struct gl_context *ctx ) _mesa_reference_vertprog(ctx, &ctx->VertexProgram._Current, NULL); _mesa_reference_vertprog(ctx, &ctx->VertexProgram._TnlProgram, NULL); - _mesa_reference_tesscprog(ctx, &ctx->TessCtrlProgram._Current, NULL); + _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, NULL); _mesa_reference_tesseprog(ctx, &ctx->TessEvalProgram._Current, NULL); _mesa_reference_geomprog(ctx, &ctx->GeometryProgram._Current, NULL); diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index c9310ef3070..9436f8e2909 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1998,16 +1998,6 @@ struct gl_vertex_program }; -/** Tessellation control program object */ -struct gl_tess_ctrl_program -{ - struct gl_program Base; /**< base class */ - - /* output layout */ - GLint VerticesOut; -}; - - /** Tessellation evaluation program object */ struct gl_tess_eval_program { @@ -2133,7 +2123,7 @@ struct gl_vertex_program_state struct gl_tess_ctrl_program_state { /** Currently bound and valid shader. */ - struct gl_tess_ctrl_program *_Current; + struct gl_program *_Current; GLint patch_vertices; GLfloat patch_default_outer_level[4]; diff --git a/src/mesa/main/state.c b/src/mesa/main/state.c index bf6035e0142..b5207613e32 100644 --- a/src/mesa/main/state.c +++ b/src/mesa/main/state.c @@ -110,7 +110,7 @@ update_program(struct gl_context *ctx) const struct gl_vertex_program *prevVP = ctx->VertexProgram._Current; const struct gl_fragment_program *prevFP = ctx->FragmentProgram._Current; const struct gl_geometry_program *prevGP = ctx->GeometryProgram._Current; - const struct gl_tess_ctrl_program *prevTCP = ctx->TessCtrlProgram._Current; + const struct gl_program *prevTCP = ctx->TessCtrlProgram._Current; const struct gl_tess_eval_program *prevTEP = ctx->TessEvalProgram._Current; const struct gl_compute_program *prevCP = ctx->ComputeProgram._Current; GLbitfield new_state = 0x0; @@ -208,13 +208,12 @@ update_program(struct gl_context *ctx) if (tcsProg && tcsProg->LinkStatus && tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]) { /* Use GLSL tessellation control shader */ - _mesa_reference_tesscprog(ctx, &ctx->TessCtrlProgram._Current, - gl_tess_ctrl_program( - tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program)); + _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, + tcsProg->_LinkedShaders[MESA_SHADER_TESS_CTRL]->Program); } else { /* No tessellation control program */ - _mesa_reference_tesscprog(ctx, &ctx->TessCtrlProgram._Current, NULL); + _mesa_reference_program(ctx, &ctx->TessCtrlProgram._Current, NULL); } /* Examine vertex program after fragment program as @@ -284,7 +283,7 @@ update_program(struct gl_context *ctx) new_state |= _NEW_PROGRAM; if (ctx->Driver.BindProgram) { ctx->Driver.BindProgram(ctx, GL_TESS_CONTROL_PROGRAM_NV, - (struct gl_program *) ctx->TessCtrlProgram._Current); + ctx->TessCtrlProgram._Current); } } diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c index 86bbd0ac663..2ac7b561b69 100644 --- a/src/mesa/program/prog_statevars.c +++ b/src/mesa/program/prog_statevars.c @@ -604,7 +604,7 @@ _mesa_fetch_state(struct gl_context *ctx, const gl_state_index state[], case STATE_TES_PATCH_VERTICES_IN: if (ctx->TessCtrlProgram._Current) - val[0].i = ctx->TessCtrlProgram._Current->Base.info.tcs.vertices_out; + val[0].i = ctx->TessCtrlProgram._Current->info.tcs.vertices_out; else val[0].i = ctx->TessCtrlProgram.patch_vertices; return; diff --git a/src/mesa/program/program.c b/src/mesa/program/program.c index 67672164f59..f89a833d202 100644 --- a/src/mesa/program/program.c +++ b/src/mesa/program/program.c @@ -228,8 +228,8 @@ _mesa_new_program(struct gl_context *ctx, GLenum target, GLuint id) return _mesa_init_gl_program(&prog->Base, target, id); } case GL_TESS_CONTROL_PROGRAM_NV: { - struct gl_tess_ctrl_program *prog = CALLOC_STRUCT(gl_tess_ctrl_program); - return _mesa_init_gl_program(&prog->Base, target, id); + struct gl_program *prog = CALLOC_STRUCT(gl_program); + return _mesa_init_gl_program(prog, target, id); } case GL_TESS_EVALUATION_PROGRAM_NV: { struct gl_tess_eval_program *prog = CALLOC_STRUCT(gl_tess_eval_program); diff --git a/src/mesa/program/program.h b/src/mesa/program/program.h index 09e69280d46..d937f826697 100644 --- a/src/mesa/program/program.h +++ b/src/mesa/program/program.h @@ -125,16 +125,6 @@ _mesa_reference_compprog(struct gl_context *ctx, (struct gl_program *) prog); } - -static inline void -_mesa_reference_tesscprog(struct gl_context *ctx, - struct gl_tess_ctrl_program **ptr, - struct gl_tess_ctrl_program *prog) -{ - _mesa_reference_program(ctx, (struct gl_program **) ptr, - (struct gl_program *) prog); -} - static inline void _mesa_reference_tesseprog(struct gl_context *ctx, struct gl_tess_eval_program **ptr, @@ -267,19 +257,6 @@ gl_compute_program_const(const struct gl_program *prog) return (const struct gl_compute_program *) prog; } -static inline struct gl_tess_ctrl_program * -gl_tess_ctrl_program(struct gl_program *prog) -{ - return (struct gl_tess_ctrl_program *) prog; -} - -static inline const struct gl_tess_ctrl_program * -gl_tess_ctrl_program_const(const struct gl_program *prog) -{ - return (const struct gl_tess_ctrl_program *) prog; -} - - static inline struct gl_tess_eval_program * gl_tess_eval_program(struct gl_program *prog) { diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 94e012a97c7..497ba82aab9 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -70,7 +70,7 @@ static void check_program_state( struct st_context *st ) struct st_fragment_program *old_fp = st->fp; struct gl_vertex_program *new_vp = ctx->VertexProgram._Current; - struct gl_tess_ctrl_program *new_tcp = ctx->TessCtrlProgram._Current; + struct gl_program *new_tcp = ctx->TessCtrlProgram._Current; struct gl_tess_eval_program *new_tep = ctx->TessEvalProgram._Current; struct gl_geometry_program *new_gp = ctx->GeometryProgram._Current; struct gl_fragment_program *new_fp = ctx->FragmentProgram._Current; diff --git a/src/mesa/state_tracker/st_atom_constbuf.c b/src/mesa/state_tracker/st_atom_constbuf.c index 8882582c601..90d4ffbe98b 100644 --- a/src/mesa/state_tracker/st_atom_constbuf.c +++ b/src/mesa/state_tracker/st_atom_constbuf.c @@ -195,7 +195,7 @@ static void update_tcs_constants(struct st_context *st ) struct gl_program_parameter_list *params; if (tcp) { - params = tcp->Base.Base.Parameters; + params = tcp->Base.Parameters; st_upload_constants( st, params, MESA_SHADER_TESS_CTRL ); } } diff --git a/src/mesa/state_tracker/st_atom_sampler.c b/src/mesa/state_tracker/st_atom_sampler.c index 065df6dd006..76b355cec95 100644 --- a/src/mesa/state_tracker/st_atom_sampler.c +++ b/src/mesa/state_tracker/st_atom_sampler.c @@ -344,7 +344,7 @@ update_samplers(struct st_context *st) if (ctx->TessCtrlProgram._Current) { update_shader_samplers(st, PIPE_SHADER_TESS_CTRL, - &ctx->TessCtrlProgram._Current->Base, + ctx->TessCtrlProgram._Current, ctx->Const.Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits, st->state.samplers[PIPE_SHADER_TESS_CTRL], &st->state.num_samplers[PIPE_SHADER_TESS_CTRL]); diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 2f700a2fc55..0df0770bb1e 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -254,7 +254,7 @@ update_tcp( struct st_context *st ) } sttcp = st_tessctrl_program(st->ctx->TessCtrlProgram._Current); - assert(sttcp->Base.Base.Target == GL_TESS_CONTROL_PROGRAM_NV); + assert(sttcp->Base.Target == GL_TESS_CONTROL_PROGRAM_NV); st->tcp_variant = st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL, &sttcp->tgsi, &sttcp->variants); diff --git a/src/mesa/state_tracker/st_atom_texture.c b/src/mesa/state_tracker/st_atom_texture.c index c8ae62c2a7b..fbd73d69f22 100644 --- a/src/mesa/state_tracker/st_atom_texture.c +++ b/src/mesa/state_tracker/st_atom_texture.c @@ -253,7 +253,7 @@ update_tessctrl_textures(struct st_context *st) if (ctx->TessCtrlProgram._Current) { update_textures(st, MESA_SHADER_TESS_CTRL, - &ctx->TessCtrlProgram._Current->Base, + ctx->TessCtrlProgram._Current, ctx->Const.Program[MESA_SHADER_TESS_CTRL].MaxTextureImageUnits, st->state.sampler_views[PIPE_SHADER_TESS_CTRL], &st->state.num_sampler_views[PIPE_SHADER_TESS_CTRL]); diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 1fd50191d75..c85f0ef83ff 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -71,7 +71,7 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id) } case GL_TESS_CONTROL_PROGRAM_NV: { struct st_tessctrl_program *prog = ST_CALLOC_STRUCT(st_tessctrl_program); - return _mesa_init_gl_program(&prog->Base.Base, target, id); + return _mesa_init_gl_program(&prog->Base, target, id); } case GL_TESS_EVALUATION_PROGRAM_NV: { struct st_tesseval_program *prog = ST_CALLOC_STRUCT(st_tesseval_program); @@ -134,8 +134,8 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog) struct st_tessctrl_program *sttcp = (struct st_tessctrl_program *) prog; - st_release_basic_variants(st, sttcp->Base.Base.Target, - &sttcp->variants, &sttcp->tgsi); + st_release_basic_variants(st, sttcp->Base.Target, &sttcp->variants, + &sttcp->tgsi); if (sttcp->glsl_to_tgsi) free_glsl_to_tgsi_visitor(sttcp->glsl_to_tgsi); @@ -221,8 +221,8 @@ st_program_string_notify( struct gl_context *ctx, struct st_tessctrl_program *sttcp = (struct st_tessctrl_program *) prog; - st_release_basic_variants(st, sttcp->Base.Base.Target, - &sttcp->variants, &sttcp->tgsi); + st_release_basic_variants(st, sttcp->Base.Target, &sttcp->variants, + &sttcp->tgsi); if (!st_translate_tessctrl_program(st, sttcp)) return false; diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index 65f903703c2..cb402115c23 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -1605,10 +1605,10 @@ st_translate_tessctrl_program(struct st_context *st, return false; ureg_property(ureg, TGSI_PROPERTY_TCS_VERTICES_OUT, - sttcp->Base.Base.info.tcs.vertices_out); + sttcp->Base.info.tcs.vertices_out); - st_translate_program_common(st, &sttcp->Base.Base, sttcp->glsl_to_tgsi, - ureg, PIPE_SHADER_TESS_CTRL, &sttcp->tgsi); + st_translate_program_common(st, &sttcp->Base, sttcp->glsl_to_tgsi, ureg, + PIPE_SHADER_TESS_CTRL, &sttcp->tgsi); free_glsl_to_tgsi_visitor(sttcp->glsl_to_tgsi); sttcp->glsl_to_tgsi = NULL; diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index ea55d476ff0..b801891832d 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -260,11 +260,11 @@ struct st_geometry_program /** - * Derived from Mesa gl_tess_ctrl_program: + * Derived from Mesa gl_program: */ struct st_tessctrl_program { - struct gl_tess_ctrl_program Base; /**< The Mesa tess ctrl program */ + struct gl_program Base; /**< The Mesa tess ctrl program */ struct pipe_shader_state tgsi; struct glsl_to_tgsi_visitor* glsl_to_tgsi; uint64_t affected_states; /**< ST_NEW_* flags to mark dirty when binding */ @@ -321,7 +321,7 @@ st_geometry_program( struct gl_geometry_program *gp ) } static inline struct st_tessctrl_program * -st_tessctrl_program( struct gl_tess_ctrl_program *tcp ) +st_tessctrl_program( struct gl_program *tcp ) { return (struct st_tessctrl_program *)tcp; }