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/draw | |
parent | e43e9caf1b17a029efbead02cabeba9b2cf9dcc7 (diff) |
GPUShader: Improve auto name
Use macro to get calling function name. Helps debugging shaders.
Diffstat (limited to 'source/blender/draw')
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 48 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_shader.c | 45 |
2 files changed, 56 insertions, 37 deletions
diff --git a/source/blender/draw/intern/DRW_render.h b/source/blender/draw/intern/DRW_render.h index 956bddfb357..134fdc0ba7c 100644 --- a/source/blender/draw/intern/DRW_render.h +++ b/source/blender/draw/intern/DRW_render.h @@ -208,27 +208,44 @@ typedef void (*GPUMaterialEvalCallbackFn)(struct GPUMaterial *mat, const char **defines); #endif -struct GPUShader *DRW_shader_create(const char *vert, - const char *geom, - const char *frag, - const char *defines); -struct GPUShader *DRW_shader_create_with_lib( - const char *vert, const char *geom, const char *frag, const char *lib, const char *defines); -struct GPUShader *DRW_shader_create_with_shaderlib(const char *vert, - const char *geom, - const char *frag, - const DRWShaderLibrary *lib, - const char *defines); +struct GPUShader *DRW_shader_create_ex( + const char *vert, const char *geom, const char *frag, const char *defines, const char *func); +struct GPUShader *DRW_shader_create_with_lib_ex(const char *vert, + const char *geom, + const char *frag, + const char *lib, + const char *defines, + const char *func); +struct GPUShader *DRW_shader_create_with_shaderlib_ex(const char *vert, + const char *geom, + const char *frag, + const DRWShaderLibrary *lib, + const char *defines, + const char *func); struct GPUShader *DRW_shader_create_with_transform_feedback(const char *vert, const char *geom, const char *defines, const eGPUShaderTFBType prim_type, const char **varying_names, const int varying_count); -struct GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines); -struct GPUShader *DRW_shader_create_fullscreen_with_shaderlib(const char *frag, - const DRWShaderLibrary *lib, - const char *defines); +struct GPUShader *DRW_shader_create_fullscreen_ex(const char *frag, + const char *defines, + const char *func); +struct GPUShader *DRW_shader_create_fullscreen_with_shaderlib_ex(const char *frag, + const DRWShaderLibrary *lib, + const char *defines, + const char *func); +#define DRW_shader_create(vert, geom, frag, defines) \ + DRW_shader_create_ex(vert, geom, frag, defines, __func__) +#define DRW_shader_create_with_lib(vert, geom, frag, lib, defines) \ + DRW_shader_create_with_lib_ex(vert, geom, frag, lib, defines, __func__) +#define DRW_shader_create_with_shaderlib(vert, geom, frag, lib, defines) \ + DRW_shader_create_with_shaderlib_ex(vert, geom, frag, lib, defines, __func__) +#define DRW_shader_create_fullscreen(frag, defines) \ + DRW_shader_create_fullscreen_ex(frag, defines, __func__) +#define DRW_shader_create_fullscreen_with_shaderlib(frag, lib, defines) \ + DRW_shader_create_fullscreen_with_shaderlib_ex(frag, lib, defines, __func__) + struct GPUMaterial *DRW_shader_find_from_world(struct World *wo, const void *engine_type, const int options, @@ -718,7 +735,6 @@ bool DRW_state_draw_background(void); /* Avoid too many lookups while drawing */ typedef struct DRWContextState { - struct ARegion *region; /* 'CTX_wm_region(C)' */ struct RegionView3D *rv3d; /* 'CTX_wm_region_view3d(C)' */ struct View3D *v3d; /* 'CTX_wm_view3d(C)' */ diff --git a/source/blender/draw/intern/draw_manager_shader.c b/source/blender/draw/intern/draw_manager_shader.c index 1c260721efb..7602bbb39ac 100644 --- a/source/blender/draw/intern/draw_manager_shader.c +++ b/source/blender/draw/intern/draw_manager_shader.c @@ -312,16 +312,18 @@ void DRW_deferred_shader_remove(GPUMaterial *mat) /** \{ */ -GPUShader *DRW_shader_create(const char *vert, - const char *geom, - const char *frag, - const char *defines) +GPUShader *DRW_shader_create_ex( + const char *vert, const char *geom, const char *frag, const char *defines, const char *name) { - return GPU_shader_create(vert, frag, geom, NULL, defines, __func__); + return GPU_shader_create(vert, frag, geom, NULL, defines, name); } -GPUShader *DRW_shader_create_with_lib( - const char *vert, const char *geom, const char *frag, const char *lib, const char *defines) +GPUShader *DRW_shader_create_with_lib_ex(const char *vert, + const char *geom, + const char *frag, + const char *lib, + const char *defines, + const char *name) { GPUShader *sh; char *vert_with_lib = NULL; @@ -334,7 +336,7 @@ GPUShader *DRW_shader_create_with_lib( geom_with_lib = BLI_string_joinN(lib, geom); } - sh = GPU_shader_create(vert_with_lib, frag_with_lib, geom_with_lib, NULL, defines, __func__); + sh = GPU_shader_create(vert_with_lib, frag_with_lib, geom_with_lib, NULL, defines, name); MEM_freeN(vert_with_lib); MEM_freeN(frag_with_lib); @@ -345,18 +347,19 @@ GPUShader *DRW_shader_create_with_lib( return sh; } -GPUShader *DRW_shader_create_with_shaderlib(const char *vert, - const char *geom, - const char *frag, - const DRWShaderLibrary *lib, - const char *defines) +GPUShader *DRW_shader_create_with_shaderlib_ex(const char *vert, + const char *geom, + const char *frag, + const DRWShaderLibrary *lib, + const char *defines, + const char *name) { GPUShader *sh; char *vert_with_lib = DRW_shader_library_create_shader_string(lib, vert); char *frag_with_lib = DRW_shader_library_create_shader_string(lib, frag); char *geom_with_lib = (geom) ? DRW_shader_library_create_shader_string(lib, geom) : NULL; - sh = GPU_shader_create(vert_with_lib, frag_with_lib, geom_with_lib, NULL, defines, __func__); + sh = GPU_shader_create(vert_with_lib, frag_with_lib, geom_with_lib, NULL, defines, name); MEM_SAFE_FREE(vert_with_lib); MEM_SAFE_FREE(frag_with_lib); @@ -383,22 +386,22 @@ GPUShader *DRW_shader_create_with_transform_feedback(const char *vert, __func__); } -GPUShader *DRW_shader_create_fullscreen(const char *frag, const char *defines) +GPUShader *DRW_shader_create_fullscreen_ex(const char *frag, const char *defines, const char *name) { - return GPU_shader_create( - datatoc_common_fullscreen_vert_glsl, frag, NULL, NULL, defines, __func__); + return GPU_shader_create(datatoc_common_fullscreen_vert_glsl, frag, NULL, NULL, defines, name); } -GPUShader *DRW_shader_create_fullscreen_with_shaderlib(const char *frag, - const DRWShaderLibrary *lib, - const char *defines) +GPUShader *DRW_shader_create_fullscreen_with_shaderlib_ex(const char *frag, + const DRWShaderLibrary *lib, + const char *defines, + const char *name) { GPUShader *sh; char *vert = datatoc_common_fullscreen_vert_glsl; char *frag_with_lib = DRW_shader_library_create_shader_string(lib, frag); - sh = GPU_shader_create(vert, frag_with_lib, NULL, NULL, defines, __func__); + sh = GPU_shader_create(vert, frag_with_lib, NULL, NULL, defines, name); MEM_SAFE_FREE(frag_with_lib); |