diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-08-14 20:11:30 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-08-18 22:30:10 +0300 |
commit | e8c48ce0752d656da1eb102a38029a0c54d7e7c4 (patch) | |
tree | 5d5729feb0395ae79024d40c956a41f3bbfd4391 /source/blender/gpu | |
parent | e43e9caf1b17a029efbead02cabeba9b2cf9dcc7 (diff) |
GPUShader: Improve auto name
Use macro to get calling function name. Helps debugging shaders.
Diffstat (limited to 'source/blender/gpu')
-rw-r--r-- | source/blender/gpu/GPU_shader.h | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.cc | 7 |
2 files changed, 9 insertions, 4 deletions
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 603b6957860..99fcae19984 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -73,9 +73,11 @@ struct GPU_ShaderCreateFromArray_Params { const char **vert, **geom, **frag, **defs; }; struct GPUShader *GPU_shader_create_from_arrays_impl( - const struct GPU_ShaderCreateFromArray_Params *params); + const struct GPU_ShaderCreateFromArray_Params *params, const char *func, int line); + #define GPU_shader_create_from_arrays(...) \ - GPU_shader_create_from_arrays_impl(&(const struct GPU_ShaderCreateFromArray_Params)__VA_ARGS__) + GPU_shader_create_from_arrays_impl( \ + &(const struct GPU_ShaderCreateFromArray_Params)__VA_ARGS__, __func__, __LINE__) void GPU_shader_free(GPUShader *shader); diff --git a/source/blender/gpu/intern/gpu_shader.cc b/source/blender/gpu/intern/gpu_shader.cc index b9c43d6842f..4e74e1f69e7 100644 --- a/source/blender/gpu/intern/gpu_shader.cc +++ b/source/blender/gpu/intern/gpu_shader.cc @@ -397,7 +397,7 @@ static const char *string_join_array_maybe_alloc(const char **str_arr, bool *r_i * \endcode */ struct GPUShader *GPU_shader_create_from_arrays_impl( - const struct GPU_ShaderCreateFromArray_Params *params) + const struct GPU_ShaderCreateFromArray_Params *params, const char *func, int line) { struct { const char *str; @@ -409,8 +409,11 @@ struct GPUShader *GPU_shader_create_from_arrays_impl( str_dst[i].str = string_join_array_maybe_alloc(str_src[i], &str_dst[i].is_alloc); } + char name[64]; + BLI_snprintf(name, sizeof(name), "%s_%d", func, line); + GPUShader *sh = GPU_shader_create( - str_dst[0].str, str_dst[1].str, str_dst[2].str, NULL, str_dst[3].str, __func__); + str_dst[0].str, str_dst[1].str, str_dst[2].str, NULL, str_dst[3].str, name); for (int i = 0; i < ARRAY_SIZE(str_dst); i++) { if (str_dst[i].is_alloc) { |