st/mesa: translate tessellation shaders into TGSI when we get them
Reviewed-by: Dave Airlie <airlied@redhat.com> Reviewed-by: Brian Paul <brianp@vmware.com> Tested-by: Brian Paul <brianp@vmware.com>
This commit is contained in:
@@ -265,6 +265,8 @@ st_program_string_notify( struct gl_context *ctx,
|
|||||||
(struct st_tessctrl_program *) prog;
|
(struct st_tessctrl_program *) prog;
|
||||||
|
|
||||||
st_release_tcp_variants(st, sttcp);
|
st_release_tcp_variants(st, sttcp);
|
||||||
|
if (!st_translate_tessctrl_program(st, sttcp))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (st->tcp == sttcp)
|
if (st->tcp == sttcp)
|
||||||
st->dirty.st |= ST_NEW_TESSCTRL_PROGRAM;
|
st->dirty.st |= ST_NEW_TESSCTRL_PROGRAM;
|
||||||
@@ -274,6 +276,8 @@ st_program_string_notify( struct gl_context *ctx,
|
|||||||
(struct st_tesseval_program *) prog;
|
(struct st_tesseval_program *) prog;
|
||||||
|
|
||||||
st_release_tep_variants(st, sttep);
|
st_release_tep_variants(st, sttep);
|
||||||
|
if (!st_translate_tesseval_program(st, sttep))
|
||||||
|
return false;
|
||||||
|
|
||||||
if (st->tep == sttep)
|
if (st->tep == sttep)
|
||||||
st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
|
st->dirty.st |= ST_NEW_TESSEVAL_PROGRAM;
|
||||||
|
@@ -207,6 +207,11 @@ st_release_tcp_variants(struct st_context *st, struct st_tessctrl_program *sttcp
|
|||||||
}
|
}
|
||||||
|
|
||||||
sttcp->variants = NULL;
|
sttcp->variants = NULL;
|
||||||
|
|
||||||
|
if (sttcp->tgsi.tokens) {
|
||||||
|
ureg_free_tokens(sttcp->tgsi.tokens);
|
||||||
|
sttcp->tgsi.tokens = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -239,6 +244,11 @@ st_release_tep_variants(struct st_context *st, struct st_tesseval_program *sttep
|
|||||||
}
|
}
|
||||||
|
|
||||||
sttep->variants = NULL;
|
sttep->variants = NULL;
|
||||||
|
|
||||||
|
if (sttep->tgsi.tokens) {
|
||||||
|
ureg_free_tokens(sttep->tgsi.tokens);
|
||||||
|
sttep->tgsi.tokens = NULL;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -1356,38 +1366,40 @@ st_get_gp_variant(struct st_context *st,
|
|||||||
/**
|
/**
|
||||||
* Translate a tessellation control program to create a new variant.
|
* Translate a tessellation control program to create a new variant.
|
||||||
*/
|
*/
|
||||||
static struct st_tcp_variant *
|
bool
|
||||||
st_translate_tessctrl_program(struct st_context *st,
|
st_translate_tessctrl_program(struct st_context *st,
|
||||||
struct st_tessctrl_program *sttcp,
|
struct st_tessctrl_program *sttcp)
|
||||||
const struct st_tcp_variant_key *key)
|
|
||||||
{
|
{
|
||||||
struct pipe_context *pipe = st->pipe;
|
|
||||||
struct ureg_program *ureg;
|
struct ureg_program *ureg;
|
||||||
struct st_tcp_variant *tcpv;
|
|
||||||
struct pipe_shader_state state;
|
|
||||||
|
|
||||||
ureg = ureg_create_with_screen(TGSI_PROCESSOR_TESS_CTRL, pipe->screen);
|
ureg = ureg_create_with_screen(TGSI_PROCESSOR_TESS_CTRL, st->pipe->screen);
|
||||||
if (ureg == NULL) {
|
if (ureg == NULL)
|
||||||
return NULL;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
ureg_property(ureg, TGSI_PROPERTY_TCS_VERTICES_OUT,
|
ureg_property(ureg, TGSI_PROPERTY_TCS_VERTICES_OUT,
|
||||||
sttcp->Base.VerticesOut);
|
sttcp->Base.VerticesOut);
|
||||||
|
|
||||||
st_translate_program_common(st, &sttcp->Base.Base, sttcp->glsl_to_tgsi,
|
st_translate_program_common(st, &sttcp->Base.Base, sttcp->glsl_to_tgsi,
|
||||||
ureg, TGSI_PROCESSOR_TESS_CTRL, &state);
|
ureg, TGSI_PROCESSOR_TESS_CTRL, &sttcp->tgsi);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct st_tcp_variant *
|
||||||
|
st_create_tcp_variant(struct st_context *st,
|
||||||
|
struct st_tessctrl_program *sttcp,
|
||||||
|
const struct st_tcp_variant_key *key)
|
||||||
|
{
|
||||||
|
struct pipe_context *pipe = st->pipe;
|
||||||
|
struct st_tcp_variant *tcpv;
|
||||||
|
|
||||||
tcpv = CALLOC_STRUCT(st_tcp_variant);
|
tcpv = CALLOC_STRUCT(st_tcp_variant);
|
||||||
if (!tcpv) {
|
if (!tcpv)
|
||||||
ureg_free_tokens(state.tokens);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* fill in new variant */
|
/* fill in new variant */
|
||||||
tcpv->driver_shader = pipe->create_tcs_state(pipe, &state);
|
tcpv->driver_shader = pipe->create_tcs_state(pipe, &sttcp->tgsi);
|
||||||
tcpv->key = *key;
|
tcpv->key = *key;
|
||||||
|
|
||||||
ureg_free_tokens(state.tokens);
|
|
||||||
return tcpv;
|
return tcpv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1411,7 +1423,7 @@ st_get_tcp_variant(struct st_context *st,
|
|||||||
|
|
||||||
if (!tcpv) {
|
if (!tcpv) {
|
||||||
/* create new */
|
/* create new */
|
||||||
tcpv = st_translate_tessctrl_program(st, sttcp, key);
|
tcpv = st_create_tcp_variant(st, sttcp, key);
|
||||||
if (tcpv) {
|
if (tcpv) {
|
||||||
/* insert into list */
|
/* insert into list */
|
||||||
tcpv->next = sttcp->variants;
|
tcpv->next = sttcp->variants;
|
||||||
@@ -1426,20 +1438,15 @@ st_get_tcp_variant(struct st_context *st,
|
|||||||
/**
|
/**
|
||||||
* Translate a tessellation evaluation program to create a new variant.
|
* Translate a tessellation evaluation program to create a new variant.
|
||||||
*/
|
*/
|
||||||
static struct st_tep_variant *
|
bool
|
||||||
st_translate_tesseval_program(struct st_context *st,
|
st_translate_tesseval_program(struct st_context *st,
|
||||||
struct st_tesseval_program *sttep,
|
struct st_tesseval_program *sttep)
|
||||||
const struct st_tep_variant_key *key)
|
|
||||||
{
|
{
|
||||||
struct pipe_context *pipe = st->pipe;
|
|
||||||
struct ureg_program *ureg;
|
struct ureg_program *ureg;
|
||||||
struct st_tep_variant *tepv;
|
|
||||||
struct pipe_shader_state state;
|
|
||||||
|
|
||||||
ureg = ureg_create_with_screen(TGSI_PROCESSOR_TESS_EVAL, pipe->screen);
|
ureg = ureg_create_with_screen(TGSI_PROCESSOR_TESS_EVAL, st->pipe->screen);
|
||||||
if (ureg == NULL) {
|
if (ureg == NULL)
|
||||||
return NULL;
|
return false;
|
||||||
}
|
|
||||||
|
|
||||||
if (sttep->Base.PrimitiveMode == GL_ISOLINES)
|
if (sttep->Base.PrimitiveMode == GL_ISOLINES)
|
||||||
ureg_property(ureg, TGSI_PROPERTY_TES_PRIM_MODE, GL_LINES);
|
ureg_property(ureg, TGSI_PROPERTY_TES_PRIM_MODE, GL_LINES);
|
||||||
@@ -1467,19 +1474,26 @@ st_translate_tesseval_program(struct st_context *st,
|
|||||||
ureg_property(ureg, TGSI_PROPERTY_TES_POINT_MODE, sttep->Base.PointMode);
|
ureg_property(ureg, TGSI_PROPERTY_TES_POINT_MODE, sttep->Base.PointMode);
|
||||||
|
|
||||||
st_translate_program_common(st, &sttep->Base.Base, sttep->glsl_to_tgsi,
|
st_translate_program_common(st, &sttep->Base.Base, sttep->glsl_to_tgsi,
|
||||||
ureg, TGSI_PROCESSOR_TESS_EVAL, &state);
|
ureg, TGSI_PROCESSOR_TESS_EVAL, &sttep->tgsi);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static struct st_tep_variant *
|
||||||
|
st_create_tep_variant(struct st_context *st,
|
||||||
|
struct st_tesseval_program *sttep,
|
||||||
|
const struct st_tep_variant_key *key)
|
||||||
|
{
|
||||||
|
struct pipe_context *pipe = st->pipe;
|
||||||
|
struct st_tep_variant *tepv;
|
||||||
|
|
||||||
tepv = CALLOC_STRUCT(st_tep_variant);
|
tepv = CALLOC_STRUCT(st_tep_variant);
|
||||||
if (!tepv) {
|
if (!tepv)
|
||||||
ureg_free_tokens(state.tokens);
|
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
|
||||||
|
|
||||||
/* fill in new variant */
|
/* fill in new variant */
|
||||||
tepv->driver_shader = pipe->create_tes_state(pipe, &state);
|
tepv->driver_shader = pipe->create_tes_state(pipe, &sttep->tgsi);
|
||||||
tepv->key = *key;
|
tepv->key = *key;
|
||||||
|
|
||||||
ureg_free_tokens(state.tokens);
|
|
||||||
return tepv;
|
return tepv;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1503,7 +1517,7 @@ st_get_tep_variant(struct st_context *st,
|
|||||||
|
|
||||||
if (!tepv) {
|
if (!tepv) {
|
||||||
/* create new */
|
/* create new */
|
||||||
tepv = st_translate_tesseval_program(st, sttep, key);
|
tepv = st_create_tep_variant(st, sttep, key);
|
||||||
if (tepv) {
|
if (tepv) {
|
||||||
/* insert into list */
|
/* insert into list */
|
||||||
tepv->next = sttep->variants;
|
tepv->next = sttep->variants;
|
||||||
|
@@ -236,6 +236,7 @@ struct st_tcp_variant
|
|||||||
struct st_tessctrl_program
|
struct st_tessctrl_program
|
||||||
{
|
{
|
||||||
struct gl_tess_ctrl_program Base; /**< The Mesa tess ctrl program */
|
struct gl_tess_ctrl_program Base; /**< The Mesa tess ctrl program */
|
||||||
|
struct pipe_shader_state tgsi;
|
||||||
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
|
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
|
||||||
|
|
||||||
struct st_tcp_variant *variants;
|
struct st_tcp_variant *variants;
|
||||||
@@ -271,6 +272,7 @@ struct st_tep_variant
|
|||||||
struct st_tesseval_program
|
struct st_tesseval_program
|
||||||
{
|
{
|
||||||
struct gl_tess_eval_program Base; /**< The Mesa tess eval program */
|
struct gl_tess_eval_program Base; /**< The Mesa tess eval program */
|
||||||
|
struct pipe_shader_state tgsi;
|
||||||
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
|
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
|
||||||
|
|
||||||
struct st_tep_variant *variants;
|
struct st_tep_variant *variants;
|
||||||
@@ -447,6 +449,14 @@ extern bool
|
|||||||
st_translate_geometry_program(struct st_context *st,
|
st_translate_geometry_program(struct st_context *st,
|
||||||
struct st_geometry_program *stgp);
|
struct st_geometry_program *stgp);
|
||||||
|
|
||||||
|
extern bool
|
||||||
|
st_translate_tessctrl_program(struct st_context *st,
|
||||||
|
struct st_tessctrl_program *sttcp);
|
||||||
|
|
||||||
|
extern bool
|
||||||
|
st_translate_tesseval_program(struct st_context *st,
|
||||||
|
struct st_tesseval_program *sttep);
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
st_print_current_vertex_program(void);
|
st_print_current_vertex_program(void);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user