struct st_geometry_program *stgp =
(struct st_geometry_program *) prog;
- st_release_gp_variants(st, stgp);
+ st_release_basic_variants(st, stgp->Base.Base.Target,
+ &stgp->variants, &stgp->tgsi);
if (stgp->glsl_to_tgsi)
free_glsl_to_tgsi_visitor(stgp->glsl_to_tgsi);
struct st_tessctrl_program *sttcp =
(struct st_tessctrl_program *) prog;
- st_release_tcp_variants(st, sttcp);
+ st_release_basic_variants(st, sttcp->Base.Base.Target,
+ &sttcp->variants, &sttcp->tgsi);
if (sttcp->glsl_to_tgsi)
free_glsl_to_tgsi_visitor(sttcp->glsl_to_tgsi);
struct st_tesseval_program *sttep =
(struct st_tesseval_program *) prog;
- st_release_tep_variants(st, sttep);
+ st_release_basic_variants(st, sttep->Base.Base.Target,
+ &sttep->variants, &sttep->tgsi);
if (sttep->glsl_to_tgsi)
free_glsl_to_tgsi_visitor(sttep->glsl_to_tgsi);
else if (target == GL_GEOMETRY_PROGRAM_NV) {
struct st_geometry_program *stgp = (struct st_geometry_program *) prog;
- st_release_gp_variants(st, stgp);
+ st_release_basic_variants(st, stgp->Base.Base.Target,
+ &stgp->variants, &stgp->tgsi);
if (!st_translate_geometry_program(st, stgp))
return false;
struct st_tessctrl_program *sttcp =
(struct st_tessctrl_program *) prog;
- st_release_tcp_variants(st, sttcp);
+ st_release_basic_variants(st, sttcp->Base.Base.Target,
+ &sttcp->variants, &sttcp->tgsi);
if (!st_translate_tessctrl_program(st, sttcp))
return false;
struct st_tesseval_program *sttep =
(struct st_tesseval_program *) prog;
- st_release_tep_variants(st, sttep);
+ st_release_basic_variants(st, sttep->Base.Base.Target,
+ &sttep->variants, &sttep->tgsi);
if (!st_translate_tesseval_program(st, sttep))
return false;
/**
- * Delete a geometry program variant. Note the caller must unlink
+ * Delete a basic program variant. Note the caller must unlink
* the variant from the linked list.
*/
static void
-delete_gp_variant(struct st_context *st, struct st_gp_variant *gpv)
+delete_basic_variant(struct st_context *st, struct st_basic_variant *v,
+ GLenum target)
{
- if (gpv->driver_shader)
- cso_delete_geometry_shader(st->cso_context, gpv->driver_shader);
-
- free(gpv);
-}
-
-
-/**
- * Free all variants of a geometry program.
- */
-void
-st_release_gp_variants(struct st_context *st, struct st_geometry_program *stgp)
-{
- struct st_gp_variant *gpv;
-
- for (gpv = stgp->variants; gpv; ) {
- struct st_gp_variant *next = gpv->next;
- delete_gp_variant(st, gpv);
- gpv = next;
- }
-
- stgp->variants = NULL;
-
- if (stgp->tgsi.tokens) {
- ureg_free_tokens(stgp->tgsi.tokens);
- stgp->tgsi.tokens = NULL;
- }
-}
-
-
-/**
- * Delete a tessellation control program variant. Note the caller must unlink
- * the variant from the linked list.
- */
-static void
-delete_tcp_variant(struct st_context *st, struct st_tcp_variant *tcpv)
-{
- if (tcpv->driver_shader)
- cso_delete_tessctrl_shader(st->cso_context, tcpv->driver_shader);
-
- free(tcpv);
-}
-
-
-/**
- * Free all variants of a tessellation control program.
- */
-void
-st_release_tcp_variants(struct st_context *st, struct st_tessctrl_program *sttcp)
-{
- struct st_tcp_variant *tcpv;
-
- for (tcpv = sttcp->variants; tcpv; ) {
- struct st_tcp_variant *next = tcpv->next;
- delete_tcp_variant(st, tcpv);
- tcpv = next;
- }
-
- sttcp->variants = NULL;
-
- if (sttcp->tgsi.tokens) {
- ureg_free_tokens(sttcp->tgsi.tokens);
- sttcp->tgsi.tokens = NULL;
+ if (v->driver_shader) {
+ switch (target) {
+ case GL_TESS_CONTROL_PROGRAM_NV:
+ cso_delete_tessctrl_shader(st->cso_context, v->driver_shader);
+ break;
+ case GL_TESS_EVALUATION_PROGRAM_NV:
+ cso_delete_tesseval_shader(st->cso_context, v->driver_shader);
+ break;
+ case GL_GEOMETRY_PROGRAM_NV:
+ cso_delete_geometry_shader(st->cso_context, v->driver_shader);
+ break;
+ default:
+ assert(!"this shouldn't occur");
+ }
}
-}
-
-
-/**
- * Delete a tessellation evaluation program variant. Note the caller must
- * unlink the variant from the linked list.
- */
-static void
-delete_tep_variant(struct st_context *st, struct st_tep_variant *tepv)
-{
- if (tepv->driver_shader)
- cso_delete_tesseval_shader(st->cso_context, tepv->driver_shader);
- free(tepv);
+ free(v);
}
/**
- * Free all variants of a tessellation evaluation program.
+ * Free all basic program variants.
*/
void
-st_release_tep_variants(struct st_context *st, struct st_tesseval_program *sttep)
+st_release_basic_variants(struct st_context *st, GLenum target,
+ struct st_basic_variant **variants,
+ struct pipe_shader_state *tgsi)
{
- struct st_tep_variant *tepv;
+ struct st_basic_variant *v;
- for (tepv = sttep->variants; tepv; ) {
- struct st_tep_variant *next = tepv->next;
- delete_tep_variant(st, tepv);
- tepv = next;
+ for (v = *variants; v; ) {
+ struct st_basic_variant *next = v->next;
+ delete_basic_variant(st, v, target);
+ v = next;
}
- sttep->variants = NULL;
+ *variants = NULL;
- if (sttep->tgsi.tokens) {
- ureg_free_tokens(sttep->tgsi.tokens);
- sttep->tgsi.tokens = NULL;
+ if (tgsi->tokens) {
+ ureg_free_tokens(tgsi->tokens);
+ tgsi->tokens = NULL;
}
}
}
-static struct st_gp_variant *
+static struct st_basic_variant *
st_create_gp_variant(struct st_context *st,
struct st_geometry_program *stgp,
- const struct st_gp_variant_key *key)
+ const struct st_basic_variant_key *key)
{
struct pipe_context *pipe = st->pipe;
- struct st_gp_variant *gpv;
+ struct st_basic_variant *gpv;
- gpv = CALLOC_STRUCT(st_gp_variant);
+ gpv = CALLOC_STRUCT(st_basic_variant);
if (!gpv)
return NULL;
/**
* Get/create geometry program variant.
*/
-struct st_gp_variant *
+struct st_basic_variant *
st_get_gp_variant(struct st_context *st,
struct st_geometry_program *stgp,
- const struct st_gp_variant_key *key)
+ const struct st_basic_variant_key *key)
{
- struct st_gp_variant *gpv;
+ struct st_basic_variant *gpv;
/* Search for existing variant */
for (gpv = stgp->variants; gpv; gpv = gpv->next) {
}
-static struct st_tcp_variant *
+static struct st_basic_variant *
st_create_tcp_variant(struct st_context *st,
struct st_tessctrl_program *sttcp,
- const struct st_tcp_variant_key *key)
+ const struct st_basic_variant_key *key)
{
struct pipe_context *pipe = st->pipe;
- struct st_tcp_variant *tcpv;
+ struct st_basic_variant *tcpv;
- tcpv = CALLOC_STRUCT(st_tcp_variant);
+ tcpv = CALLOC_STRUCT(st_basic_variant);
if (!tcpv)
return NULL;
/**
* Get/create tessellation control program variant.
*/
-struct st_tcp_variant *
+struct st_basic_variant *
st_get_tcp_variant(struct st_context *st,
struct st_tessctrl_program *sttcp,
- const struct st_tcp_variant_key *key)
+ const struct st_basic_variant_key *key)
{
- struct st_tcp_variant *tcpv;
+ struct st_basic_variant *tcpv;
/* Search for existing variant */
for (tcpv = sttcp->variants; tcpv; tcpv = tcpv->next) {
}
-static struct st_tep_variant *
+static struct st_basic_variant *
st_create_tep_variant(struct st_context *st,
struct st_tesseval_program *sttep,
- const struct st_tep_variant_key *key)
+ const struct st_basic_variant_key *key)
{
struct pipe_context *pipe = st->pipe;
- struct st_tep_variant *tepv;
+ struct st_basic_variant *tepv;
- tepv = CALLOC_STRUCT(st_tep_variant);
+ tepv = CALLOC_STRUCT(st_basic_variant);
if (!tepv)
return NULL;
/**
* Get/create tessellation evaluation program variant.
*/
-struct st_tep_variant *
+struct st_basic_variant *
st_get_tep_variant(struct st_context *st,
struct st_tesseval_program *sttep,
- const struct st_tep_variant_key *key)
+ const struct st_basic_variant_key *key)
{
- struct st_tep_variant *tepv;
+ struct st_basic_variant *tepv;
/* Search for existing variant */
for (tepv = sttep->variants; tepv; tepv = tepv->next) {
* variants attached to the given program which match the given context.
*/
static void
-destroy_program_variants(struct st_context *st, struct gl_program *program)
+destroy_program_variants(struct st_context *st, struct gl_program *target)
{
- if (!program || program == &_mesa_DummyProgram)
+ if (!target || target == &_mesa_DummyProgram)
return;
- switch (program->Target) {
+ switch (target->Target) {
case GL_VERTEX_PROGRAM_ARB:
{
- struct st_vertex_program *stvp = (struct st_vertex_program *) program;
+ struct st_vertex_program *stvp = (struct st_vertex_program *) target;
struct st_vp_variant *vpv, **prevPtr = &stvp->variants;
for (vpv = stvp->variants; vpv; ) {
case GL_FRAGMENT_PROGRAM_ARB:
{
struct st_fragment_program *stfp =
- (struct st_fragment_program *) program;
+ (struct st_fragment_program *) target;
struct st_fp_variant *fpv, **prevPtr = &stfp->variants;
for (fpv = stfp->variants; fpv; ) {
case GL_GEOMETRY_PROGRAM_NV:
{
struct st_geometry_program *stgp =
- (struct st_geometry_program *) program;
- struct st_gp_variant *gpv, **prevPtr = &stgp->variants;
+ (struct st_geometry_program *) target;
+ struct st_basic_variant *gpv, **prevPtr = &stgp->variants;
for (gpv = stgp->variants; gpv; ) {
- struct st_gp_variant *next = gpv->next;
+ struct st_basic_variant *next = gpv->next;
if (gpv->key.st == st) {
/* unlink from list */
*prevPtr = next;
/* destroy this variant */
- delete_gp_variant(st, gpv);
+ delete_basic_variant(st, gpv, stgp->Base.Base.Target);
}
else {
prevPtr = &gpv->next;
case GL_TESS_CONTROL_PROGRAM_NV:
{
struct st_tessctrl_program *sttcp =
- (struct st_tessctrl_program *) program;
- struct st_tcp_variant *tcpv, **prevPtr = &sttcp->variants;
+ (struct st_tessctrl_program *) target;
+ struct st_basic_variant *tcpv, **prevPtr = &sttcp->variants;
for (tcpv = sttcp->variants; tcpv; ) {
- struct st_tcp_variant *next = tcpv->next;
+ struct st_basic_variant *next = tcpv->next;
if (tcpv->key.st == st) {
/* unlink from list */
*prevPtr = next;
/* destroy this variant */
- delete_tcp_variant(st, tcpv);
+ delete_basic_variant(st, tcpv, sttcp->Base.Base.Target);
}
else {
prevPtr = &tcpv->next;
case GL_TESS_EVALUATION_PROGRAM_NV:
{
struct st_tesseval_program *sttep =
- (struct st_tesseval_program *) program;
- struct st_tep_variant *tepv, **prevPtr = &sttep->variants;
+ (struct st_tesseval_program *) target;
+ struct st_basic_variant *tepv, **prevPtr = &sttep->variants;
for (tepv = sttep->variants; tepv; ) {
- struct st_tep_variant *next = tepv->next;
+ struct st_basic_variant *next = tepv->next;
if (tepv->key.st == st) {
/* unlink from list */
*prevPtr = next;
/* destroy this variant */
- delete_tep_variant(st, tepv);
+ delete_basic_variant(st, tepv, sttep->Base.Base.Target);
}
else {
prevPtr = &tepv->next;
break;
default:
_mesa_problem(NULL, "Unexpected program target 0x%x in "
- "destroy_program_variants_cb()", program->Target);
+ "destroy_program_variants_cb()", target->Target);
}
}
case GL_TESS_CONTROL_PROGRAM_NV: {
struct st_tessctrl_program *p = (struct st_tessctrl_program *)prog;
- struct st_tcp_variant_key key;
+ struct st_basic_variant_key key;
memset(&key, 0, sizeof(key));
key.st = st->has_shareable_shaders ? NULL : st;
case GL_TESS_EVALUATION_PROGRAM_NV: {
struct st_tesseval_program *p = (struct st_tesseval_program *)prog;
- struct st_tep_variant_key key;
+ struct st_basic_variant_key key;
memset(&key, 0, sizeof(key));
key.st = st->has_shareable_shaders ? NULL : st;
case GL_GEOMETRY_PROGRAM_NV: {
struct st_geometry_program *p = (struct st_geometry_program *)prog;
- struct st_gp_variant_key key;
+ struct st_basic_variant_key key;
memset(&key, 0, sizeof(key));
key.st = st->has_shareable_shaders ? NULL : st;
-/** Geometry program variant key */
-struct st_gp_variant_key
+/** Key shared by all shaders except VP, FP */
+struct st_basic_variant_key
{
struct st_context *st; /**< variants are per-context */
- /* no other fields yet */
};
/**
* Geometry program variant.
*/
-struct st_gp_variant
+struct st_basic_variant
{
/* Parameters which generated this variant. */
- struct st_gp_variant_key key;
+ struct st_basic_variant_key key;
void *driver_shader;
- struct st_gp_variant *next;
+ struct st_basic_variant *next;
};
struct pipe_shader_state tgsi;
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
- struct st_gp_variant *variants;
-};
-
-
-
-/** Tessellation control program variant key */
-struct st_tcp_variant_key
-{
- struct st_context *st; /**< variants are per-context */
- /* no other fields yet */
-};
-
-
-/**
- * Tessellation control program variant.
- */
-struct st_tcp_variant
-{
- /* Parameters which generated this variant. */
- struct st_tcp_variant_key key;
-
- void *driver_shader;
-
- struct st_tcp_variant *next;
+ struct st_basic_variant *variants;
};
struct pipe_shader_state tgsi;
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
- struct st_tcp_variant *variants;
-};
-
-
-
-/** Tessellation evaluation program variant key */
-struct st_tep_variant_key
-{
- struct st_context *st; /**< variants are per-context */
- /* no other fields yet */
-};
-
-
-/**
- * Tessellation evaluation program variant.
- */
-struct st_tep_variant
-{
- /* Parameters which generated this variant. */
- struct st_tep_variant_key key;
-
- void *driver_shader;
-
- struct st_tep_variant *next;
+ struct st_basic_variant *variants;
};
struct pipe_shader_state tgsi;
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
- struct st_tep_variant *variants;
+ struct st_basic_variant *variants;
};
const struct st_fp_variant_key *key);
-extern struct st_gp_variant *
+extern struct st_basic_variant *
st_get_gp_variant(struct st_context *st,
struct st_geometry_program *stgp,
- const struct st_gp_variant_key *key);
+ const struct st_basic_variant_key *key);
-extern struct st_tcp_variant *
+extern struct st_basic_variant *
st_get_tcp_variant(struct st_context *st,
struct st_tessctrl_program *sttcp,
- const struct st_tcp_variant_key *key);
+ const struct st_basic_variant_key *key);
-extern struct st_tep_variant *
+extern struct st_basic_variant *
st_get_tep_variant(struct st_context *st,
struct st_tesseval_program *sttep,
- const struct st_tep_variant_key *key);
+ const struct st_basic_variant_key *key);
extern void
st_release_vp_variants( struct st_context *st,
struct st_fragment_program *stfp );
extern void
-st_release_gp_variants(struct st_context *st,
- struct st_geometry_program *stgp);
-
-extern void
-st_release_tcp_variants(struct st_context *st,
- struct st_tessctrl_program *sttcp);
-
-extern void
-st_release_tep_variants(struct st_context *st,
- struct st_tesseval_program *sttep);
+st_release_basic_variants(struct st_context *st, GLenum target,
+ struct st_basic_variant **variants,
+ struct pipe_shader_state *tgsi);
extern void
st_destroy_program_variants(struct st_context *st);