#include "ir_uniform.h"
#include "linker.h"
#include "link_varyings.h"
-#include "main/core.h"
#include "nir.h"
#include "program.h"
#include "serialize.h"
#include "shader_cache.h"
#include "util/mesa-sha1.h"
#include "string_to_uint_map.h"
+#include "main/mtypes.h"
extern "C" {
#include "main/enums.h"
return;
/* Exit early when we are dealing with a ff shader with no source file to
- * generate a source from.
+ * generate a source from, or with a SPIR-V shader.
*
* TODO: In future we should use another method to generate a key for ff
- * programs.
+ * programs, and SPIR-V shaders.
*/
static const char zero[sizeof(prog->data->sha1)] = {0};
if (memcmp(prog->data->sha1, zero, sizeof(prog->data->sha1)) == 0)
struct blob metadata;
blob_init(&metadata);
+ if (ctx->Driver.ShaderCacheSerializeDriverBlob) {
+ for (unsigned i = 0; i < MESA_SHADER_STAGES; i++) {
+ struct gl_linked_shader *sh = prog->_LinkedShaders[i];
+ if (sh)
+ ctx->Driver.ShaderCacheSerializeDriverBlob(ctx, sh->Program);
+ }
+ }
+
serialize_glsl_program(&metadata, ctx, prog);
struct cache_item_metadata cache_item_metadata;
if (!cache_item_metadata.keys)
goto fail;
- char sha1_buf[41];
for (unsigned i = 0; i < prog->NumShaders; i++) {
- disk_cache_put_key(cache, prog->Shaders[i]->sha1);
memcpy(cache_item_metadata.keys[i], prog->Shaders[i]->sha1,
sizeof(cache_key));
- if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
- _mesa_sha1_format(sha1_buf, prog->Shaders[i]->sha1);
- fprintf(stderr, "marking shader: %s\n", sha1_buf);
- }
}
disk_cache_put(cache, prog->data->sha1, metadata.data, metadata.size,
&cache_item_metadata);
+ char sha1_buf[41];
if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
_mesa_sha1_format(sha1_buf, prog->data->sha1);
fprintf(stderr, "putting program metadata in cache: %s\n", sha1_buf);
shader_cache_read_program_metadata(struct gl_context *ctx,
struct gl_shader_program *prog)
{
- /* Fixed function programs generated by Mesa are not cached. So don't
- * try to read metadata for them from the cache.
+ /* Fixed function programs generated by Mesa, or SPIR-V shaders, are not
+ * cached. So don't try to read metadata for them from the cache.
*/
- if (prog->Name == 0)
+ if (prog->Name == 0 || prog->data->spirv)
return false;
struct disk_cache *cache = ctx->Cache;
prog->FragDataBindings->iterate(create_binding_str, &buf);
ralloc_strcat(&buf, "fbi: ");
prog->FragDataIndexBindings->iterate(create_binding_str, &buf);
+ ralloc_asprintf_append(&buf, "tf: %d ", prog->TransformFeedback.BufferMode);
+ for (unsigned int i = 0; i < prog->TransformFeedback.NumVarying; i++) {
+ ralloc_asprintf_append(&buf, "%s ",
+ prog->TransformFeedback.VaryingNames[i]);
+ }
/* SSO has an effect on the linked program so include this when generating
* the sha also.
/* This is used to flag a shader retrieved from cache */
prog->data->LinkStatus = LINKING_SKIPPED;
- /* Since the program load was successful, CompileStatus of all shaders at
- * this point should normally be compile_skipped. However because of how
- * the eviction works, it may happen that some of the individual shader keys
- * have been evicted, resulting in unnecessary recompiles on this load, so
- * mark them again to skip such recompiles next time.
- */
- char sha1_buf[41];
- for (unsigned i = 0; i < prog->NumShaders; i++) {
- if (prog->Shaders[i]->CompileStatus == COMPILED_NO_OPTS) {
- disk_cache_put_key(cache, prog->Shaders[i]->sha1);
- if (ctx->_Shader->Flags & GLSL_CACHE_INFO) {
- _mesa_sha1_format(sha1_buf, prog->Shaders[i]->sha1);
- fprintf(stderr, "re-marking shader: %s\n", sha1_buf);
- }
- }
- }
-
free (buffer);
return true;