summaryrefslogtreecommitdiffstats
path: root/src/mesa/drivers/dri
diff options
context:
space:
mode:
authorTimothy Arceri <[email protected]>2017-02-17 10:16:16 +1100
committerTimothy Arceri <[email protected]>2017-02-17 11:18:43 +1100
commit6602d0401c23211af122f4ef5a86acf5dd9665e7 (patch)
treecc98dc21d0d7438c2be32cdb49667bee81fbe81a /src/mesa/drivers/dri
parented6153012167fc7176a23f23ee4cccce9cbaee4a (diff)
st/mesa/glsl: build string of dri options and use as input to building sha for shaders
Reviewed-by: Nicolai Hähnle <[email protected]>
Diffstat (limited to 'src/mesa/drivers/dri')
-rw-r--r--src/mesa/drivers/dri/common/xmlconfig.h52
1 files changed, 52 insertions, 0 deletions
diff --git a/src/mesa/drivers/dri/common/xmlconfig.h b/src/mesa/drivers/dri/common/xmlconfig.h
index 8969843bdc9..77aa14c20e0 100644
--- a/src/mesa/drivers/dri/common/xmlconfig.h
+++ b/src/mesa/drivers/dri/common/xmlconfig.h
@@ -30,6 +30,9 @@
#ifndef __XMLCONFIG_H
#define __XMLCONFIG_H
+#include "util/mesa-sha1.h"
+#include "util/ralloc.h"
+
#define STRING_CONF_MAXLEN 25
/** \brief Option data types */
@@ -124,4 +127,53 @@ float driQueryOptionf (const driOptionCache *cache, const char *name);
/** \brief Query a string option value */
char *driQueryOptionstr (const driOptionCache *cache, const char *name);
+/**
+ * Returns a hash of the options for this application.
+ */
+static inline void
+driComputeOptionsSha1(const driOptionCache *cache, unsigned char *sha1)
+{
+ void *ctx = ralloc_context(NULL);
+ char *dri_options = ralloc_strdup(ctx, "");
+
+ for (int i = 0; i < 1 << cache->tableSize; i++) {
+ if (cache->info[i].name == NULL)
+ continue;
+
+ bool ret = false;
+ switch (cache->info[i].type) {
+ case DRI_BOOL:
+ ret = ralloc_asprintf_append(&dri_options, "%s:%u,",
+ cache->info[i].name,
+ cache->values[i]._bool);
+ break;
+ case DRI_INT:
+ case DRI_ENUM:
+ ret = ralloc_asprintf_append(&dri_options, "%s:%d,",
+ cache->info[i].name,
+ cache->values[i]._int);
+ break;
+ case DRI_FLOAT:
+ ret = ralloc_asprintf_append(&dri_options, "%s:%f,",
+ cache->info[i].name,
+ cache->values[i]._float);
+ break;
+ case DRI_STRING:
+ ret = ralloc_asprintf_append(&dri_options, "%s:%s,",
+ cache->info[i].name,
+ cache->values[i]._string);
+ break;
+ default:
+ unreachable("unsupported dri config type!");
+ }
+
+ if (!ret) {
+ break;
+ }
+ }
+
+ _mesa_sha1_compute(dri_options, strlen(dri_options), sha1);
+ ralloc_free(ctx);
+}
+
#endif