We now get all the tcs metadata from shader_info.
Reviewed-by: Jason Ekstrand <jason@jlekstrand.net>
/** 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 */
};
*/
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;
}
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;
}
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);
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;
}
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),
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 {
(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;
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;
}
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;
}
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];
_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);
}
* 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;
}
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);
_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);
};
-/** 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
{
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];
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;
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
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);
}
}
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;
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);
(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,
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)
{
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;
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 );
}
}
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]);
}
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);
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]);
}
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);
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);
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;
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;
/**
- * 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 */
}
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;
}