Mesa (main): radv,aco: disable shader cache when ACO debug options are used
GitLab Mirror
gitlab-mirror at kemper.freedesktop.org
Thu Jun 2 15:16:16 UTC 2022
Module: Mesa
Branch: main
Commit: be4c1a5f527d3d2e439f1d7cc5f7b9b87b226a09
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=be4c1a5f527d3d2e439f1d7cc5f7b9b87b226a09
Author: Rhys Perry <pendingchaos02 at gmail.com>
Date: Tue Jan 18 14:53:38 2022 +0000
radv,aco: disable shader cache when ACO debug options are used
Signed-off-by: Rhys Perry <pendingchaos02 at gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14594>
---
src/amd/compiler/aco_interface.cpp | 10 ++++++++++
src/amd/compiler/aco_interface.h | 2 ++
src/amd/vulkan/radv_pipeline_cache.c | 20 ++++++++++++--------
3 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/src/amd/compiler/aco_interface.cpp b/src/amd/compiler/aco_interface.cpp
index 66917e846c7..86f8b0962a6 100644
--- a/src/amd/compiler/aco_interface.cpp
+++ b/src/amd/compiler/aco_interface.cpp
@@ -63,6 +63,16 @@ static const std::array<aco_compiler_statistic_info, aco::num_statistics> statis
const unsigned aco_num_statistics = aco::num_statistics;
const aco_compiler_statistic_info* aco_statistic_infos = statistic_infos.data();
+uint64_t
+aco_get_codegen_flags()
+{
+ aco::init();
+ /* Exclude flags which don't affect code generation. */
+ uint64_t exclude = aco::DEBUG_VALIDATE_IR | aco::DEBUG_VALIDATE_RA | aco::DEBUG_PERFWARN |
+ aco::DEBUG_PERF_INFO | aco::DEBUG_LIVE_INFO;
+ return aco::debug_flags & ~exclude;
+}
+
static void
validate(aco::Program* program)
{
diff --git a/src/amd/compiler/aco_interface.h b/src/amd/compiler/aco_interface.h
index 522bb11ca9b..6bcdb26b9c4 100644
--- a/src/amd/compiler/aco_interface.h
+++ b/src/amd/compiler/aco_interface.h
@@ -58,6 +58,8 @@ void aco_compile_vs_prolog(const struct aco_compiler_options* options,
const struct radv_shader_args* args,
struct radv_prolog_binary** binary);
+uint64_t aco_get_codegen_flags();
+
#ifdef __cplusplus
}
#endif
diff --git a/src/amd/vulkan/radv_pipeline_cache.c b/src/amd/vulkan/radv_pipeline_cache.c
index fb7f33934b9..25fe1bbae97 100644
--- a/src/amd/vulkan/radv_pipeline_cache.c
+++ b/src/amd/vulkan/radv_pipeline_cache.c
@@ -30,6 +30,7 @@
#include "radv_debug.h"
#include "radv_private.h"
#include "radv_shader.h"
+#include "aco_interface.h"
struct cache_entry {
union {
@@ -61,6 +62,16 @@ radv_pipeline_cache_unlock(struct radv_pipeline_cache *cache)
mtx_unlock(&cache->mutex);
}
+static bool
+radv_is_cache_disabled(struct radv_device *device)
+{
+ /* Pipeline caches can be disabled with RADV_DEBUG=nocache, with MESA_GLSL_CACHE_DISABLE=1 and
+ * when ACO_DEBUG is used. MESA_GLSL_CACHE_DISABLE is done elsewhere.
+ */
+ return (device->instance->debug_flags & RADV_DEBUG_NO_CACHE) ||
+ (device->physical_device->use_llvm ? 0 : aco_get_codegen_flags());
+}
+
void
radv_pipeline_cache_init(struct radv_pipeline_cache *cache, struct radv_device *device)
{
@@ -80,7 +91,7 @@ radv_pipeline_cache_init(struct radv_pipeline_cache *cache, struct radv_device *
/* We don't consider allocation failure fatal, we just start with a 0-sized
* cache. Disable caching when we want to keep shader debug info, since
* we don't get the debug info on cached shaders. */
- if (cache->hash_table == NULL || (device->instance->debug_flags & RADV_DEBUG_NO_CACHE))
+ if (cache->hash_table == NULL || radv_is_cache_disabled(device))
cache->table_size = 0;
else
memset(cache->hash_table, 0, byte_size);
@@ -287,13 +298,6 @@ radv_pipeline_cache_add_entry(struct radv_pipeline_cache *cache, struct cache_en
radv_pipeline_cache_set_entry(cache, entry);
}
-static bool
-radv_is_cache_disabled(struct radv_device *device)
-{
- /* Pipeline caches can be disabled with RADV_DEBUG=nocache and with MESA_SHADER_CACHE_DISABLE=1. */
- return (device->instance->debug_flags & RADV_DEBUG_NO_CACHE);
-}
-
bool
radv_create_shaders_from_pipeline_cache(
struct radv_device *device, struct radv_pipeline_cache *cache, const unsigned char *sha1,
More information about the mesa-commit
mailing list