summaryrefslogtreecommitdiffstats
path: root/src/mesa/state_tracker
diff options
context:
space:
mode:
authorMarek Olšák <marek.olsak@amd.com>2017-04-30 16:31:07 +0200
committerMarek Olšák <marek.olsak@amd.com>2017-05-08 18:32:00 +0200
commit57fc8ae61aa3fb3f2a0170d22363045bfdf1ec2c (patch)
treef4e7a5785a7fb0547c623fedc70a345c3ca082ff /src/mesa/state_tracker
parenta159d6ed20e3487df37c0d447564d4690d59ccc4 (diff)
st/mesa: simplify code due to unification to st_common_program
v2: use the st_common_program() helper Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com> Reviewed-by: Brian Paul <brianp@vmware.com> Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
Diffstat (limited to 'src/mesa/state_tracker')
-rw-r--r--src/mesa/state_tracker/st_cb_program.c57
-rw-r--r--src/mesa/state_tracker/st_glsl_to_tgsi.cpp16
-rw-r--r--src/mesa/state_tracker/st_program.c21
-rw-r--r--src/mesa/state_tracker/st_shader_cache.c40
4 files changed, 35 insertions, 99 deletions
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index 531d20d20ff..555fc5d5ad9 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -68,19 +68,11 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id,
struct st_fragment_program);
return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
}
+ case GL_TESS_CONTROL_PROGRAM_NV:
+ case GL_TESS_EVALUATION_PROGRAM_NV:
case GL_GEOMETRY_PROGRAM_NV: {
struct st_common_program *prog = rzalloc(NULL,
- struct st_common_program);
- return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
- }
- case GL_TESS_CONTROL_PROGRAM_NV: {
- struct st_common_program *prog = rzalloc(NULL,
- struct st_common_program);
- return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
- }
- case GL_TESS_EVALUATION_PROGRAM_NV: {
- struct st_common_program *prog = rzalloc(NULL,
- struct st_common_program);
+ struct st_common_program);
return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
}
case GL_COMPUTE_PROGRAM_NV: {
@@ -113,16 +105,17 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog)
free_glsl_to_tgsi_visitor(stvp->glsl_to_tgsi);
}
break;
+ case GL_TESS_CONTROL_PROGRAM_NV:
+ case GL_TESS_EVALUATION_PROGRAM_NV:
case GL_GEOMETRY_PROGRAM_NV:
{
- struct st_common_program *stgp =
- (struct st_common_program *) prog;
+ struct st_common_program *p = st_common_program(prog);
- st_release_basic_variants(st, stgp->Base.Target, &stgp->variants,
- &stgp->tgsi);
+ st_release_basic_variants(st, p->Base.Target, &p->variants,
+ &p->tgsi);
- if (stgp->glsl_to_tgsi)
- free_glsl_to_tgsi_visitor(stgp->glsl_to_tgsi);
+ if (p->glsl_to_tgsi)
+ free_glsl_to_tgsi_visitor(p->glsl_to_tgsi);
}
break;
case GL_FRAGMENT_PROGRAM_ARB:
@@ -136,30 +129,6 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog)
free_glsl_to_tgsi_visitor(stfp->glsl_to_tgsi);
}
break;
- case GL_TESS_CONTROL_PROGRAM_NV:
- {
- struct st_common_program *sttcp =
- (struct st_common_program *) prog;
-
- 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);
- }
- break;
- case GL_TESS_EVALUATION_PROGRAM_NV:
- {
- struct st_common_program *sttep =
- (struct st_common_program *) prog;
-
- st_release_basic_variants(st, sttep->Base.Target,
- &sttep->variants, &sttep->tgsi);
-
- if (sttep->glsl_to_tgsi)
- free_glsl_to_tgsi_visitor(sttep->glsl_to_tgsi);
- }
- break;
case GL_COMPUTE_PROGRAM_NV:
{
struct st_compute_program *stcp =
@@ -204,7 +173,7 @@ st_program_string_notify( struct gl_context *ctx,
st->dirty |= stfp->affected_states;
}
else if (target == GL_GEOMETRY_PROGRAM_NV) {
- struct st_common_program *stgp = (struct st_common_program *) prog;
+ struct st_common_program *stgp = st_common_program(prog);
st_release_basic_variants(st, stgp->Base.Target, &stgp->variants,
&stgp->tgsi);
@@ -226,7 +195,7 @@ st_program_string_notify( struct gl_context *ctx,
}
else if (target == GL_TESS_CONTROL_PROGRAM_NV) {
struct st_common_program *sttcp =
- (struct st_common_program *) prog;
+ st_common_program(prog);
st_release_basic_variants(st, sttcp->Base.Target, &sttcp->variants,
&sttcp->tgsi);
@@ -238,7 +207,7 @@ st_program_string_notify( struct gl_context *ctx,
}
else if (target == GL_TESS_EVALUATION_PROGRAM_NV) {
struct st_common_program *sttep =
- (struct st_common_program *) prog;
+ st_common_program(prog);
st_release_basic_variants(st, sttep->Base.Target, &sttep->variants,
&sttep->tgsi);
diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
index 0a8782ec364..f3e8e337982 100644
--- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
+++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp
@@ -6830,9 +6830,7 @@ get_mesa_program_tgsi(struct gl_context *ctx,
struct st_vertex_program *stvp;
struct st_fragment_program *stfp;
- struct st_common_program *stgp;
- struct st_common_program *sttcp;
- struct st_common_program *sttep;
+ struct st_common_program *stp;
struct st_compute_program *stcp;
switch (shader->Stage) {
@@ -6844,17 +6842,11 @@ get_mesa_program_tgsi(struct gl_context *ctx,
stfp = (struct st_fragment_program *)prog;
stfp->glsl_to_tgsi = v;
break;
- case MESA_SHADER_GEOMETRY:
- stgp = (struct st_common_program *)prog;
- stgp->glsl_to_tgsi = v;
- break;
case MESA_SHADER_TESS_CTRL:
- sttcp = (struct st_common_program *)prog;
- sttcp->glsl_to_tgsi = v;
- break;
case MESA_SHADER_TESS_EVAL:
- sttep = (struct st_common_program *)prog;
- sttep->glsl_to_tgsi = v;
+ case MESA_SHADER_GEOMETRY:
+ stp = st_common_program(prog);
+ stp->glsl_to_tgsi = v;
break;
case MESA_SHADER_COMPUTE:
stcp = (struct st_compute_program *)prog;
diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
index 09e6696782f..6de61741dcf 100644
--- a/src/mesa/state_tracker/st_program.c
+++ b/src/mesa/state_tracker/st_program.c
@@ -120,7 +120,7 @@ st_set_prog_affected_state_flags(struct gl_program *prog)
break;
case MESA_SHADER_TESS_CTRL:
- states = &((struct st_common_program*)prog)->affected_states;
+ states = &(st_common_program(prog))->affected_states;
*states = ST_NEW_TCS_STATE;
@@ -135,7 +135,7 @@ st_set_prog_affected_state_flags(struct gl_program *prog)
break;
case MESA_SHADER_TESS_EVAL:
- states = &((struct st_common_program*)prog)->affected_states;
+ states = &(st_common_program(prog))->affected_states;
*states = ST_NEW_TES_STATE |
ST_NEW_RASTERIZER;
@@ -151,7 +151,7 @@ st_set_prog_affected_state_flags(struct gl_program *prog)
break;
case MESA_SHADER_GEOMETRY:
- states = &((struct st_common_program*)prog)->affected_states;
+ states = &(st_common_program(prog))->affected_states;
*states = ST_NEW_GS_STATE |
ST_NEW_RASTERIZER;
@@ -1918,16 +1918,11 @@ destroy_program_variants(struct st_context *st, struct gl_program *target)
case GL_TESS_EVALUATION_PROGRAM_NV:
case GL_COMPUTE_PROGRAM_NV:
{
- struct st_common_program *gp = (struct st_common_program*)target;
- struct st_common_program *tcp = (struct st_common_program*)target;
- struct st_common_program *tep = (struct st_common_program*)target;
+ struct st_common_program *p = st_common_program(target);
struct st_compute_program *cp = (struct st_compute_program*)target;
struct st_basic_variant **variants =
- target->Target == GL_GEOMETRY_PROGRAM_NV ? &gp->variants :
- target->Target == GL_TESS_CONTROL_PROGRAM_NV ? &tcp->variants :
- target->Target == GL_TESS_EVALUATION_PROGRAM_NV ? &tep->variants :
target->Target == GL_COMPUTE_PROGRAM_NV ? &cp->variants :
- NULL;
+ &p->variants;
struct st_basic_variant *v, **prevPtr = variants;
for (v = *variants; v; ) {
@@ -2066,19 +2061,19 @@ st_precompile_shader_variant(struct st_context *st,
}
case GL_TESS_CONTROL_PROGRAM_NV: {
- struct st_common_program *p = (struct st_common_program *)prog;
+ struct st_common_program *p = st_common_program(prog);
st_get_basic_variant(st, PIPE_SHADER_TESS_CTRL, &p->tgsi, &p->variants);
break;
}
case GL_TESS_EVALUATION_PROGRAM_NV: {
- struct st_common_program *p = (struct st_common_program *)prog;
+ struct st_common_program *p = st_common_program(prog);
st_get_basic_variant(st, PIPE_SHADER_TESS_EVAL, &p->tgsi, &p->variants);
break;
}
case GL_GEOMETRY_PROGRAM_NV: {
- struct st_common_program *p = (struct st_common_program *)prog;
+ struct st_common_program *p = st_common_program(prog);
st_get_basic_variant(st, PIPE_SHADER_GEOMETRY, &p->tgsi, &p->variants);
break;
}
diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c
index 0771ca660cf..23416c0c3fa 100644
--- a/src/mesa/state_tracker/st_shader_cache.c
+++ b/src/mesa/state_tracker/st_shader_cache.c
@@ -86,25 +86,11 @@ st_store_tgsi_in_disk_cache(struct st_context *st, struct gl_program *prog,
write_tgsi_to_cache(blob, &stvp->tgsi, st, sha1, num_tokens);
break;
}
- case MESA_SHADER_TESS_CTRL: {
- struct st_common_program *stcp = (struct st_common_program *) prog;
- sha1 = stcp->sha1;
-
- write_stream_out_to_cache(blob, out_state);
- write_tgsi_to_cache(blob, out_state, st, sha1, num_tokens);
- break;
- }
- case MESA_SHADER_TESS_EVAL: {
- struct st_common_program *step = (struct st_common_program *) prog;
- sha1 = step->sha1;
-
- write_stream_out_to_cache(blob, out_state);
- write_tgsi_to_cache(blob, out_state, st, sha1, num_tokens);
- break;
- }
+ case MESA_SHADER_TESS_CTRL:
+ case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY: {
- struct st_common_program *stgp = (struct st_common_program *) prog;
- sha1 = stgp->sha1;
+ struct st_common_program *p = st_common_program(prog);
+ sha1 = p->sha1;
write_stream_out_to_cache(blob, out_state);
write_tgsi_to_cache(blob, out_state, st, sha1, num_tokens);
@@ -188,24 +174,21 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
break;
}
case MESA_SHADER_TESS_CTRL: {
- struct st_common_program *stcp =
- (struct st_common_program *) glprog;
+ struct st_common_program *stcp = st_common_program(glprog);
stage_sha1[i] = stcp->sha1;
ralloc_strcat(&buf, " tcs");
disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
break;
}
case MESA_SHADER_TESS_EVAL: {
- struct st_common_program *step =
- (struct st_common_program *) glprog;
+ struct st_common_program *step = st_common_program(glprog);
stage_sha1[i] = step->sha1;
ralloc_strcat(&buf, " tes");
disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
break;
}
case MESA_SHADER_GEOMETRY: {
- struct st_common_program *stgp =
- (struct st_common_program *) glprog;
+ struct st_common_program *stgp = st_common_program(glprog);
stage_sha1[i] = stgp->sha1;
ralloc_strcat(&buf, " gs");
disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
@@ -278,8 +261,7 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
break;
}
case MESA_SHADER_TESS_CTRL: {
- struct st_common_program *sttcp =
- (struct st_common_program *) glprog;
+ struct st_common_program *sttcp = st_common_program(glprog);
st_release_basic_variants(st, sttcp->Base.Target,
&sttcp->variants, &sttcp->tgsi);
@@ -293,8 +275,7 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
break;
}
case MESA_SHADER_TESS_EVAL: {
- struct st_common_program *sttep =
- (struct st_common_program *) glprog;
+ struct st_common_program *sttep = st_common_program(glprog);
st_release_basic_variants(st, sttep->Base.Target,
&sttep->variants, &sttep->tgsi);
@@ -308,8 +289,7 @@ st_load_tgsi_from_disk_cache(struct gl_context *ctx,
break;
}
case MESA_SHADER_GEOMETRY: {
- struct st_common_program *stgp =
- (struct st_common_program *) glprog;
+ struct st_common_program *stgp = st_common_program(glprog);
st_release_basic_variants(st, stgp->Base.Target, &stgp->variants,
&stgp->tgsi);