st/mesa: merge st_fragment_program into st_common_program
Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
parent
e94da4ab80
commit
48b4843c30
|
@ -541,7 +541,7 @@ void
|
||||||
st_init_atifs_prog(struct gl_context *ctx, struct gl_program *prog)
|
st_init_atifs_prog(struct gl_context *ctx, struct gl_program *prog)
|
||||||
{
|
{
|
||||||
/* we know this is st_fragment_program, because of st_new_ati_fs() */
|
/* we know this is st_fragment_program, because of st_new_ati_fs() */
|
||||||
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
|
struct st_common_program *stfp = (struct st_common_program *) prog;
|
||||||
struct ati_fragment_shader *atifs = stfp->ati_fs;
|
struct ati_fragment_shader *atifs = stfp->ati_fs;
|
||||||
|
|
||||||
unsigned pass, i, r, optype, arg;
|
unsigned pass, i, r, optype, arg;
|
||||||
|
|
|
@ -71,7 +71,7 @@ static void check_program_state( struct st_context *st )
|
||||||
struct st_common_program *old_tcp = st->tcp;
|
struct st_common_program *old_tcp = st->tcp;
|
||||||
struct st_common_program *old_tep = st->tep;
|
struct st_common_program *old_tep = st->tep;
|
||||||
struct st_common_program *old_gp = st->gp;
|
struct st_common_program *old_gp = st->gp;
|
||||||
struct st_fragment_program *old_fp = st->fp;
|
struct st_common_program *old_fp = st->fp;
|
||||||
|
|
||||||
struct gl_program *new_vp = ctx->VertexProgram._Current;
|
struct gl_program *new_vp = ctx->VertexProgram._Current;
|
||||||
struct gl_program *new_tcp = ctx->TessCtrlProgram._Current;
|
struct gl_program *new_tcp = ctx->TessCtrlProgram._Current;
|
||||||
|
@ -116,7 +116,7 @@ static void check_program_state( struct st_context *st )
|
||||||
if (old_fp)
|
if (old_fp)
|
||||||
dirty |= old_fp->affected_states;
|
dirty |= old_fp->affected_states;
|
||||||
if (new_fp)
|
if (new_fp)
|
||||||
dirty |= st_fragment_program(new_fp)->affected_states;
|
dirty |= st_common_program(new_fp)->affected_states;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Find out the number of viewports. This determines how many scissors
|
/* Find out the number of viewports. This determines how many scissors
|
||||||
|
|
|
@ -98,10 +98,10 @@ get_texture_target(struct gl_context *ctx, const unsigned unit)
|
||||||
void
|
void
|
||||||
st_update_fp( struct st_context *st )
|
st_update_fp( struct st_context *st )
|
||||||
{
|
{
|
||||||
struct st_fragment_program *stfp;
|
struct st_common_program *stfp;
|
||||||
|
|
||||||
assert(st->ctx->FragmentProgram._Current);
|
assert(st->ctx->FragmentProgram._Current);
|
||||||
stfp = st_fragment_program(st->ctx->FragmentProgram._Current);
|
stfp = st_common_program(st->ctx->FragmentProgram._Current);
|
||||||
assert(stfp->Base.Target == GL_FRAGMENT_PROGRAM_ARB);
|
assert(stfp->Base.Target == GL_FRAGMENT_PROGRAM_ARB);
|
||||||
|
|
||||||
void *shader;
|
void *shader;
|
||||||
|
@ -109,10 +109,10 @@ st_update_fp( struct st_context *st )
|
||||||
if (st->shader_has_one_variant[MESA_SHADER_FRAGMENT] &&
|
if (st->shader_has_one_variant[MESA_SHADER_FRAGMENT] &&
|
||||||
!stfp->ati_fs && /* ATI_fragment_shader always has multiple variants */
|
!stfp->ati_fs && /* ATI_fragment_shader always has multiple variants */
|
||||||
!stfp->Base.ExternalSamplersUsed && /* external samplers need variants */
|
!stfp->Base.ExternalSamplersUsed && /* external samplers need variants */
|
||||||
stfp->variants &&
|
stfp->fp_variants &&
|
||||||
!stfp->variants->key.drawpixels &&
|
!stfp->fp_variants->key.drawpixels &&
|
||||||
!stfp->variants->key.bitmap) {
|
!stfp->fp_variants->key.bitmap) {
|
||||||
shader = stfp->variants->driver_shader;
|
shader = stfp->fp_variants->driver_shader;
|
||||||
} else {
|
} else {
|
||||||
struct st_fp_variant_key key;
|
struct st_fp_variant_key key;
|
||||||
|
|
||||||
|
@ -163,7 +163,7 @@ st_update_fp( struct st_context *st )
|
||||||
shader = st_get_fp_variant(st, stfp, &key)->driver_shader;
|
shader = st_get_fp_variant(st, stfp, &key)->driver_shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
st_reference_fragprog(st, &st->fp, stfp);
|
st_reference_prog(st, &st->fp, stfp);
|
||||||
|
|
||||||
cso_set_fragment_shader_handle(st->cso_context, shader);
|
cso_set_fragment_shader_handle(st->cso_context, shader);
|
||||||
}
|
}
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
struct dd_function_table;
|
struct dd_function_table;
|
||||||
struct st_context;
|
struct st_context;
|
||||||
struct gl_program;
|
struct gl_program;
|
||||||
struct st_fragment_program;
|
struct st_common_program;
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
st_init_bitmap_functions(struct dd_function_table *functions);
|
st_init_bitmap_functions(struct dd_function_table *functions);
|
||||||
|
|
|
@ -64,14 +64,10 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id,
|
||||||
struct st_vertex_program);
|
struct st_vertex_program);
|
||||||
return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
|
return _mesa_init_gl_program(&prog->Base, target, id, is_arb_asm);
|
||||||
}
|
}
|
||||||
case GL_FRAGMENT_PROGRAM_ARB: {
|
|
||||||
struct st_fragment_program *prog = rzalloc(NULL,
|
|
||||||
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_CONTROL_PROGRAM_NV:
|
||||||
case GL_TESS_EVALUATION_PROGRAM_NV:
|
case GL_TESS_EVALUATION_PROGRAM_NV:
|
||||||
case GL_GEOMETRY_PROGRAM_NV:
|
case GL_GEOMETRY_PROGRAM_NV:
|
||||||
|
case GL_FRAGMENT_PROGRAM_ARB:
|
||||||
case GL_COMPUTE_PROGRAM_NV: {
|
case GL_COMPUTE_PROGRAM_NV: {
|
||||||
struct st_common_program *prog = rzalloc(NULL,
|
struct st_common_program *prog = rzalloc(NULL,
|
||||||
struct st_common_program);
|
struct st_common_program);
|
||||||
|
@ -105,27 +101,20 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog)
|
||||||
case GL_TESS_CONTROL_PROGRAM_NV:
|
case GL_TESS_CONTROL_PROGRAM_NV:
|
||||||
case GL_TESS_EVALUATION_PROGRAM_NV:
|
case GL_TESS_EVALUATION_PROGRAM_NV:
|
||||||
case GL_GEOMETRY_PROGRAM_NV:
|
case GL_GEOMETRY_PROGRAM_NV:
|
||||||
|
case GL_FRAGMENT_PROGRAM_ARB:
|
||||||
case GL_COMPUTE_PROGRAM_NV:
|
case GL_COMPUTE_PROGRAM_NV:
|
||||||
{
|
{
|
||||||
struct st_common_program *p = st_common_program(prog);
|
struct st_common_program *p = st_common_program(prog);
|
||||||
|
|
||||||
st_release_common_variants(st, p);
|
if (prog->Target == GL_FRAGMENT_PROGRAM_ARB)
|
||||||
|
st_release_fp_variants(st, p);
|
||||||
|
else
|
||||||
|
st_release_common_variants(st, p);
|
||||||
|
|
||||||
if (p->glsl_to_tgsi)
|
if (p->glsl_to_tgsi)
|
||||||
free_glsl_to_tgsi_visitor(p->glsl_to_tgsi);
|
free_glsl_to_tgsi_visitor(p->glsl_to_tgsi);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case GL_FRAGMENT_PROGRAM_ARB:
|
|
||||||
{
|
|
||||||
struct st_fragment_program *stfp =
|
|
||||||
(struct st_fragment_program *) prog;
|
|
||||||
|
|
||||||
st_release_fp_variants(st, stfp);
|
|
||||||
|
|
||||||
if (stfp->glsl_to_tgsi)
|
|
||||||
free_glsl_to_tgsi_visitor(stfp->glsl_to_tgsi);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
assert(0); /* problem */
|
assert(0); /* problem */
|
||||||
}
|
}
|
||||||
|
@ -150,7 +139,7 @@ st_program_string_notify( struct gl_context *ctx,
|
||||||
|
|
||||||
if (target == GL_FRAGMENT_PROGRAM_ARB ||
|
if (target == GL_FRAGMENT_PROGRAM_ARB ||
|
||||||
target == GL_FRAGMENT_SHADER_ATI) {
|
target == GL_FRAGMENT_SHADER_ATI) {
|
||||||
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
|
struct st_common_program *stfp = (struct st_common_program *) prog;
|
||||||
|
|
||||||
if (target == GL_FRAGMENT_SHADER_ATI) {
|
if (target == GL_FRAGMENT_SHADER_ATI) {
|
||||||
assert(stfp->ati_fs);
|
assert(stfp->ati_fs);
|
||||||
|
@ -207,7 +196,7 @@ st_new_ati_fs(struct gl_context *ctx, struct ati_fragment_shader *curProg)
|
||||||
{
|
{
|
||||||
struct gl_program *prog = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
|
struct gl_program *prog = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
|
||||||
curProg->Id, true);
|
curProg->Id, true);
|
||||||
struct st_fragment_program *stfp = (struct st_fragment_program *)prog;
|
struct st_common_program *stfp = (struct st_common_program *)prog;
|
||||||
stfp->ati_fs = curProg;
|
stfp->ati_fs = curProg;
|
||||||
return prog;
|
return prog;
|
||||||
}
|
}
|
||||||
|
@ -243,8 +232,8 @@ st_get_shader_program_completion_status(struct gl_context *ctx,
|
||||||
sh = st_vertex_program(linked->Program)->variants->driver_shader;
|
sh = st_vertex_program(linked->Program)->variants->driver_shader;
|
||||||
break;
|
break;
|
||||||
case MESA_SHADER_FRAGMENT:
|
case MESA_SHADER_FRAGMENT:
|
||||||
if (st_fragment_program(linked->Program)->variants)
|
if (st_common_program(linked->Program)->fp_variants)
|
||||||
sh = st_fragment_program(linked->Program)->variants->driver_shader;
|
sh = st_common_program(linked->Program)->fp_variants->driver_shader;
|
||||||
break;
|
break;
|
||||||
case MESA_SHADER_TESS_CTRL:
|
case MESA_SHADER_TESS_CTRL:
|
||||||
case MESA_SHADER_TESS_EVAL:
|
case MESA_SHADER_TESS_EVAL:
|
||||||
|
|
|
@ -145,8 +145,8 @@ st_get_active_states(struct gl_context *ctx)
|
||||||
st_common_program(ctx->TessEvalProgram._Current);
|
st_common_program(ctx->TessEvalProgram._Current);
|
||||||
struct st_common_program *gp =
|
struct st_common_program *gp =
|
||||||
st_common_program(ctx->GeometryProgram._Current);
|
st_common_program(ctx->GeometryProgram._Current);
|
||||||
struct st_fragment_program *fp =
|
struct st_common_program *fp =
|
||||||
st_fragment_program(ctx->FragmentProgram._Current);
|
st_common_program(ctx->FragmentProgram._Current);
|
||||||
struct st_common_program *cp =
|
struct st_common_program *cp =
|
||||||
st_common_program(ctx->ComputeProgram._Current);
|
st_common_program(ctx->ComputeProgram._Current);
|
||||||
uint64_t active_shader_states = 0;
|
uint64_t active_shader_states = 0;
|
||||||
|
@ -1041,7 +1041,7 @@ st_destroy_context(struct st_context *st)
|
||||||
simple_mtx_destroy(&st->zombie_sampler_views.mutex);
|
simple_mtx_destroy(&st->zombie_sampler_views.mutex);
|
||||||
simple_mtx_destroy(&st->zombie_shaders.mutex);
|
simple_mtx_destroy(&st->zombie_shaders.mutex);
|
||||||
|
|
||||||
st_reference_fragprog(st, &st->fp, NULL);
|
st_reference_prog(st, &st->fp, NULL);
|
||||||
st_reference_prog(st, &st->gp, NULL);
|
st_reference_prog(st, &st->gp, NULL);
|
||||||
st_reference_vertprog(st, &st->vp, NULL);
|
st_reference_vertprog(st, &st->vp, NULL);
|
||||||
st_reference_prog(st, &st->tcp, NULL);
|
st_reference_prog(st, &st->tcp, NULL);
|
||||||
|
|
|
@ -50,7 +50,7 @@ struct draw_context;
|
||||||
struct draw_stage;
|
struct draw_stage;
|
||||||
struct gen_mipmap_state;
|
struct gen_mipmap_state;
|
||||||
struct st_context;
|
struct st_context;
|
||||||
struct st_fragment_program;
|
struct st_common_program;
|
||||||
struct st_perf_monitor_group;
|
struct st_perf_monitor_group;
|
||||||
struct u_upload_mgr;
|
struct u_upload_mgr;
|
||||||
|
|
||||||
|
@ -234,7 +234,7 @@ struct st_context
|
||||||
unsigned active_queries;
|
unsigned active_queries;
|
||||||
|
|
||||||
struct st_vertex_program *vp; /**< Currently bound vertex program */
|
struct st_vertex_program *vp; /**< Currently bound vertex program */
|
||||||
struct st_fragment_program *fp; /**< Currently bound fragment program */
|
struct st_common_program *fp; /**< Currently bound fragment program */
|
||||||
struct st_common_program *gp; /**< Currently bound geometry program */
|
struct st_common_program *gp; /**< Currently bound geometry program */
|
||||||
struct st_common_program *tcp; /**< Currently bound tess control program */
|
struct st_common_program *tcp; /**< Currently bound tess control program */
|
||||||
struct st_common_program *tep; /**< Currently bound tess eval program */
|
struct st_common_program *tep; /**< Currently bound tess eval program */
|
||||||
|
|
|
@ -503,7 +503,6 @@ set_st_program(struct gl_program *prog,
|
||||||
{
|
{
|
||||||
struct st_vertex_program *stvp;
|
struct st_vertex_program *stvp;
|
||||||
struct st_common_program *stp;
|
struct st_common_program *stp;
|
||||||
struct st_fragment_program *stfp;
|
|
||||||
|
|
||||||
switch (prog->info.stage) {
|
switch (prog->info.stage) {
|
||||||
case MESA_SHADER_VERTEX:
|
case MESA_SHADER_VERTEX:
|
||||||
|
@ -516,17 +515,12 @@ set_st_program(struct gl_program *prog,
|
||||||
case MESA_SHADER_TESS_CTRL:
|
case MESA_SHADER_TESS_CTRL:
|
||||||
case MESA_SHADER_TESS_EVAL:
|
case MESA_SHADER_TESS_EVAL:
|
||||||
case MESA_SHADER_COMPUTE:
|
case MESA_SHADER_COMPUTE:
|
||||||
|
case MESA_SHADER_FRAGMENT:
|
||||||
stp = (struct st_common_program *)prog;
|
stp = (struct st_common_program *)prog;
|
||||||
stp->shader_program = shader_program;
|
stp->shader_program = shader_program;
|
||||||
stp->state.type = PIPE_SHADER_IR_NIR;
|
stp->state.type = PIPE_SHADER_IR_NIR;
|
||||||
stp->state.ir.nir = nir;
|
stp->state.ir.nir = nir;
|
||||||
break;
|
break;
|
||||||
case MESA_SHADER_FRAGMENT:
|
|
||||||
stfp = (struct st_fragment_program *)prog;
|
|
||||||
stfp->shader_program = shader_program;
|
|
||||||
stfp->state.type = PIPE_SHADER_IR_NIR;
|
|
||||||
stfp->state.ir.nir = nir;
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
unreachable("unknown shader stage");
|
unreachable("unknown shader stage");
|
||||||
}
|
}
|
||||||
|
|
|
@ -7309,7 +7309,6 @@ get_mesa_program_tgsi(struct gl_context *ctx,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct st_vertex_program *stvp;
|
struct st_vertex_program *stvp;
|
||||||
struct st_fragment_program *stfp;
|
|
||||||
struct st_common_program *stp;
|
struct st_common_program *stp;
|
||||||
|
|
||||||
switch (shader->Stage) {
|
switch (shader->Stage) {
|
||||||
|
@ -7318,9 +7317,6 @@ get_mesa_program_tgsi(struct gl_context *ctx,
|
||||||
stvp->glsl_to_tgsi = v;
|
stvp->glsl_to_tgsi = v;
|
||||||
break;
|
break;
|
||||||
case MESA_SHADER_FRAGMENT:
|
case MESA_SHADER_FRAGMENT:
|
||||||
stfp = (struct st_fragment_program *)prog;
|
|
||||||
stfp->glsl_to_tgsi = v;
|
|
||||||
break;
|
|
||||||
case MESA_SHADER_TESS_CTRL:
|
case MESA_SHADER_TESS_CTRL:
|
||||||
case MESA_SHADER_TESS_EVAL:
|
case MESA_SHADER_TESS_EVAL:
|
||||||
case MESA_SHADER_GEOMETRY:
|
case MESA_SHADER_GEOMETRY:
|
||||||
|
|
|
@ -170,7 +170,7 @@ st_set_prog_affected_state_flags(struct gl_program *prog)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case MESA_SHADER_FRAGMENT:
|
case MESA_SHADER_FRAGMENT:
|
||||||
states = &((struct st_fragment_program*)prog)->affected_states;
|
states = &((struct st_common_program*)prog)->affected_states;
|
||||||
|
|
||||||
/* gl_FragCoord and glDrawPixels always use constants. */
|
/* gl_FragCoord and glDrawPixels always use constants. */
|
||||||
*states = ST_NEW_FS_STATE |
|
*states = ST_NEW_FS_STATE |
|
||||||
|
@ -297,17 +297,17 @@ delete_fp_variant(struct st_context *st, struct st_fp_variant *fpv)
|
||||||
* Free all variants of a fragment program.
|
* Free all variants of a fragment program.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
st_release_fp_variants(struct st_context *st, struct st_fragment_program *stfp)
|
st_release_fp_variants(struct st_context *st, struct st_common_program *stfp)
|
||||||
{
|
{
|
||||||
struct st_fp_variant *fpv;
|
struct st_fp_variant *fpv;
|
||||||
|
|
||||||
for (fpv = stfp->variants; fpv; ) {
|
for (fpv = stfp->fp_variants; fpv; ) {
|
||||||
struct st_fp_variant *next = fpv->next;
|
struct st_fp_variant *next = fpv->next;
|
||||||
delete_fp_variant(st, fpv);
|
delete_fp_variant(st, fpv);
|
||||||
fpv = next;
|
fpv = next;
|
||||||
}
|
}
|
||||||
|
|
||||||
stfp->variants = NULL;
|
stfp->fp_variants = NULL;
|
||||||
|
|
||||||
delete_ir(&stfp->state);
|
delete_ir(&stfp->state);
|
||||||
}
|
}
|
||||||
|
@ -798,7 +798,7 @@ st_get_vp_variant(struct st_context *st,
|
||||||
*/
|
*/
|
||||||
bool
|
bool
|
||||||
st_translate_fragment_program(struct st_context *st,
|
st_translate_fragment_program(struct st_context *st,
|
||||||
struct st_fragment_program *stfp)
|
struct st_common_program *stfp)
|
||||||
{
|
{
|
||||||
/* Non-GLSL programs: */
|
/* Non-GLSL programs: */
|
||||||
if (!stfp->glsl_to_tgsi) {
|
if (!stfp->glsl_to_tgsi) {
|
||||||
|
@ -1171,7 +1171,7 @@ st_translate_fragment_program(struct st_context *st,
|
||||||
|
|
||||||
static struct st_fp_variant *
|
static struct st_fp_variant *
|
||||||
st_create_fp_variant(struct st_context *st,
|
st_create_fp_variant(struct st_context *st,
|
||||||
struct st_fragment_program *stfp,
|
struct st_common_program *stfp,
|
||||||
const struct st_fp_variant_key *key)
|
const struct st_fp_variant_key *key)
|
||||||
{
|
{
|
||||||
struct pipe_context *pipe = st->pipe;
|
struct pipe_context *pipe = st->pipe;
|
||||||
|
@ -1437,13 +1437,13 @@ st_create_fp_variant(struct st_context *st,
|
||||||
*/
|
*/
|
||||||
struct st_fp_variant *
|
struct st_fp_variant *
|
||||||
st_get_fp_variant(struct st_context *st,
|
st_get_fp_variant(struct st_context *st,
|
||||||
struct st_fragment_program *stfp,
|
struct st_common_program *stfp,
|
||||||
const struct st_fp_variant_key *key)
|
const struct st_fp_variant_key *key)
|
||||||
{
|
{
|
||||||
struct st_fp_variant *fpv;
|
struct st_fp_variant *fpv;
|
||||||
|
|
||||||
/* Search for existing variant */
|
/* Search for existing variant */
|
||||||
for (fpv = stfp->variants; fpv; fpv = fpv->next) {
|
for (fpv = stfp->fp_variants; fpv; fpv = fpv->next) {
|
||||||
if (memcmp(&fpv->key, key, sizeof(*key)) == 0) {
|
if (memcmp(&fpv->key, key, sizeof(*key)) == 0) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1460,17 +1460,17 @@ st_get_fp_variant(struct st_context *st,
|
||||||
* st_update_fp can take a fast path when
|
* st_update_fp can take a fast path when
|
||||||
* shader_has_one_variant is set.
|
* shader_has_one_variant is set.
|
||||||
*/
|
*/
|
||||||
if (!stfp->variants) {
|
if (!stfp->fp_variants) {
|
||||||
stfp->variants = fpv;
|
stfp->fp_variants = fpv;
|
||||||
} else {
|
} else {
|
||||||
/* insert into list after the first one */
|
/* insert into list after the first one */
|
||||||
fpv->next = stfp->variants->next;
|
fpv->next = stfp->fp_variants->next;
|
||||||
stfp->variants->next = fpv;
|
stfp->fp_variants->next = fpv;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* insert into list */
|
/* insert into list */
|
||||||
fpv->next = stfp->variants;
|
fpv->next = stfp->fp_variants;
|
||||||
stfp->variants = fpv;
|
stfp->fp_variants = fpv;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1804,11 +1804,11 @@ destroy_program_variants(struct st_context *st, struct gl_program *target)
|
||||||
break;
|
break;
|
||||||
case GL_FRAGMENT_PROGRAM_ARB:
|
case GL_FRAGMENT_PROGRAM_ARB:
|
||||||
{
|
{
|
||||||
struct st_fragment_program *stfp =
|
struct st_common_program *stfp =
|
||||||
(struct st_fragment_program *) target;
|
(struct st_common_program *) target;
|
||||||
struct st_fp_variant *fpv, **prevPtr = &stfp->variants;
|
struct st_fp_variant *fpv, **prevPtr = &stfp->fp_variants;
|
||||||
|
|
||||||
for (fpv = stfp->variants; fpv; ) {
|
for (fpv = stfp->fp_variants; fpv; ) {
|
||||||
struct st_fp_variant *next = fpv->next;
|
struct st_fp_variant *next = fpv->next;
|
||||||
if (fpv->key.st == st) {
|
if (fpv->key.st == st) {
|
||||||
/* unlink from list */
|
/* unlink from list */
|
||||||
|
@ -1968,7 +1968,7 @@ st_precompile_shader_variant(struct st_context *st,
|
||||||
}
|
}
|
||||||
|
|
||||||
case GL_FRAGMENT_PROGRAM_ARB: {
|
case GL_FRAGMENT_PROGRAM_ARB: {
|
||||||
struct st_fragment_program *p = (struct st_fragment_program *)prog;
|
struct st_common_program *p = (struct st_common_program *)prog;
|
||||||
struct st_fp_variant_key key;
|
struct st_fp_variant_key key;
|
||||||
|
|
||||||
memset(&key, 0, sizeof(key));
|
memset(&key, 0, sizeof(key));
|
||||||
|
|
|
@ -162,24 +162,6 @@ struct st_fp_variant
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Derived from Mesa gl_program:
|
|
||||||
*/
|
|
||||||
struct st_fragment_program
|
|
||||||
{
|
|
||||||
struct gl_program Base;
|
|
||||||
struct pipe_shader_state state;
|
|
||||||
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
|
|
||||||
struct ati_fragment_shader *ati_fs;
|
|
||||||
uint64_t affected_states; /**< ST_NEW_* flags to mark dirty when binding */
|
|
||||||
|
|
||||||
/* used when bypassing glsl_to_tgsi: */
|
|
||||||
struct gl_shader_program *shader_program;
|
|
||||||
|
|
||||||
struct st_fp_variant *variants;
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
/** Shader key shared by other shaders */
|
/** Shader key shared by other shaders */
|
||||||
struct st_common_variant_key
|
struct st_common_variant_key
|
||||||
{
|
{
|
||||||
|
@ -285,22 +267,19 @@ struct st_common_program
|
||||||
struct gl_program Base;
|
struct gl_program Base;
|
||||||
struct pipe_shader_state state;
|
struct pipe_shader_state state;
|
||||||
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
|
struct glsl_to_tgsi_visitor* glsl_to_tgsi;
|
||||||
|
struct ati_fragment_shader *ati_fs;
|
||||||
uint64_t affected_states; /**< ST_NEW_* flags to mark dirty when binding */
|
uint64_t affected_states; /**< ST_NEW_* flags to mark dirty when binding */
|
||||||
|
|
||||||
/* used when bypassing glsl_to_tgsi: */
|
/* used when bypassing glsl_to_tgsi: */
|
||||||
struct gl_shader_program *shader_program;
|
struct gl_shader_program *shader_program;
|
||||||
|
|
||||||
struct st_common_variant *variants;
|
union {
|
||||||
|
struct st_common_variant *variants;
|
||||||
|
struct st_fp_variant *fp_variants;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
static inline struct st_fragment_program *
|
|
||||||
st_fragment_program( struct gl_program *fp )
|
|
||||||
{
|
|
||||||
return (struct st_fragment_program *)fp;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static inline struct st_vertex_program *
|
static inline struct st_vertex_program *
|
||||||
st_vertex_program( struct gl_program *vp )
|
st_vertex_program( struct gl_program *vp )
|
||||||
{
|
{
|
||||||
|
@ -323,16 +302,6 @@ st_reference_vertprog(struct st_context *st,
|
||||||
(struct gl_program *) prog);
|
(struct gl_program *) prog);
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void
|
|
||||||
st_reference_fragprog(struct st_context *st,
|
|
||||||
struct st_fragment_program **ptr,
|
|
||||||
struct st_fragment_program *prog)
|
|
||||||
{
|
|
||||||
_mesa_reference_program(st->ctx,
|
|
||||||
(struct gl_program **) ptr,
|
|
||||||
(struct gl_program *) prog);
|
|
||||||
}
|
|
||||||
|
|
||||||
static inline void
|
static inline void
|
||||||
st_reference_prog(struct st_context *st,
|
st_reference_prog(struct st_context *st,
|
||||||
struct st_common_program **ptr,
|
struct st_common_program **ptr,
|
||||||
|
@ -364,7 +333,7 @@ st_get_vp_variant(struct st_context *st,
|
||||||
|
|
||||||
extern struct st_fp_variant *
|
extern struct st_fp_variant *
|
||||||
st_get_fp_variant(struct st_context *st,
|
st_get_fp_variant(struct st_context *st,
|
||||||
struct st_fragment_program *stfp,
|
struct st_common_program *stfp,
|
||||||
const struct st_fp_variant_key *key);
|
const struct st_fp_variant_key *key);
|
||||||
|
|
||||||
extern struct st_common_variant *
|
extern struct st_common_variant *
|
||||||
|
@ -378,7 +347,7 @@ st_release_vp_variants( struct st_context *st,
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
st_release_fp_variants( struct st_context *st,
|
st_release_fp_variants( struct st_context *st,
|
||||||
struct st_fragment_program *stfp );
|
struct st_common_program *stfp );
|
||||||
|
|
||||||
extern void
|
extern void
|
||||||
st_release_common_variants(struct st_context *st, struct st_common_program *p);
|
st_release_common_variants(struct st_context *st, struct st_common_program *p);
|
||||||
|
@ -398,7 +367,7 @@ st_translate_vertex_program(struct st_context *st,
|
||||||
|
|
||||||
extern bool
|
extern bool
|
||||||
st_translate_fragment_program(struct st_context *st,
|
st_translate_fragment_program(struct st_context *st,
|
||||||
struct st_fragment_program *stfp);
|
struct st_common_program *stfp);
|
||||||
|
|
||||||
extern bool
|
extern bool
|
||||||
st_translate_common_program(struct st_context *st,
|
st_translate_common_program(struct st_context *st,
|
||||||
|
|
|
@ -107,6 +107,7 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog,
|
||||||
case MESA_SHADER_TESS_CTRL:
|
case MESA_SHADER_TESS_CTRL:
|
||||||
case MESA_SHADER_TESS_EVAL:
|
case MESA_SHADER_TESS_EVAL:
|
||||||
case MESA_SHADER_GEOMETRY:
|
case MESA_SHADER_GEOMETRY:
|
||||||
|
case MESA_SHADER_FRAGMENT:
|
||||||
case MESA_SHADER_COMPUTE: {
|
case MESA_SHADER_COMPUTE: {
|
||||||
struct st_common_program *stcp = (struct st_common_program *) prog;
|
struct st_common_program *stcp = (struct st_common_program *) prog;
|
||||||
|
|
||||||
|
@ -120,15 +121,6 @@ st_serialise_ir_program(struct gl_context *ctx, struct gl_program *prog,
|
||||||
write_tgsi_to_cache(&blob, stcp->state.tokens, prog);
|
write_tgsi_to_cache(&blob, stcp->state.tokens, prog);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MESA_SHADER_FRAGMENT: {
|
|
||||||
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
|
|
||||||
|
|
||||||
if (nir)
|
|
||||||
write_nir_to_cache(&blob, prog);
|
|
||||||
else
|
|
||||||
write_tgsi_to_cache(&blob, stfp->state.tokens, prog);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
unreachable("Unsupported stage");
|
unreachable("Unsupported stage");
|
||||||
}
|
}
|
||||||
|
@ -228,10 +220,14 @@ st_deserialise_ir_program(struct gl_context *ctx,
|
||||||
case MESA_SHADER_TESS_CTRL:
|
case MESA_SHADER_TESS_CTRL:
|
||||||
case MESA_SHADER_TESS_EVAL:
|
case MESA_SHADER_TESS_EVAL:
|
||||||
case MESA_SHADER_GEOMETRY:
|
case MESA_SHADER_GEOMETRY:
|
||||||
|
case MESA_SHADER_FRAGMENT:
|
||||||
case MESA_SHADER_COMPUTE: {
|
case MESA_SHADER_COMPUTE: {
|
||||||
struct st_common_program *stcp = st_common_program(prog);
|
struct st_common_program *stcp = st_common_program(prog);
|
||||||
|
|
||||||
st_release_common_variants(st, stcp);
|
if (prog->info.stage == MESA_SHADER_FRAGMENT)
|
||||||
|
st_release_fp_variants(st, stcp);
|
||||||
|
else
|
||||||
|
st_release_common_variants(st, stcp);
|
||||||
|
|
||||||
if (prog->info.stage == MESA_SHADER_TESS_EVAL ||
|
if (prog->info.stage == MESA_SHADER_TESS_EVAL ||
|
||||||
prog->info.stage == MESA_SHADER_GEOMETRY)
|
prog->info.stage == MESA_SHADER_GEOMETRY)
|
||||||
|
@ -249,29 +245,11 @@ st_deserialise_ir_program(struct gl_context *ctx,
|
||||||
if ((prog->info.stage == MESA_SHADER_TESS_CTRL && st->tcp == stcp) ||
|
if ((prog->info.stage == MESA_SHADER_TESS_CTRL && st->tcp == stcp) ||
|
||||||
(prog->info.stage == MESA_SHADER_TESS_EVAL && st->tep == stcp) ||
|
(prog->info.stage == MESA_SHADER_TESS_EVAL && st->tep == stcp) ||
|
||||||
(prog->info.stage == MESA_SHADER_GEOMETRY && st->gp == stcp) ||
|
(prog->info.stage == MESA_SHADER_GEOMETRY && st->gp == stcp) ||
|
||||||
|
(prog->info.stage == MESA_SHADER_FRAGMENT && st->fp == stcp) ||
|
||||||
(prog->info.stage == MESA_SHADER_COMPUTE && st->cp == stcp))
|
(prog->info.stage == MESA_SHADER_COMPUTE && st->cp == stcp))
|
||||||
st->dirty |= stcp->affected_states;
|
st->dirty |= stcp->affected_states;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MESA_SHADER_FRAGMENT: {
|
|
||||||
struct st_fragment_program *stfp = (struct st_fragment_program *) prog;
|
|
||||||
|
|
||||||
st_release_fp_variants(st, stfp);
|
|
||||||
|
|
||||||
if (nir) {
|
|
||||||
stfp->state.type = PIPE_SHADER_IR_NIR;
|
|
||||||
stfp->shader_program = shProg;
|
|
||||||
stfp->state.ir.nir = nir_deserialize(NULL, options, &blob_reader);
|
|
||||||
prog->nir = stfp->state.ir.nir;
|
|
||||||
} else {
|
|
||||||
read_tgsi_from_cache(&blob_reader, &stfp->state.tokens);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (st->fp == stfp)
|
|
||||||
st->dirty |= stfp->affected_states;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
unreachable("Unsupported stage");
|
unreachable("Unsupported stage");
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue