ctx->API, ctx->Const.GLSLVersion,
ctx->Const.ForceGLSLVersion);
+ /* DRI config options may also change the output from the compiler so
+ * include them as an input to sha1 creation.
+ */
char sha1buf[41];
+ _mesa_sha1_format(sha1buf, ctx->Const.dri_config_options_sha1);
+ ralloc_strcat(&buf, sha1buf);
+
for (unsigned i = 0; i < prog->NumShaders; i++) {
struct gl_shader *sh = prog->Shaders[i];
ralloc_asprintf_append(&buf, "%s: %s\n",
options->allow_higher_compat_version =
driQueryOptionb(optionCache, "allow_higher_compat_version");
options->glsl_zero_init = driQueryOptionb(optionCache, "glsl_zero_init");
+
+ driComputeOptionsSha1(optionCache, options->config_options_sha1);
}
static const __DRIconfig **
#ifndef __XMLCONFIG_H
#define __XMLCONFIG_H
+#include "util/mesa-sha1.h"
+#include "util/ralloc.h"
+
#define STRING_CONF_MAXLEN 25
/** \brief Option data types */
/** \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