diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2022-04-27 16:29:53 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-04-27 17:01:41 +0300 |
commit | c01e33d6caf64812bf24cf52609b7115c78fa01b (patch) | |
tree | 0126d466bc7aba02790216dec15b34a0c9c7d33c /source/blender/gpu | |
parent | 163f6a17e4fe60ce917715afc5bb5eae3d5ff07a (diff) |
GPUCodegen: Use spin lock to protect the pass refcounter.
This is not performance critical so using the same global lock should not
pose any issue.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/intern/gpu_codegen.cc | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/source/blender/gpu/intern/gpu_codegen.cc b/source/blender/gpu/intern/gpu_codegen.cc index 048928b2312..1f929c4fcd0 100644 --- a/source/blender/gpu/intern/gpu_codegen.cc +++ b/source/blender/gpu/intern/gpu_codegen.cc @@ -571,7 +571,9 @@ GPUPass *GPU_generate_pass(GPUMaterial *material, return nullptr; } /* No collision, just return the pass. */ + BLI_spin_lock(&pass_cache_spin); pass_hash->refcount += 1; + BLI_spin_unlock(&pass_cache_spin); return pass_hash; } @@ -597,7 +599,9 @@ GPUPass *GPU_generate_pass(GPUMaterial *material, /* Shader has already been created but failed to compile. */ return nullptr; } + BLI_spin_lock(&pass_cache_spin); pass->refcount += 1; + BLI_spin_unlock(&pass_cache_spin); } else { /* We still create a pass even if shader compilation @@ -697,8 +701,10 @@ GPUShader *GPU_pass_shader_get(GPUPass *pass) void GPU_pass_release(GPUPass *pass) { + BLI_spin_lock(&pass_cache_spin); BLI_assert(pass->refcount > 0); pass->refcount--; + BLI_spin_unlock(&pass_cache_spin); } static void gpu_pass_free(GPUPass *pass) |