radeonsi: simplify checking for monolithic compilation
authorMarek Olšák <marek.olsak@amd.com>
Sun, 13 Nov 2016 18:21:46 +0000 (19:21 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 21 Nov 2016 20:44:35 +0000 (21:44 +0100)
Tested-by: Edmondo Tommasina <edmondo.tommasina@gmail.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeonsi/si_compute.c
src/gallium/drivers/radeonsi/si_shader.c
src/gallium/drivers/radeonsi/si_shader.h
src/gallium/drivers/radeonsi/si_state_shaders.c

index e53ffa4cc7261dfbb088112477f2b7a5e75fedad..91f1b0a7420bf86bd5b2b3a8edd926667544c9e1 100644 (file)
@@ -126,6 +126,7 @@ static void *si_create_compute_state(
                p_atomic_inc(&sscreen->b.num_shaders_created);
 
                program->shader.selector = &sel;
+               program->shader.is_monolithic = true;
 
                if (si_shader_create(sscreen, sctx->tm, &program->shader,
                                     &sctx->b.debug)) {
index 6d3365ce252a1157f1fefb1b16d21c7988f8f66a..5e57bb3b6644558f745b61034b22cc314a60cf1e 100644 (file)
@@ -8139,14 +8139,7 @@ int si_shader_create(struct si_screen *sscreen, LLVMTargetMachineRef tm,
         * Vertex shaders are compiled on demand when a vertex fetch
         * workaround must be applied.
         */
-       if (!mainp ||
-           shader->key.as_es != mainp->key.as_es ||
-           shader->key.as_ls != mainp->key.as_ls ||
-           (sel->type == PIPE_SHADER_VERTEX &&
-            shader->key.mono.vs.fix_fetch) ||
-           (sel->type == PIPE_SHADER_TESS_CTRL &&
-            shader->key.mono.tcs.inputs_to_copy) ||
-           sel->type == PIPE_SHADER_COMPUTE) {
+       if (shader->is_monolithic) {
                /* Monolithic shader (compiled as a whole, has many variants,
                 * may take a long time to compile).
                 */
index bed22c1cf0098222aaa753ddbe1ec3c51561d13b..2ed0cb783ff661b0570dfd025ad1b9ab6e040b99 100644 (file)
@@ -484,6 +484,7 @@ struct si_shader {
        struct r600_resource            *bo;
        struct r600_resource            *scratch_bo;
        struct si_shader_key            key;
+       bool                            is_monolithic;
        bool                            is_binary_shared;
        bool                            is_gs_copy_shader;
 
index 3323d3c3a33d897d876d6d70e1273450a1cd3177..9df8f47e6243c7f79a2519eeb9fac9b5ecd34283 100644 (file)
@@ -1024,6 +1024,7 @@ static int si_shader_select_with_key(struct si_screen *sscreen,
                                     bool wait,
                                     bool is_debug_context)
 {
+       static const struct si_shader_key zeroed;
        struct si_shader_selector *sel = state->cso;
        struct si_shader *current = state->current;
        struct si_shader *iter, *shader = NULL;
@@ -1064,6 +1065,11 @@ static int si_shader_select_with_key(struct si_screen *sscreen,
        }
        shader->selector = sel;
        shader->key = *key;
+       shader->is_monolithic =
+               !sel->main_shader_part ||
+               sel->main_shader_part->key.as_ls != key->as_ls ||
+               sel->main_shader_part->key.as_es != key->as_es ||
+               memcmp(&key->mono, &zeroed.mono, sizeof(key->mono)) != 0;
 
        r = si_shader_create(sscreen, tm, shader, debug);
        if (unlikely(r)) {