diff options
author | Marek Olšák <[email protected]> | 2019-10-16 16:46:19 -0400 |
---|---|---|
committer | Marek Olšák <[email protected]> | 2019-10-17 20:31:34 -0400 |
commit | 48b4843c30594876f03044a518159f449802959c (patch) | |
tree | eae1aa539810552ece903e4c778360413fe9c6d5 /src/mesa | |
parent | e94da4ab80c189eee6adc833b6fe9bc20ada1e64 (diff) |
st/mesa: merge st_fragment_program into st_common_program
Reviewed-by: Timothy Arceri <[email protected]>
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/state_tracker/st_atifs_to_tgsi.c | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom.c | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_atom_shader.c | 14 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_bitmap.h | 2 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_cb_program.c | 31 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.c | 6 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_context.h | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_nir.cpp | 8 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_glsl_to_tgsi.cpp | 4 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.c | 38 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_program.h | 47 | ||||
-rw-r--r-- | src/mesa/state_tracker/st_shader_cache.c | 36 |
12 files changed, 61 insertions, 135 deletions
diff --git a/src/mesa/state_tracker/st_atifs_to_tgsi.c b/src/mesa/state_tracker/st_atifs_to_tgsi.c index 1180ede35e6..8c6b1fce4d3 100644 --- a/src/mesa/state_tracker/st_atifs_to_tgsi.c +++ b/src/mesa/state_tracker/st_atifs_to_tgsi.c @@ -541,7 +541,7 @@ void 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; diff --git a/src/mesa/state_tracker/st_atom.c b/src/mesa/state_tracker/st_atom.c index 74fe5462544..586d5b670f1 100644 --- a/src/mesa/state_tracker/st_atom.c +++ b/src/mesa/state_tracker/st_atom.c @@ -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_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; @@ -116,7 +116,7 @@ static void check_program_state( struct st_context *st ) 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 diff --git a/src/mesa/state_tracker/st_atom_shader.c b/src/mesa/state_tracker/st_atom_shader.c index 751c9441b20..3aa5de3ec1a 100644 --- a/src/mesa/state_tracker/st_atom_shader.c +++ b/src/mesa/state_tracker/st_atom_shader.c @@ -98,10 +98,10 @@ get_texture_target(struct gl_context *ctx, const unsigned unit) 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; @@ -109,10 +109,10 @@ st_update_fp( struct st_context *st ) 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; @@ -163,7 +163,7 @@ st_update_fp( struct st_context *st ) 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); } diff --git a/src/mesa/state_tracker/st_cb_bitmap.h b/src/mesa/state_tracker/st_cb_bitmap.h index 899f45e4f5d..14e3d930e5b 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.h +++ b/src/mesa/state_tracker/st_cb_bitmap.h @@ -35,7 +35,7 @@ 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); diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c index 8b74214a894..806fbbc7c34 100644 --- a/src/mesa/state_tracker/st_cb_program.c +++ b/src/mesa/state_tracker/st_cb_program.c @@ -64,14 +64,10 @@ st_new_program(struct gl_context *ctx, GLenum target, GLuint id, 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); @@ -105,27 +101,20 @@ st_delete_program(struct gl_context *ctx, struct gl_program *prog) 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 */ } @@ -150,7 +139,7 @@ st_program_string_notify( struct gl_context *ctx, 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); @@ -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, 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; } @@ -243,8 +232,8 @@ st_get_shader_program_completion_status(struct gl_context *ctx, 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: diff --git a/src/mesa/state_tracker/st_context.c b/src/mesa/state_tracker/st_context.c index 549afb3168e..b54afce0d78 100644 --- a/src/mesa/state_tracker/st_context.c +++ b/src/mesa/state_tracker/st_context.c @@ -145,8 +145,8 @@ st_get_active_states(struct gl_context *ctx) 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; @@ -1041,7 +1041,7 @@ st_destroy_context(struct st_context *st) 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); diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index e29e1ed713f..4a265c49e5f 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -50,7 +50,7 @@ struct draw_context; 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; @@ -234,7 +234,7 @@ struct st_context 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 */ diff --git a/src/mesa/state_tracker/st_glsl_to_nir.cpp b/src/mesa/state_tracker/st_glsl_to_nir.cpp index 4ecaa05797f..43459d46b57 100644 --- a/src/mesa/state_tracker/st_glsl_to_nir.cpp +++ b/src/mesa/state_tracker/st_glsl_to_nir.cpp @@ -503,7 +503,6 @@ set_st_program(struct gl_program *prog, { struct st_vertex_program *stvp; struct st_common_program *stp; - struct st_fragment_program *stfp; switch (prog->info.stage) { case MESA_SHADER_VERTEX: @@ -516,17 +515,12 @@ set_st_program(struct gl_program *prog, 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"); } diff --git a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp index 3e73b4dc576..e70762ba152 100644 --- a/src/mesa/state_tracker/st_glsl_to_tgsi.cpp +++ b/src/mesa/state_tracker/st_glsl_to_tgsi.cpp @@ -7309,7 +7309,6 @@ get_mesa_program_tgsi(struct gl_context *ctx, } struct st_vertex_program *stvp; - struct st_fragment_program *stfp; struct st_common_program *stp; switch (shader->Stage) { @@ -7318,9 +7317,6 @@ get_mesa_program_tgsi(struct gl_context *ctx, 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: diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c index b06aa7fc065..9906f652a9e 100644 --- a/src/mesa/state_tracker/st_program.c +++ b/src/mesa/state_tracker/st_program.c @@ -170,7 +170,7 @@ st_set_prog_affected_state_flags(struct gl_program *prog) 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 | @@ -297,17 +297,17 @@ delete_fp_variant(struct st_context *st, struct st_fp_variant *fpv) * 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); } @@ -798,7 +798,7 @@ st_get_vp_variant(struct st_context *st, */ 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) { @@ -1171,7 +1171,7 @@ st_translate_fragment_program(struct st_context *st, 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; @@ -1437,13 +1437,13 @@ st_create_fp_variant(struct st_context *st, */ 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; } @@ -1460,17 +1460,17 @@ st_get_fp_variant(struct st_context *st, * 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; } } } @@ -1804,11 +1804,11 @@ destroy_program_variants(struct st_context *st, struct gl_program *target) 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 */ @@ -1968,7 +1968,7 @@ st_precompile_shader_variant(struct st_context *st, } 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)); diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h index 17271ac7323..ee443628b78 100644 --- a/src/mesa/state_tracker/st_program.h +++ b/src/mesa/state_tracker/st_program.h @@ -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 */ struct st_common_variant_key { @@ -285,22 +267,19 @@ struct st_common_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_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 ) { @@ -324,16 +303,6 @@ st_reference_vertprog(struct st_context *st, } 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, struct st_common_program *prog) @@ -364,7 +333,7 @@ st_get_vp_variant(struct st_context *st, 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 * @@ -378,7 +347,7 @@ st_release_vp_variants( struct st_context *st, 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); @@ -398,7 +367,7 @@ st_translate_vertex_program(struct st_context *st, 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, diff --git a/src/mesa/state_tracker/st_shader_cache.c b/src/mesa/state_tracker/st_shader_cache.c index be334eee759..6f23ec8672a 100644 --- a/src/mesa/state_tracker/st_shader_cache.c +++ b/src/mesa/state_tracker/st_shader_cache.c @@ -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_EVAL: case MESA_SHADER_GEOMETRY: + case MESA_SHADER_FRAGMENT: case MESA_SHADER_COMPUTE: { 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); 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"); } @@ -228,10 +220,14 @@ st_deserialise_ir_program(struct gl_context *ctx, 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) @@ -249,29 +245,11 @@ st_deserialise_ir_program(struct gl_context *ctx, 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"); } |