diff options
Diffstat (limited to 'source')
-rw-r--r-- | source/blender/draw/intern/DRW_render.h | 48 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager_shader.c | 45 | ||||
-rw-r--r-- | source/blender/gpu/GPU_shader.h | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.cc | 7 |
4 files changed, 65 insertions, 41 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); 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) { |