diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-08-02 19:31:38 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-08-02 19:33:49 +0300 |
commit | 8f6ff3adfae7b7f14e0bab293efd0c8231982c89 (patch) | |
tree | d37d2abd17a8b324cc5bbc6a1c73cb5c81a4aa3d /source/blender/gpu/intern/gpu_material.c | |
parent | 3578212e462d2a67f49d64ce5fb64df43200654f (diff) |
GPUShader: Add name for debugging & identifying shaders.
Diffstat (limited to 'source/blender/gpu/intern/gpu_material.c')
-rw-r--r-- | source/blender/gpu/intern/gpu_material.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/source/blender/gpu/intern/gpu_material.c b/source/blender/gpu/intern/gpu_material.c index 5e0d9275aa2..9859f56c1db 100644 --- a/source/blender/gpu/intern/gpu_material.c +++ b/source/blender/gpu/intern/gpu_material.c @@ -43,6 +43,7 @@ #include "BLI_math.h" #include "BLI_listbase.h" #include "BLI_utildefines.h" +#include "BLI_string.h" #include "BKE_main.h" #include "BKE_node.h" @@ -120,6 +121,10 @@ struct GPUMaterial { short int sss_falloff; float sss_sharpness; bool sss_dirty; + +#ifndef NDEBUG + char name[64]; +#endif }; enum { @@ -581,7 +586,7 @@ GPUMaterial *GPU_material_from_nodetree_find( */ GPUMaterial *GPU_material_from_nodetree( Scene *scene, struct bNodeTree *ntree, ListBase *gpumaterials, const void *engine_type, int options, - const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines) + const char *vert_code, const char *geom_code, const char *frag_lib, const char *defines, const char *name) { LinkData *link; bool has_volume_output, has_surface_output; @@ -594,6 +599,11 @@ GPUMaterial *GPU_material_from_nodetree( mat->scene = scene; mat->engine_type = engine_type; mat->options = options; +#ifndef NDEBUG + BLI_snprintf(mat->name, sizeof(mat->name), "%s", name); +#else + UNUSED_VARS(name); +#endif /* localize tree to create links for reroute and mute */ bNodeTree *localtree = ntreeLocalize(ntree); @@ -666,7 +676,12 @@ void GPU_material_compile(GPUMaterial *mat) /* NOTE: The shader may have already been compiled here since we are * sharing GPUShader across GPUMaterials. In this case it's a no-op. */ - GPU_pass_compile(mat->pass); +#ifndef NDEBUG + GPU_pass_compile(mat->pass, mat->name); +#else + GPU_pass_compile(mat->pass, __func__); +#endif + GPUShader *sh = GPU_pass_shader_get(mat->pass); if (sh != NULL) { |