st/mesa: unify get_variant functions for TCS, TES, GS
Reviewed-by: Edward O'Callaghan <eocallaghan@alterapraxis.com>
This commit is contained in:
@@ -163,7 +163,6 @@ static void
|
|||||||
update_gp( struct st_context *st )
|
update_gp( struct st_context *st )
|
||||||
{
|
{
|
||||||
struct st_geometry_program *stgp;
|
struct st_geometry_program *stgp;
|
||||||
struct st_basic_variant_key key;
|
|
||||||
|
|
||||||
if (!st->ctx->GeometryProgram._Current) {
|
if (!st->ctx->GeometryProgram._Current) {
|
||||||
cso_set_geometry_shader_handle(st->cso_context, NULL);
|
cso_set_geometry_shader_handle(st->cso_context, NULL);
|
||||||
@@ -173,10 +172,7 @@ update_gp( struct st_context *st )
|
|||||||
stgp = st_geometry_program(st->ctx->GeometryProgram._Current);
|
stgp = st_geometry_program(st->ctx->GeometryProgram._Current);
|
||||||
assert(stgp->Base.Base.Target == GL_GEOMETRY_PROGRAM_NV);
|
assert(stgp->Base.Base.Target == GL_GEOMETRY_PROGRAM_NV);
|
||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
st->gp_variant = st_get_basic_variant(st, &stgp->tgsi, &stgp->variants);
|
||||||
key.st = st->has_shareable_shaders ? NULL : st;
|
|
||||||
|
|
||||||
st->gp_variant = st_get_gp_variant(st, stgp, &key);
|
|
||||||
|
|
||||||
st_reference_geomprog(st, &st->gp, stgp);
|
st_reference_geomprog(st, &st->gp, stgp);
|
||||||
|
|
||||||
@@ -199,7 +195,6 @@ static void
|
|||||||
update_tcp( struct st_context *st )
|
update_tcp( struct st_context *st )
|
||||||
{
|
{
|
||||||
struct st_tessctrl_program *sttcp;
|
struct st_tessctrl_program *sttcp;
|
||||||
struct st_basic_variant_key key;
|
|
||||||
|
|
||||||
if (!st->ctx->TessCtrlProgram._Current) {
|
if (!st->ctx->TessCtrlProgram._Current) {
|
||||||
cso_set_tessctrl_shader_handle(st->cso_context, NULL);
|
cso_set_tessctrl_shader_handle(st->cso_context, NULL);
|
||||||
@@ -209,10 +204,7 @@ update_tcp( struct st_context *st )
|
|||||||
sttcp = st_tessctrl_program(st->ctx->TessCtrlProgram._Current);
|
sttcp = st_tessctrl_program(st->ctx->TessCtrlProgram._Current);
|
||||||
assert(sttcp->Base.Base.Target == GL_TESS_CONTROL_PROGRAM_NV);
|
assert(sttcp->Base.Base.Target == GL_TESS_CONTROL_PROGRAM_NV);
|
||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
st->tcp_variant = st_get_basic_variant(st, &sttcp->tgsi, &sttcp->variants);
|
||||||
key.st = st->has_shareable_shaders ? NULL : st;
|
|
||||||
|
|
||||||
st->tcp_variant = st_get_tcp_variant(st, sttcp, &key);
|
|
||||||
|
|
||||||
st_reference_tesscprog(st, &st->tcp, sttcp);
|
st_reference_tesscprog(st, &st->tcp, sttcp);
|
||||||
|
|
||||||
@@ -235,7 +227,6 @@ static void
|
|||||||
update_tep( struct st_context *st )
|
update_tep( struct st_context *st )
|
||||||
{
|
{
|
||||||
struct st_tesseval_program *sttep;
|
struct st_tesseval_program *sttep;
|
||||||
struct st_basic_variant_key key;
|
|
||||||
|
|
||||||
if (!st->ctx->TessEvalProgram._Current) {
|
if (!st->ctx->TessEvalProgram._Current) {
|
||||||
cso_set_tesseval_shader_handle(st->cso_context, NULL);
|
cso_set_tesseval_shader_handle(st->cso_context, NULL);
|
||||||
@@ -245,10 +236,7 @@ update_tep( struct st_context *st )
|
|||||||
sttep = st_tesseval_program(st->ctx->TessEvalProgram._Current);
|
sttep = st_tesseval_program(st->ctx->TessEvalProgram._Current);
|
||||||
assert(sttep->Base.Base.Target == GL_TESS_EVALUATION_PROGRAM_NV);
|
assert(sttep->Base.Base.Target == GL_TESS_EVALUATION_PROGRAM_NV);
|
||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
st->tep_variant = st_get_basic_variant(st, &sttep->tgsi, &sttep->variants);
|
||||||
key.st = st->has_shareable_shaders ? NULL : st;
|
|
||||||
|
|
||||||
st->tep_variant = st_get_tep_variant(st, sttep, &key);
|
|
||||||
|
|
||||||
st_reference_tesseprog(st, &st->tep, sttep);
|
st_reference_tesseprog(st, &st->tep, sttep);
|
||||||
|
|
||||||
|
@@ -1266,53 +1266,43 @@ st_translate_geometry_program(struct st_context *st,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct st_basic_variant *
|
|
||||||
st_create_gp_variant(struct st_context *st,
|
|
||||||
struct st_geometry_program *stgp,
|
|
||||||
const struct st_basic_variant_key *key)
|
|
||||||
{
|
|
||||||
struct pipe_context *pipe = st->pipe;
|
|
||||||
struct st_basic_variant *gpv;
|
|
||||||
|
|
||||||
gpv = CALLOC_STRUCT(st_basic_variant);
|
|
||||||
if (!gpv)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* fill in new variant */
|
|
||||||
gpv->driver_shader = pipe->create_gs_state(pipe, &stgp->tgsi);
|
|
||||||
gpv->key = *key;
|
|
||||||
return gpv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get/create geometry program variant.
|
* Get/create a basic program variant.
|
||||||
*/
|
*/
|
||||||
struct st_basic_variant *
|
struct st_basic_variant *
|
||||||
st_get_gp_variant(struct st_context *st,
|
st_get_basic_variant(struct st_context *st,
|
||||||
struct st_geometry_program *stgp,
|
struct pipe_shader_state *tgsi,
|
||||||
const struct st_basic_variant_key *key)
|
struct st_basic_variant **variants)
|
||||||
{
|
{
|
||||||
struct st_basic_variant *gpv;
|
struct pipe_context *pipe = st->pipe;
|
||||||
|
struct st_basic_variant *v;
|
||||||
|
struct st_basic_variant_key key;
|
||||||
|
|
||||||
|
memset(&key, 0, sizeof(key));
|
||||||
|
key.st = st->has_shareable_shaders ? NULL : st;
|
||||||
|
|
||||||
/* Search for existing variant */
|
/* Search for existing variant */
|
||||||
for (gpv = stgp->variants; gpv; gpv = gpv->next) {
|
for (v = *variants; v; v = v->next) {
|
||||||
if (memcmp(&gpv->key, key, sizeof(*key)) == 0) {
|
if (memcmp(&v->key, &key, sizeof(key)) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!gpv) {
|
if (!v) {
|
||||||
/* create new */
|
/* create new */
|
||||||
gpv = st_create_gp_variant(st, stgp, key);
|
v = CALLOC_STRUCT(st_basic_variant);
|
||||||
if (gpv) {
|
if (v) {
|
||||||
|
/* fill in new variant */
|
||||||
|
v->driver_shader = pipe->create_gs_state(pipe, tgsi);
|
||||||
|
v->key = key;
|
||||||
|
|
||||||
/* insert into list */
|
/* insert into list */
|
||||||
gpv->next = stgp->variants;
|
v->next = *variants;
|
||||||
stgp->variants = gpv;
|
*variants = v;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return gpv;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1341,56 +1331,6 @@ st_translate_tessctrl_program(struct st_context *st,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct st_basic_variant *
|
|
||||||
st_create_tcp_variant(struct st_context *st,
|
|
||||||
struct st_tessctrl_program *sttcp,
|
|
||||||
const struct st_basic_variant_key *key)
|
|
||||||
{
|
|
||||||
struct pipe_context *pipe = st->pipe;
|
|
||||||
struct st_basic_variant *tcpv;
|
|
||||||
|
|
||||||
tcpv = CALLOC_STRUCT(st_basic_variant);
|
|
||||||
if (!tcpv)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* fill in new variant */
|
|
||||||
tcpv->driver_shader = pipe->create_tcs_state(pipe, &sttcp->tgsi);
|
|
||||||
tcpv->key = *key;
|
|
||||||
return tcpv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get/create tessellation control program variant.
|
|
||||||
*/
|
|
||||||
struct st_basic_variant *
|
|
||||||
st_get_tcp_variant(struct st_context *st,
|
|
||||||
struct st_tessctrl_program *sttcp,
|
|
||||||
const struct st_basic_variant_key *key)
|
|
||||||
{
|
|
||||||
struct st_basic_variant *tcpv;
|
|
||||||
|
|
||||||
/* Search for existing variant */
|
|
||||||
for (tcpv = sttcp->variants; tcpv; tcpv = tcpv->next) {
|
|
||||||
if (memcmp(&tcpv->key, key, sizeof(*key)) == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tcpv) {
|
|
||||||
/* create new */
|
|
||||||
tcpv = st_create_tcp_variant(st, sttcp, key);
|
|
||||||
if (tcpv) {
|
|
||||||
/* insert into list */
|
|
||||||
tcpv->next = sttcp->variants;
|
|
||||||
sttcp->variants = tcpv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tcpv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Translate a tessellation evaluation program to create a new variant.
|
* Translate a tessellation evaluation program to create a new variant.
|
||||||
*/
|
*/
|
||||||
@@ -1438,56 +1378,6 @@ st_translate_tesseval_program(struct st_context *st,
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static struct st_basic_variant *
|
|
||||||
st_create_tep_variant(struct st_context *st,
|
|
||||||
struct st_tesseval_program *sttep,
|
|
||||||
const struct st_basic_variant_key *key)
|
|
||||||
{
|
|
||||||
struct pipe_context *pipe = st->pipe;
|
|
||||||
struct st_basic_variant *tepv;
|
|
||||||
|
|
||||||
tepv = CALLOC_STRUCT(st_basic_variant);
|
|
||||||
if (!tepv)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
/* fill in new variant */
|
|
||||||
tepv->driver_shader = pipe->create_tes_state(pipe, &sttep->tgsi);
|
|
||||||
tepv->key = *key;
|
|
||||||
return tepv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get/create tessellation evaluation program variant.
|
|
||||||
*/
|
|
||||||
struct st_basic_variant *
|
|
||||||
st_get_tep_variant(struct st_context *st,
|
|
||||||
struct st_tesseval_program *sttep,
|
|
||||||
const struct st_basic_variant_key *key)
|
|
||||||
{
|
|
||||||
struct st_basic_variant *tepv;
|
|
||||||
|
|
||||||
/* Search for existing variant */
|
|
||||||
for (tepv = sttep->variants; tepv; tepv = tepv->next) {
|
|
||||||
if (memcmp(&tepv->key, key, sizeof(*key)) == 0) {
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!tepv) {
|
|
||||||
/* create new */
|
|
||||||
tepv = st_create_tep_variant(st, sttep, key);
|
|
||||||
if (tepv) {
|
|
||||||
/* insert into list */
|
|
||||||
tepv->next = sttep->variants;
|
|
||||||
sttep->variants = tepv;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return tepv;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Vert/Geom/Frag programs have per-context variants. Free all the
|
* Vert/Geom/Frag programs have per-context variants. Free all the
|
||||||
* variants attached to the given program which match the given context.
|
* variants attached to the given program which match the given context.
|
||||||
@@ -1731,31 +1621,19 @@ st_precompile_shader_variant(struct st_context *st,
|
|||||||
|
|
||||||
case GL_TESS_CONTROL_PROGRAM_NV: {
|
case GL_TESS_CONTROL_PROGRAM_NV: {
|
||||||
struct st_tessctrl_program *p = (struct st_tessctrl_program *)prog;
|
struct st_tessctrl_program *p = (struct st_tessctrl_program *)prog;
|
||||||
struct st_basic_variant_key key;
|
st_get_basic_variant(st, &p->tgsi, &p->variants);
|
||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
|
||||||
key.st = st->has_shareable_shaders ? NULL : st;
|
|
||||||
st_get_tcp_variant(st, p, &key);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GL_TESS_EVALUATION_PROGRAM_NV: {
|
case GL_TESS_EVALUATION_PROGRAM_NV: {
|
||||||
struct st_tesseval_program *p = (struct st_tesseval_program *)prog;
|
struct st_tesseval_program *p = (struct st_tesseval_program *)prog;
|
||||||
struct st_basic_variant_key key;
|
st_get_basic_variant(st, &p->tgsi, &p->variants);
|
||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
|
||||||
key.st = st->has_shareable_shaders ? NULL : st;
|
|
||||||
st_get_tep_variant(st, p, &key);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case GL_GEOMETRY_PROGRAM_NV: {
|
case GL_GEOMETRY_PROGRAM_NV: {
|
||||||
struct st_geometry_program *p = (struct st_geometry_program *)prog;
|
struct st_geometry_program *p = (struct st_geometry_program *)prog;
|
||||||
struct st_basic_variant_key key;
|
st_get_basic_variant(st, &p->tgsi, &p->variants);
|
||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
|
||||||
key.st = st->has_shareable_shaders ? NULL : st;
|
|
||||||
st_get_gp_variant(st, p, &key);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -350,21 +350,10 @@ st_get_fp_variant(struct st_context *st,
|
|||||||
struct st_fragment_program *stfp,
|
struct st_fragment_program *stfp,
|
||||||
const struct st_fp_variant_key *key);
|
const struct st_fp_variant_key *key);
|
||||||
|
|
||||||
|
|
||||||
extern struct st_basic_variant *
|
extern struct st_basic_variant *
|
||||||
st_get_gp_variant(struct st_context *st,
|
st_get_basic_variant(struct st_context *st,
|
||||||
struct st_geometry_program *stgp,
|
struct pipe_shader_state *tgsi,
|
||||||
const struct st_basic_variant_key *key);
|
struct st_basic_variant **variants);
|
||||||
|
|
||||||
extern struct st_basic_variant *
|
|
||||||
st_get_tcp_variant(struct st_context *st,
|
|
||||||
struct st_tessctrl_program *sttcp,
|
|
||||||
const struct st_basic_variant_key *key);
|
|
||||||
|
|
||||||
extern struct st_basic_variant *
|
|
||||||
st_get_tep_variant(struct st_context *st,
|
|
||||||
struct st_tesseval_program *sttep,
|
|
||||||
const struct st_basic_variant_key *key);
|
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
st_release_vp_variants( struct st_context *st,
|
st_release_vp_variants( struct st_context *st,
|
||||||
|
Reference in New Issue
Block a user