Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2018-07-02 12:03:14 +0300
committerClément Foucault <foucault.clem@gmail.com>2018-07-02 12:05:48 +0300
commitad5a20efcef8114b589ff66d09166eabdc8e67ad (patch)
treecdfa0334ea001a006a489a513267460b8cc14d27 /source/blender
parentbf7c8151696255910594dcd9de1b4af7e7bdd296 (diff)
Commit D3494 : Compiled shader lookup fix
Authored by Pavel Rudko (PavelRudko) on Thu, Jun 21, 10:41 AM. Original description: I've encounterd into a problem with blender 2.8. See the example screenshot (scene, shader setup). For some materials it's not enough to calculate hash based on fragment code and defines. In some cases attribute names may change. And if we change uv set name, for example, vertex shader is not recompiled, and another attribute name inside it is used.
Diffstat (limited to 'source/blender')
-rw-r--r--source/blender/gpu/intern/gpu_codegen.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.c b/source/blender/gpu/intern/gpu_codegen.c
index 436f43d9c1e..a450b551d4a 100644
--- a/source/blender/gpu/intern/gpu_codegen.c
+++ b/source/blender/gpu/intern/gpu_codegen.c
@@ -80,11 +80,17 @@ static char *glsl_material_library = NULL;
static GPUPass *pass_cache = NULL;
static SpinLock pass_cache_spin;
-static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs)
+static uint32_t gpu_pass_hash(const char *frag_gen, const char *defs, GPUVertexAttribs *attribs)
{
BLI_HashMurmur2A hm2a;
BLI_hash_mm2a_init(&hm2a, 0);
BLI_hash_mm2a_add(&hm2a, (unsigned char *)frag_gen, strlen(frag_gen));
+ if (attribs) {
+ for (int att_idx = 0; att_idx < attribs->totlayer; att_idx++) {
+ char *name = attribs->layer[att_idx].name;
+ BLI_hash_mm2a_add(&hm2a, (unsigned char *)name, strlen(name));
+ }
+ }
if (defs)
BLI_hash_mm2a_add(&hm2a, (unsigned char *)defs, strlen(defs));
@@ -1885,7 +1891,7 @@ GPUPass *GPU_generate_pass_new(
char *fragmentgen = code_generate_fragment(material, nodes, frag_outlink->output);
/* Cache lookup: Reuse shaders already compiled */
- uint32_t hash = gpu_pass_hash(fragmentgen, defines);
+ uint32_t hash = gpu_pass_hash(fragmentgen, defines, attribs);
pass_hash = gpu_pass_cache_lookup(hash);
if (pass_hash && (pass_hash->next == NULL || pass_hash->next->hash != hash)) {