diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2020-09-16 02:40:04 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2020-09-16 02:40:45 +0300 |
commit | 1858535a105c306282d95d1894f4f8dc088d17e4 (patch) | |
tree | d42df580aa525bd4ada4d432814e6678bc645c4e | |
parent | 0dd44f46473d3706cc5343e0d01820d5ec56e962 (diff) |
GPUShader: Add meaningful debug names to builtin shaders
This makes the debugging easier.
-rw-r--r-- | source/blender/gpu/GPU_shader.h | 4 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_shader_builtin.c | 84 |
2 files changed, 76 insertions, 12 deletions
diff --git a/source/blender/gpu/GPU_shader.h b/source/blender/gpu/GPU_shader.h index 64695dfe3fb..9aaa5d4cae8 100644 --- a/source/blender/gpu/GPU_shader.h +++ b/source/blender/gpu/GPU_shader.h @@ -72,6 +72,10 @@ struct GPUShader *GPU_shader_create_from_arrays_impl( GPU_shader_create_from_arrays_impl( \ &(const struct GPU_ShaderCreateFromArray_Params)__VA_ARGS__, __func__, __LINE__) +#define GPU_shader_create_from_arrays_named(name, ...) \ + GPU_shader_create_from_arrays_impl( \ + &(const struct GPU_ShaderCreateFromArray_Params)__VA_ARGS__, name, 0) + void GPU_shader_free(GPUShader *shader); void GPU_shader_bind(GPUShader *shader); diff --git a/source/blender/gpu/intern/gpu_shader_builtin.c b/source/blender/gpu/intern/gpu_shader_builtin.c index f528e67a80a..63eae109f01 100644 --- a/source/blender/gpu/intern/gpu_shader_builtin.c +++ b/source/blender/gpu/intern/gpu_shader_builtin.c @@ -152,6 +152,7 @@ const struct GPUShaderConfigData GPU_shader_cfg_data[GPU_SHADER_CFG_LEN] = { static GPUShader *builtin_shaders[GPU_SHADER_CFG_LEN][GPU_SHADER_BUILTIN_LEN] = {{NULL}}; typedef struct { + const char *name; const char *vert; /** Optional. */ const char *geom; @@ -163,116 +164,138 @@ typedef struct { static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { [GPU_SHADER_TEXT] = { + .name = "GPU_SHADER_TEXT", .vert = datatoc_gpu_shader_text_vert_glsl, .frag = datatoc_gpu_shader_text_frag_glsl, }, [GPU_SHADER_KEYFRAME_DIAMOND] = { + .name = "GPU_SHADER_KEYFRAME_DIAMOND", .vert = datatoc_gpu_shader_keyframe_diamond_vert_glsl, .frag = datatoc_gpu_shader_keyframe_diamond_frag_glsl, }, [GPU_SHADER_SIMPLE_LIGHTING] = { + .name = "GPU_SHADER_SIMPLE_LIGHTING", .vert = datatoc_gpu_shader_3D_normal_vert_glsl, .frag = datatoc_gpu_shader_simple_lighting_frag_glsl, }, [GPU_SHADER_2D_CHECKER] = { + .name = "GPU_SHADER_2D_CHECKER", .vert = datatoc_gpu_shader_2D_vert_glsl, .frag = datatoc_gpu_shader_checker_frag_glsl, }, [GPU_SHADER_2D_DIAG_STRIPES] = { + .name = "GPU_SHADER_2D_DIAG_STRIPES", .vert = datatoc_gpu_shader_2D_vert_glsl, .frag = datatoc_gpu_shader_diag_stripes_frag_glsl, }, [GPU_SHADER_2D_UNIFORM_COLOR] = { + .name = "GPU_SHADER_2D_UNIFORM_COLOR", .vert = datatoc_gpu_shader_2D_vert_glsl, .frag = datatoc_gpu_shader_uniform_color_frag_glsl, }, [GPU_SHADER_2D_FLAT_COLOR] = { + .name = "GPU_SHADER_2D_FLAT_COLOR", .vert = datatoc_gpu_shader_2D_flat_color_vert_glsl, .frag = datatoc_gpu_shader_flat_color_frag_glsl, }, [GPU_SHADER_2D_SMOOTH_COLOR] = { + .name = "GPU_SHADER_2D_SMOOTH_COLOR", .vert = datatoc_gpu_shader_2D_smooth_color_vert_glsl, .frag = datatoc_gpu_shader_2D_smooth_color_frag_glsl, }, [GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE] = { + .name = "GPU_SHADER_2D_IMAGE_OVERLAYS_MERGE", .vert = datatoc_gpu_shader_2D_image_vert_glsl, .frag = datatoc_gpu_shader_image_overlays_merge_frag_glsl, }, [GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE] = { + .name = "GPU_SHADER_2D_IMAGE_OVERLAYS_STEREO_MERGE", .vert = datatoc_gpu_shader_2D_vert_glsl, .frag = datatoc_gpu_shader_image_overlays_stereo_merge_frag_glsl, }, [GPU_SHADER_2D_IMAGE] = { + .name = "GPU_SHADER_2D_IMAGE", .vert = datatoc_gpu_shader_2D_image_vert_glsl, .frag = datatoc_gpu_shader_image_frag_glsl, }, [GPU_SHADER_2D_IMAGE_COLOR] = { + .name = "GPU_SHADER_2D_IMAGE_COLOR", .vert = datatoc_gpu_shader_2D_image_vert_glsl, .frag = datatoc_gpu_shader_image_color_frag_glsl, }, [GPU_SHADER_2D_IMAGE_DESATURATE_COLOR] = { + .name = "GPU_SHADER_2D_IMAGE_DESATURATE_COLOR", .vert = datatoc_gpu_shader_2D_image_vert_glsl, .frag = datatoc_gpu_shader_image_desaturate_frag_glsl, }, [GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR] = { + .name = "GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR", .vert = datatoc_gpu_shader_2D_image_vert_glsl, .frag = datatoc_gpu_shader_image_shuffle_color_frag_glsl, }, [GPU_SHADER_2D_IMAGE_RECT_COLOR] = { + .name = "GPU_SHADER_2D_IMAGE_RECT_COLOR", .vert = datatoc_gpu_shader_2D_image_rect_vert_glsl, .frag = datatoc_gpu_shader_image_color_frag_glsl, }, [GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR] = { + .name = "GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR", .vert = datatoc_gpu_shader_2D_image_multi_rect_vert_glsl, .frag = datatoc_gpu_shader_image_varying_color_frag_glsl, }, [GPU_SHADER_3D_UNIFORM_COLOR] = { + .name = "GPU_SHADER_3D_UNIFORM_COLOR", .vert = datatoc_gpu_shader_3D_vert_glsl, .frag = datatoc_gpu_shader_uniform_color_frag_glsl, }, [GPU_SHADER_3D_FLAT_COLOR] = { + .name = "GPU_SHADER_3D_FLAT_COLOR", .vert = datatoc_gpu_shader_3D_flat_color_vert_glsl, .frag = datatoc_gpu_shader_flat_color_frag_glsl, }, [GPU_SHADER_3D_SMOOTH_COLOR] = { + .name = "GPU_SHADER_3D_SMOOTH_COLOR", .vert = datatoc_gpu_shader_3D_smooth_color_vert_glsl, .frag = datatoc_gpu_shader_3D_smooth_color_frag_glsl, }, [GPU_SHADER_3D_DEPTH_ONLY] = { + .name = "GPU_SHADER_3D_DEPTH_ONLY", .vert = datatoc_gpu_shader_3D_vert_glsl, .frag = datatoc_gpu_shader_depth_only_frag_glsl, }, [GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR] = { + .name = "GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR", .vert = datatoc_gpu_shader_3D_clipped_uniform_color_vert_glsl, .frag = datatoc_gpu_shader_uniform_color_frag_glsl, }, [GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR] = { + .name = "GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR", .vert = datatoc_gpu_shader_3D_polyline_vert_glsl, .geom = datatoc_gpu_shader_3D_polyline_geom_glsl, .frag = datatoc_gpu_shader_3D_polyline_frag_glsl, @@ -280,6 +303,7 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { }, [GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR] = { + .name = "GPU_SHADER_3D_POLYLINE_CLIPPED_UNIFORM_COLOR", .vert = datatoc_gpu_shader_3D_polyline_vert_glsl, .geom = datatoc_gpu_shader_3D_polyline_geom_glsl, .frag = datatoc_gpu_shader_3D_polyline_frag_glsl, @@ -288,6 +312,7 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { }, [GPU_SHADER_3D_POLYLINE_FLAT_COLOR] = { + .name = "GPU_SHADER_3D_POLYLINE_FLAT_COLOR", .vert = datatoc_gpu_shader_3D_polyline_vert_glsl, .geom = datatoc_gpu_shader_3D_polyline_geom_glsl, .frag = datatoc_gpu_shader_3D_polyline_frag_glsl, @@ -295,6 +320,7 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { }, [GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR] = { + .name = "GPU_SHADER_3D_POLYLINE_SMOOTH_COLOR", .vert = datatoc_gpu_shader_3D_polyline_vert_glsl, .geom = datatoc_gpu_shader_3D_polyline_geom_glsl, .frag = datatoc_gpu_shader_3D_polyline_frag_glsl, @@ -303,73 +329,87 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { [GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR] = { + .name = "GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR", .vert = datatoc_gpu_shader_2D_line_dashed_uniform_color_vert_glsl, .frag = datatoc_gpu_shader_2D_line_dashed_frag_glsl, }, [GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR] = { + .name = "GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR", .vert = datatoc_gpu_shader_3D_line_dashed_uniform_color_vert_glsl, .frag = datatoc_gpu_shader_2D_line_dashed_frag_glsl, }, [GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR] = { + .name = "GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR", .vert = datatoc_gpu_shader_2D_vert_glsl, .frag = datatoc_gpu_shader_point_uniform_color_frag_glsl, }, [GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR] = { + .name = "GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR", .vert = datatoc_gpu_shader_2D_point_varying_size_varying_color_vert_glsl, .frag = datatoc_gpu_shader_point_varying_color_frag_glsl, }, [GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA] = { + .name = "GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA", .vert = datatoc_gpu_shader_2D_point_uniform_size_aa_vert_glsl, .frag = datatoc_gpu_shader_point_uniform_color_aa_frag_glsl, }, [GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA] = { + .name = "GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA", .vert = datatoc_gpu_shader_2D_point_uniform_size_outline_aa_vert_glsl, .frag = datatoc_gpu_shader_point_uniform_color_outline_aa_frag_glsl, }, [GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA] = { + .name = "GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA", .vert = datatoc_gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert_glsl, .frag = datatoc_gpu_shader_point_varying_color_outline_aa_frag_glsl, }, [GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR] = { + .name = "GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR", .vert = datatoc_gpu_shader_3D_vert_glsl, .frag = datatoc_gpu_shader_point_uniform_color_frag_glsl, }, [GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR] = { + .name = "GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR", .vert = datatoc_gpu_shader_3D_point_fixed_size_varying_color_vert_glsl, .frag = datatoc_gpu_shader_point_varying_color_frag_glsl, }, [GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR] = { + .name = "GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR", .vert = datatoc_gpu_shader_3D_point_varying_size_vert_glsl, .frag = datatoc_gpu_shader_point_uniform_color_frag_glsl, }, [GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR] = { + .name = "GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR", .vert = datatoc_gpu_shader_3D_point_varying_size_varying_color_vert_glsl, .frag = datatoc_gpu_shader_point_varying_color_frag_glsl, }, [GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA] = { + .name = "GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA", .vert = datatoc_gpu_shader_3D_point_uniform_size_aa_vert_glsl, .frag = datatoc_gpu_shader_point_uniform_color_aa_frag_glsl, }, [GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA] = { + .name = "GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA", .vert = datatoc_gpu_shader_3D_point_uniform_size_outline_aa_vert_glsl, .frag = datatoc_gpu_shader_point_uniform_color_outline_aa_frag_glsl, }, [GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE] = { + .name = "GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE", .vert = datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl, .frag = datatoc_gpu_shader_flat_color_frag_glsl, .defs = "#define UNIFORM_SCALE\n", @@ -377,32 +417,38 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { [GPU_SHADER_2D_AREA_EDGES] = { + .name = "GPU_SHADER_2D_AREA_EDGES", .vert = datatoc_gpu_shader_2D_area_borders_vert_glsl, .frag = datatoc_gpu_shader_2D_area_borders_frag_glsl, }, [GPU_SHADER_2D_WIDGET_BASE] = { + .name = "GPU_SHADER_2D_WIDGET_BASE", .vert = datatoc_gpu_shader_2D_widget_base_vert_glsl, .frag = datatoc_gpu_shader_2D_widget_base_frag_glsl, }, [GPU_SHADER_2D_WIDGET_BASE_INST] = { + .name = "GPU_SHADER_2D_WIDGET_BASE_INST", .vert = datatoc_gpu_shader_2D_widget_base_vert_glsl, .frag = datatoc_gpu_shader_2D_widget_base_frag_glsl, .defs = "#define USE_INSTANCE\n", }, [GPU_SHADER_2D_WIDGET_SHADOW] = { + .name = "GPU_SHADER_2D_WIDGET_SHADOW", .vert = datatoc_gpu_shader_2D_widget_shadow_vert_glsl, .frag = datatoc_gpu_shader_2D_widget_shadow_frag_glsl, }, [GPU_SHADER_2D_NODELINK] = { + .name = "GPU_SHADER_2D_NODELINK", .vert = datatoc_gpu_shader_2D_nodelink_vert_glsl, .frag = datatoc_gpu_shader_2D_nodelink_frag_glsl, }, [GPU_SHADER_2D_NODELINK_INST] = { + .name = "GPU_SHADER_2D_NODELINK_INST", .vert = datatoc_gpu_shader_2D_nodelink_vert_glsl, .frag = datatoc_gpu_shader_2D_nodelink_frag_glsl, .defs = "#define USE_INSTANCE\n", @@ -410,43 +456,51 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { [GPU_SHADER_2D_UV_UNIFORM_COLOR] = { + .name = "GPU_SHADER_2D_UV_UNIFORM_COLOR", .vert = datatoc_gpu_shader_2D_vert_glsl, .frag = datatoc_gpu_shader_uniform_color_frag_glsl, .defs = "#define UV_POS\n", }, [GPU_SHADER_2D_UV_VERTS] = { + .name = "GPU_SHADER_2D_UV_VERTS", .vert = datatoc_gpu_shader_2D_edituvs_points_vert_glsl, .frag = datatoc_gpu_shader_point_varying_color_varying_outline_aa_frag_glsl, }, [GPU_SHADER_2D_UV_FACEDOTS] = { + .name = "GPU_SHADER_2D_UV_FACEDOTS", .vert = datatoc_gpu_shader_2D_edituvs_facedots_vert_glsl, .frag = datatoc_gpu_shader_point_varying_color_frag_glsl, }, [GPU_SHADER_2D_UV_EDGES] = { + .name = "GPU_SHADER_2D_UV_EDGES", .vert = datatoc_gpu_shader_2D_edituvs_edges_vert_glsl, .frag = datatoc_gpu_shader_2D_edituvs_edges_frag_glsl, }, [GPU_SHADER_2D_UV_EDGES_SMOOTH] = { + .name = "GPU_SHADER_2D_UV_EDGES_SMOOTH", .vert = datatoc_gpu_shader_2D_edituvs_edges_vert_glsl, .frag = datatoc_gpu_shader_2D_edituvs_edges_frag_glsl, .defs = "#define SMOOTH_COLOR\n", }, [GPU_SHADER_2D_UV_FACES] = { + .name = "GPU_SHADER_2D_UV_FACES", .vert = datatoc_gpu_shader_2D_edituvs_faces_vert_glsl, .frag = datatoc_gpu_shader_flat_color_frag_glsl, }, [GPU_SHADER_2D_UV_FACES_STRETCH_AREA] = { + .name = "GPU_SHADER_2D_UV_FACES_STRETCH_AREA", .vert = datatoc_gpu_shader_2D_edituvs_stretch_vert_glsl, .frag = datatoc_gpu_shader_2D_smooth_color_frag_glsl, }, [GPU_SHADER_2D_UV_FACES_STRETCH_ANGLE] = { + .name = "GPU_SHADER_2D_UV_FACES_STRETCH_ANGLE", .vert = datatoc_gpu_shader_2D_edituvs_stretch_vert_glsl, .frag = datatoc_gpu_shader_2D_smooth_color_frag_glsl, .defs = "#define STRETCH_ANGLE\n", @@ -454,6 +508,7 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { [GPU_SHADER_GPENCIL_STROKE] = { + .name = "GPU_SHADER_GPENCIL_STROKE", .vert = datatoc_gpu_shader_gpencil_stroke_vert_glsl, .geom = datatoc_gpu_shader_gpencil_stroke_geom_glsl, .frag = datatoc_gpu_shader_gpencil_stroke_frag_glsl, @@ -461,6 +516,7 @@ static const GPUShaderStages builtin_shader_stages[GPU_SHADER_BUILTIN_LEN] = { [GPU_SHADER_GPENCIL_FILL] = { + .name = "GPU_SHADER_GPENCIL_FILL", .vert = datatoc_gpu_shader_gpencil_fill_vert_glsl, .frag = datatoc_gpu_shader_gpencil_fill_frag_glsl, }, @@ -478,12 +534,14 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader, /* common case */ if (sh_cfg == GPU_SHADER_CFG_DEFAULT) { - *sh_p = GPU_shader_create_from_arrays({ - .vert = (const char *[]){stages->vert, NULL}, - .geom = (const char *[]){stages->geom, NULL}, - .frag = (const char *[]){datatoc_gpu_shader_colorspace_lib_glsl, stages->frag, NULL}, - .defs = (const char *[]){stages->defs, NULL}, - }); + *sh_p = GPU_shader_create_from_arrays_named( + stages->name, + { + .vert = (const char *[]){stages->vert, NULL}, + .geom = (const char *[]){stages->geom, NULL}, + .frag = (const char *[]){datatoc_gpu_shader_colorspace_lib_glsl, stages->frag, NULL}, + .defs = (const char *[]){stages->defs, NULL}, + }); } else if (sh_cfg == GPU_SHADER_CFG_CLIPPED) { /* Remove eventually, for now ensure support for each shader has been added. */ @@ -499,12 +557,14 @@ GPUShader *GPU_shader_get_builtin_shader_with_config(eGPUBuiltinShader shader, const char *world_clip_lib = datatoc_gpu_shader_cfg_world_clip_lib_glsl; const char *world_clip_def = "#define USE_WORLD_CLIP_PLANES\n"; /* In rare cases geometry shaders calculate clipping themselves. */ - *sh_p = GPU_shader_create_from_arrays({ - .vert = (const char *[]){world_clip_lib, stages->vert, NULL}, - .geom = (const char *[]){stages->geom ? world_clip_lib : NULL, stages->geom, NULL}, - .frag = (const char *[]){datatoc_gpu_shader_colorspace_lib_glsl, stages->frag, NULL}, - .defs = (const char *[]){world_clip_def, stages->defs, NULL}, - }); + *sh_p = GPU_shader_create_from_arrays_named( + stages->name, + { + .vert = (const char *[]){world_clip_lib, stages->vert, NULL}, + .geom = (const char *[]){stages->geom ? world_clip_lib : NULL, stages->geom, NULL}, + .frag = (const char *[]){datatoc_gpu_shader_colorspace_lib_glsl, stages->frag, NULL}, + .defs = (const char *[]){world_clip_def, stages->defs, NULL}, + }); } else { BLI_assert(0); |