Mesa (master): compiler/glsl: call util_cpu_detect from glsl_type_singleton_init_or_ref

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Mar 17 07:36:18 UTC 2021


Module: Mesa
Branch: master
Commit: f29de817eb39ceba9d1617a8a58ad5148ce2c8ca
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=f29de817eb39ceba9d1617a8a58ad5148ce2c8ca

Author: Iago Toral Quiroga <itoral at igalia.com>
Date:   Mon Mar  8 08:34:50 2021 +0100

compiler/glsl: call util_cpu_detect from glsl_type_singleton_init_or_ref

Reviewed-by: Jason Ekstrand <jason at jlekstrand.net>
Closes: #4393
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9457>

---

 src/compiler/glsl/standalone.cpp                | 2 --
 src/compiler/glsl_types.cpp                     | 6 ++++++
 src/compiler/nir/tests/negative_equal_tests.cpp | 2 --
 3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/compiler/glsl/standalone.cpp b/src/compiler/glsl/standalone.cpp
index ad1da65bcef..b34583e54bd 100644
--- a/src/compiler/glsl/standalone.cpp
+++ b/src/compiler/glsl/standalone.cpp
@@ -398,8 +398,6 @@ standalone_compile_shader(const struct standalone_options *_options,
    int status = EXIT_SUCCESS;
    bool glsl_es = false;
 
-   util_cpu_detect();
-
    options = _options;
 
    switch (options->glsl_version) {
diff --git a/src/compiler/glsl_types.cpp b/src/compiler/glsl_types.cpp
index 98d962481e1..4d1c4366c51 100644
--- a/src/compiler/glsl_types.cpp
+++ b/src/compiler/glsl_types.cpp
@@ -26,6 +26,7 @@
 #include "compiler/glsl/glsl_parser_extras.h"
 #include "glsl_types.h"
 #include "util/hash_table.h"
+#include "util/u_cpu_detect.h"
 #include "util/u_string.h"
 
 
@@ -518,6 +519,11 @@ hash_free_type_function(struct hash_entry *entry)
 void
 glsl_type_singleton_init_or_ref()
 {
+   /* This is required for _mesa_half_to_float() which is
+    * required for constant-folding 16-bit float ops.
+    */
+   util_cpu_detect();
+
    mtx_lock(&glsl_type::hash_mutex);
    glsl_type_users++;
    mtx_unlock(&glsl_type::hash_mutex);
diff --git a/src/compiler/nir/tests/negative_equal_tests.cpp b/src/compiler/nir/tests/negative_equal_tests.cpp
index c7cf53543bb..ff9eeb27f40 100644
--- a/src/compiler/nir/tests/negative_equal_tests.cpp
+++ b/src/compiler/nir/tests/negative_equal_tests.cpp
@@ -36,7 +36,6 @@ protected:
    const_value_negative_equal_test()
    {
       glsl_type_singleton_init_or_ref();
-      util_cpu_detect();
 
       memset(c1, 0, sizeof(c1));
       memset(c2, 0, sizeof(c2));
@@ -56,7 +55,6 @@ protected:
    alu_srcs_negative_equal_test()
    {
       glsl_type_singleton_init_or_ref();
-      util_cpu_detect();
 
       static const nir_shader_compiler_options options = { };
       bld = nir_builder_init_simple_shader(MESA_SHADER_VERTEX, &options,



More information about the mesa-commit mailing list