st/mesa: call st_nir_opts for linked shaders only once

The removed st_nir_opts calls are mostly redundant.

There is an improvement with shader-db on radeonsi:

Before:
    real	1m54.047s
    user	28m37.857s
    sys 	0m7.573s

After:
    real	1m52.012s
    user	28m3.412s
    sys 	0m7.808s

Reviewed-by: Timothy Arceri <tarceri@itsqueeze.com>
This commit is contained in:
Marek Olšák
2019-10-07 22:15:01 -04:00
parent 92252219d3
commit 7908e82f60
+12 -1
View File
@@ -387,7 +387,6 @@ st_nir_preprocess(struct st_context *st, struct gl_program *prog,
/* before buffers and vars_to_ssa */
NIR_PASS_V(nir, gl_nir_lower_bindless_images);
st_nir_opts(nir);
/* TODO: Change GLSL to not lower shared memory. */
if (prog->nir->info.stage == MESA_SHADER_COMPUTE &&
@@ -403,6 +402,9 @@ st_nir_preprocess(struct st_context *st, struct gl_program *prog,
NIR_PASS_V(nir, nir_opt_constant_folding);
if (lower_64bit) {
/* Clean up the IR before 64-bit lowering. */
st_nir_opts(nir);
bool lowered_64bit_ops = false;
if (options->lower_doubles_options) {
NIR_PASS(lowered_64bit_ops, nir, nir_lower_doubles,
@@ -653,6 +655,7 @@ st_link_nir(struct gl_context *ctx,
{
struct st_context *st = st_context(ctx);
struct pipe_screen *screen = st->pipe->screen;
unsigned num_linked_shaders = 0;
unsigned last_stage = 0;
for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
@@ -660,6 +663,8 @@ st_link_nir(struct gl_context *ctx,
if (shader == NULL)
continue;
num_linked_shaders++;
const nir_shader_compiler_options *options =
st->ctx->Const.ShaderCompilerOptions[shader->Stage].NirOptions;
struct gl_program *prog = shader->Program;
@@ -757,6 +762,12 @@ st_link_nir(struct gl_context *ctx,
nir_shader *nir = shader->Program->nir;
/* Linked shaders are optimized in st_nir_link_shaders. Separate shaders
* and shaders with a fixed-func VS or FS are optimized here.
*/
if (num_linked_shaders == 1)
st_nir_opts(nir);
NIR_PASS_V(nir, st_nir_lower_wpos_ytransform, shader->Program,
st->pipe->screen);