- if (res != -1) {
- /* These flags affect shader compilation. */
- #define ALL_FLAGS (DBG(FS_CORRECT_DERIVS_AFTER_KILL) | \
- DBG(SI_SCHED) | \
- DBG(UNSAFE_MATH) | \
- DBG(NIR))
- uint64_t shader_debug_flags = sscreen->debug_flags &
- ALL_FLAGS;
-
- /* Add the high bits of 32-bit addresses, which affects
- * how 32-bit addresses are expanded to 64 bits.
- */
- STATIC_ASSERT(ALL_FLAGS <= UINT_MAX);
- shader_debug_flags |= (uint64_t)sscreen->info.address32_hi << 32;
-
- sscreen->disk_shader_cache =
- disk_cache_create(si_get_family_name(sscreen),
- timestamp_str,
- shader_debug_flags);
- free(timestamp_str);
- }
+ _mesa_sha1_init(&ctx);
+
+ if (!disk_cache_get_function_identifier(si_disk_cache_create, &ctx) ||
+ !disk_cache_get_function_identifier(LLVMInitializeAMDGPUTargetInfo,
+ &ctx))
+ return;
+
+ _mesa_sha1_final(&ctx, sha1);
+ disk_cache_format_hex_id(cache_id, sha1, 20 * 2);
+
+ /* These flags affect shader compilation. */
+ #define ALL_FLAGS (DBG(FS_CORRECT_DERIVS_AFTER_KILL) | \
+ DBG(SI_SCHED) | \
+ DBG(GISEL) | \
+ DBG(UNSAFE_MATH))
+ uint64_t shader_debug_flags = sscreen->debug_flags & ALL_FLAGS;
+
+ if (sscreen->options.enable_nir) {
+ STATIC_ASSERT((ALL_FLAGS & (1u << 31)) == 0);
+ shader_debug_flags |= 1u << 31;
+ }
+
+ /* Add the high bits of 32-bit addresses, which affects
+ * how 32-bit addresses are expanded to 64 bits.
+ */
+ STATIC_ASSERT(ALL_FLAGS <= UINT_MAX);
+ assert((int16_t)sscreen->info.address32_hi == (int32_t)sscreen->info.address32_hi);
+ shader_debug_flags |= (uint64_t)(sscreen->info.address32_hi & 0xffff) << 32;
+
+ sscreen->disk_shader_cache =
+ disk_cache_create(sscreen->info.name,
+ cache_id,
+ shader_debug_flags);
+}
+
+static void si_set_max_shader_compiler_threads(struct pipe_screen *screen,
+ unsigned max_threads)
+{
+ struct si_screen *sscreen = (struct si_screen *)screen;
+
+ /* This function doesn't allow a greater number of threads than
+ * the queue had at its creation. */
+ util_queue_adjust_num_threads(&sscreen->shader_compiler_queue,
+ max_threads);
+ /* Don't change the number of threads on the low priority queue. */
+}
+
+static bool si_is_parallel_shader_compilation_finished(struct pipe_screen *screen,
+ void *shader,
+ enum pipe_shader_type shader_type)
+{
+ if (shader_type == PIPE_SHADER_COMPUTE) {
+ struct si_compute *cs = (struct si_compute*)shader;
+
+ return util_queue_fence_is_signalled(&cs->ready);