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() */
- 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;
unsigned pass, i, r, optype, arg;
struct st_common_program *old_tcp = st->tcp;
struct st_common_program *old_tep = st->tep;
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_tcp = ctx->TessCtrlProgram._Current;
if (old_fp)
dirty |= old_fp->affected_states;
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
void
st_update_fp( struct st_context *st )
{
- struct st_fragment_program *stfp;
+ struct st_common_program *stfp;
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);
void *shader;
if (st->shader_has_one_variant[MESA_SHADER_FRAGMENT] &&
!stfp->ati_fs && /* ATI_fragment_shader always has multiple variants */
!stfp->Base.ExternalSamplersUsed && /* external samplers need variants */
- stfp->variants &&
- !stfp->variants->key.drawpixels &&
- !stfp->variants->key.bitmap) {
- shader = stfp->variants->driver_shader;
+ stfp->fp_variants &&
+ !stfp->fp_variants->key.drawpixels &&
+ !stfp->fp_variants->key.bitmap) {
+ shader = stfp->fp_variants->driver_shader;
} else {
struct st_fp_variant_key key;
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);
}
struct dd_function_table;
struct st_context;
struct gl_program;
-struct st_fragment_program;
+struct st_common_program;
extern void
st_init_bitmap_functions(struct dd_function_table *functions);
struct st_vertex_program);
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_EVALUATION_PROGRAM_NV:
case GL_GEOMETRY_PROGRAM_NV:
+ case GL_FRAGMENT_PROGRAM_ARB:
case GL_COMPUTE_PROGRAM_NV: {
struct st_common_program *prog = rzalloc(NULL,
struct st_common_program);
case GL_TESS_CONTROL_PROGRAM_NV:
case GL_TESS_EVALUATION_PROGRAM_NV:
case GL_GEOMETRY_PROGRAM_NV:
+ case GL_FRAGMENT_PROGRAM_ARB:
case GL_COMPUTE_PROGRAM_NV:
{
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)
free_glsl_to_tgsi_visitor(p->glsl_to_tgsi);
}
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:
assert(0); /* problem */
}
if (target == GL_FRAGMENT_PROGRAM_ARB ||
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) {
assert(stfp->ati_fs);
{
struct gl_program *prog = ctx->Driver.NewProgram(ctx, GL_FRAGMENT_PROGRAM_ARB,
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;
return prog;
}
sh = st_vertex_program(linked->Program)->variants->driver_shader;
break;
case MESA_SHADER_FRAGMENT:
- if (st_fragment_program(linked->Program)->variants)
- sh = st_fragment_program(linked->Program)->variants->driver_shader;
+ if (st_common_program(linked->Program)->fp_variants)
+ sh = st_common_program(linked->Program)->fp_variants->driver_shader;
break;
case MESA_SHADER_TESS_CTRL:
case MESA_SHADER_TESS_EVAL:
st_common_program(ctx->TessEvalProgram._Current);
struct st_common_program *gp =
st_common_program(ctx->GeometryProgram._Current);
- struct st_fragment_program *fp =
- st_fragment_program(ctx->FragmentProgram._Current);
+ struct st_common_program *fp =
+ st_common_program(ctx->FragmentProgram._Current);
struct st_common_program *cp =
st_common_program(ctx->ComputeProgram._Current);
uint64_t active_shader_states = 0;
simple_mtx_destroy(&st->zombie_sampler_views.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_vertprog(st, &st->vp, NULL);
st_reference_prog(st, &st->tcp, NULL);
struct draw_stage;
struct gen_mipmap_state;
struct st_context;
-struct st_fragment_program;
+struct st_common_program;
struct st_perf_monitor_group;
struct u_upload_mgr;
unsigned active_queries;
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 *tcp; /**< Currently bound tess control program */
struct st_common_program *tep; /**< Currently bound tess eval program */
{
struct st_vertex_program *stvp;
struct st_common_program *stp;
- struct st_fragment_program *stfp;
switch (prog->info.stage) {
case MESA_SHADER_VERTEX:
case MESA_SHADER_TESS_CTRL:
case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_COMPUTE:
+ case MESA_SHADER_FRAGMENT:
stp = (struct st_common_program *)prog;
stp->shader_program = shader_program;
stp->state.type = PIPE_SHADER_IR_NIR;
stp->state.ir.nir = nir;
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:
unreachable("unknown shader stage");
}
}
struct st_vertex_program *stvp;
- struct st_fragment_program *stfp;
struct st_common_program *stp;
switch (shader->Stage) {
stvp->glsl_to_tgsi = v;
break;
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_EVAL:
case MESA_SHADER_GEOMETRY:
break;
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. */
*states = ST_NEW_FS_STATE |
* Free all variants of a fragment program.
*/
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;
- for (fpv = stfp->variants; fpv; ) {
+ for (fpv = stfp->fp_variants; fpv; ) {
struct st_fp_variant *next = fpv->next;
delete_fp_variant(st, fpv);
fpv = next;
}
- stfp->variants = NULL;
+ stfp->fp_variants = NULL;
delete_ir(&stfp->state);
}
*/
bool
st_translate_fragment_program(struct st_context *st,
- struct st_fragment_program *stfp)
+ struct st_common_program *stfp)
{
/* Non-GLSL programs: */
if (!stfp->glsl_to_tgsi) {
static struct st_fp_variant *
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)
{
struct pipe_context *pipe = st->pipe;
*/
struct st_fp_variant *
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)
{
struct st_fp_variant *fpv;
/* 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) {
break;
}
* st_update_fp can take a fast path when
* shader_has_one_variant is set.
*/
- if (!stfp->variants) {
- stfp->variants = fpv;
+ if (!stfp->fp_variants) {
+ stfp->fp_variants = fpv;
} else {
/* insert into list after the first one */
- fpv->next = stfp->variants->next;
- stfp->variants->next = fpv;
+ fpv->next = stfp->fp_variants->next;
+ stfp->fp_variants->next = fpv;
}
} else {
/* insert into list */
- fpv->next = stfp->variants;
- stfp->variants = fpv;
+ fpv->next = stfp->fp_variants;
+ stfp->fp_variants = fpv;
}
}
}
break;
case GL_FRAGMENT_PROGRAM_ARB:
{
- struct st_fragment_program *stfp =
- (struct st_fragment_program *) target;
- struct st_fp_variant *fpv, **prevPtr = &stfp->variants;
+ struct st_common_program *stfp =
+ (struct st_common_program *) target;
+ 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;
if (fpv->key.st == st) {
/* unlink from list */
}
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;
memset(&key, 0, sizeof(key));
};
-/**
- * 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 */
struct st_common_variant_key
{
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_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 *
st_vertex_program( struct gl_program *vp )
{
(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
st_reference_prog(struct st_context *st,
struct st_common_program **ptr,
extern struct st_fp_variant *
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);
extern struct st_common_variant *
extern void
st_release_fp_variants( struct st_context *st,
- struct st_fragment_program *stfp );
+ struct st_common_program *stfp );
extern void
st_release_common_variants(struct st_context *st, struct st_common_program *p);
extern bool
st_translate_fragment_program(struct st_context *st,
- struct st_fragment_program *stfp);
+ struct st_common_program *stfp);
extern bool
st_translate_common_program(struct st_context *st,
case MESA_SHADER_TESS_CTRL:
case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY:
+ case MESA_SHADER_FRAGMENT:
case MESA_SHADER_COMPUTE: {
struct st_common_program *stcp = (struct st_common_program *) prog;
write_tgsi_to_cache(&blob, stcp->state.tokens, prog);
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:
unreachable("Unsupported stage");
}
case MESA_SHADER_TESS_CTRL:
case MESA_SHADER_TESS_EVAL:
case MESA_SHADER_GEOMETRY:
+ case MESA_SHADER_FRAGMENT:
case MESA_SHADER_COMPUTE: {
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 ||
prog->info.stage == MESA_SHADER_GEOMETRY)
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_GEOMETRY && st->gp == stcp) ||
+ (prog->info.stage == MESA_SHADER_FRAGMENT && st->fp == stcp) ||
(prog->info.stage == MESA_SHADER_COMPUTE && st->cp == stcp))
st->dirty |= stcp->affected_states;
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:
unreachable("Unsupported stage");
}