- if (!ctx->Cache)
- return false;
-
- unsigned char *stage_sha1[MESA_SHADER_STAGES];
- char sha1_buf[41];
-
- /* Compute and store sha1 for each stage. These will be reused by the
- * cache store pass if we fail to find the cached tgsi.
- */
- for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
- if (prog->_LinkedShaders[i] == NULL)
- continue;
-
- char *buf = ralloc_strdup(NULL, "tgsi_tokens ");
- _mesa_sha1_format(sha1_buf,
- prog->_LinkedShaders[i]->Program->sh.data->sha1);
- ralloc_strcat(&buf, sha1_buf);
-
- struct gl_program *glprog = prog->_LinkedShaders[i]->Program;
- switch (glprog->info.stage) {
- case MESA_SHADER_VERTEX: {
- struct st_vertex_program *stvp = (struct st_vertex_program *) glprog;
- stage_sha1[i] = stvp->sha1;
- ralloc_strcat(&buf, " vs");
- disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
- break;
- }
- case MESA_SHADER_TESS_CTRL: {
- struct st_tessctrl_program *stcp =
- (struct st_tessctrl_program *) glprog;
- stage_sha1[i] = stcp->sha1;
- ralloc_strcat(&buf, " tcs");
- disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
- break;
- }
- case MESA_SHADER_TESS_EVAL: {
- struct st_tesseval_program *step =
- (struct st_tesseval_program *) glprog;
- stage_sha1[i] = step->sha1;
- ralloc_strcat(&buf, " tes");
- disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
- break;
- }
- case MESA_SHADER_GEOMETRY: {
- struct st_geometry_program *stgp =
- (struct st_geometry_program *) glprog;
- stage_sha1[i] = stgp->sha1;
- ralloc_strcat(&buf, " gs");
- disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
- break;
- }
- case MESA_SHADER_FRAGMENT: {
- struct st_fragment_program *stfp =
- (struct st_fragment_program *) glprog;
- stage_sha1[i] = stfp->sha1;
- ralloc_strcat(&buf, " fs");
- disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
- break;
- }
- case MESA_SHADER_COMPUTE: {
- struct st_compute_program *stcp =
- (struct st_compute_program *) glprog;
- stage_sha1[i] = stcp->sha1;
- ralloc_strcat(&buf, " cs");
- disk_cache_compute_key(ctx->Cache, buf, strlen(buf), stage_sha1[i]);
- break;
- }
- default:
- unreachable("Unsupported stage");
- }
-
- ralloc_free(buf);
- }
-
- /* Now that we have created the sha1 keys that will be used for writting to
- * the tgsi cache fallback to the regular glsl to tgsi path if we didn't
- * load the GLSL IR from cache. We do this as glsl to tgsi can alter things
- * such as gl_program_parameter_list which holds things like uniforms.
- */
- if (prog->data->LinkStatus != linking_skipped)
- return false;
-