diff options
Diffstat (limited to 'source/blender')
-rw-r--r-- | source/blender/gpu/intern/gpu_shader.c | 687 |
1 files changed, 389 insertions, 298 deletions
diff --git a/source/blender/gpu/intern/gpu_shader.c b/source/blender/gpu/intern/gpu_shader.c index 5d5084c4eb9..45c0996bcd2 100644 --- a/source/blender/gpu/intern/gpu_shader.c +++ b/source/blender/gpu/intern/gpu_shader.c @@ -187,8 +187,9 @@ static uint g_shaderid = 0; typedef struct { const char *vert; + /** Optional. */ + const char *geom; const char *frag; - const char *geom; /* geometry stage runs between vert & frag, but is less common, so it goes last */ } GPUShaderStages; static void shader_print_errors(const char *task, const char *log, const char **code, int totcode) @@ -676,300 +677,390 @@ int GPU_shader_get_attribute(GPUShader *shader, const char *name) } static const GPUShaderStages builtin_shader_stages[GPU_NUM_BUILTIN_SHADERS] = { - [GPU_SHADER_TEXT] = - { datatoc_gpu_shader_text_vert_glsl, - datatoc_gpu_shader_text_frag_glsl, - datatoc_gpu_shader_text_geom_glsl }, - [GPU_SHADER_TEXT_SIMPLE] = - { datatoc_gpu_shader_text_simple_vert_glsl, - datatoc_gpu_shader_text_frag_glsl, - datatoc_gpu_shader_text_simple_geom_glsl }, - [GPU_SHADER_KEYFRAME_DIAMOND] = - { datatoc_gpu_shader_keyframe_diamond_vert_glsl, - datatoc_gpu_shader_keyframe_diamond_frag_glsl }, - [GPU_SHADER_EDGES_FRONT_BACK_PERSP] = - { datatoc_gpu_shader_edges_front_back_persp_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl, /* this version is */ - datatoc_gpu_shader_edges_front_back_persp_geom_glsl }, /* magical but slooow */ - [GPU_SHADER_EDGES_FRONT_BACK_ORTHO] = - { datatoc_gpu_shader_edges_front_back_ortho_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl }, - [GPU_SHADER_EDGES_OVERLAY_SIMPLE] = - { datatoc_gpu_shader_3D_vert_glsl, - datatoc_gpu_shader_edges_overlay_frag_glsl, - datatoc_gpu_shader_edges_overlay_simple_geom_glsl }, - [GPU_SHADER_EDGES_OVERLAY] = - { datatoc_gpu_shader_edges_overlay_vert_glsl, - datatoc_gpu_shader_edges_overlay_frag_glsl, - datatoc_gpu_shader_edges_overlay_geom_glsl }, - [GPU_SHADER_SIMPLE_LIGHTING] = - { datatoc_gpu_shader_3D_normal_vert_glsl, - datatoc_gpu_shader_simple_lighting_frag_glsl }, + [GPU_SHADER_TEXT] = { + .vert = datatoc_gpu_shader_text_vert_glsl, + .geom = datatoc_gpu_shader_text_geom_glsl, + .frag = datatoc_gpu_shader_text_frag_glsl, + }, + [GPU_SHADER_TEXT_SIMPLE] = { + .vert = datatoc_gpu_shader_text_simple_vert_glsl, + .geom = datatoc_gpu_shader_text_simple_geom_glsl, + .frag = datatoc_gpu_shader_text_frag_glsl, + }, + [GPU_SHADER_KEYFRAME_DIAMOND] = { + .vert = datatoc_gpu_shader_keyframe_diamond_vert_glsl, + .frag = datatoc_gpu_shader_keyframe_diamond_frag_glsl, + }, + /* This version is magical but slow! */ + [GPU_SHADER_EDGES_FRONT_BACK_PERSP] = { + .vert = datatoc_gpu_shader_edges_front_back_persp_vert_glsl, + .geom = datatoc_gpu_shader_edges_front_back_persp_geom_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + [GPU_SHADER_EDGES_FRONT_BACK_ORTHO] = { + .vert = datatoc_gpu_shader_edges_front_back_ortho_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + [GPU_SHADER_EDGES_OVERLAY_SIMPLE] = { + .vert = datatoc_gpu_shader_3D_vert_glsl, + .geom = datatoc_gpu_shader_edges_overlay_simple_geom_glsl, + .frag = datatoc_gpu_shader_edges_overlay_frag_glsl, + }, + [GPU_SHADER_EDGES_OVERLAY] = { + .vert = datatoc_gpu_shader_edges_overlay_vert_glsl, + .geom = datatoc_gpu_shader_edges_overlay_geom_glsl, + .frag = datatoc_gpu_shader_edges_overlay_frag_glsl, + }, + [GPU_SHADER_SIMPLE_LIGHTING] = { + .vert = datatoc_gpu_shader_3D_normal_vert_glsl, + .frag = datatoc_gpu_shader_simple_lighting_frag_glsl, + }, /* Use 'USE_FLAT_NORMAL' to make flat shader from smooth */ - [GPU_SHADER_SIMPLE_LIGHTING_FLAT_COLOR] = - { datatoc_gpu_shader_3D_normal_smooth_color_vert_glsl, - datatoc_gpu_shader_simple_lighting_smooth_color_frag_glsl }, - [GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR] = - { datatoc_gpu_shader_3D_normal_smooth_color_vert_glsl, - datatoc_gpu_shader_simple_lighting_smooth_color_frag_glsl }, - [GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR_ALPHA] = - { datatoc_gpu_shader_3D_normal_smooth_color_vert_glsl, - datatoc_gpu_shader_simple_lighting_smooth_color_alpha_frag_glsl }, - - [GPU_SHADER_2D_IMAGE_MASK_UNIFORM_COLOR] = - { datatoc_gpu_shader_3D_image_vert_glsl, - datatoc_gpu_shader_image_mask_uniform_color_frag_glsl }, - [GPU_SHADER_3D_IMAGE_MODULATE_ALPHA] = - { datatoc_gpu_shader_3D_image_vert_glsl, - datatoc_gpu_shader_image_modulate_alpha_frag_glsl }, - [GPU_SHADER_3D_IMAGE_DEPTH] = - { datatoc_gpu_shader_3D_image_vert_glsl, - datatoc_gpu_shader_image_depth_linear_frag_glsl }, - [GPU_SHADER_3D_IMAGE_DEPTH_COPY] = - { datatoc_gpu_shader_3D_image_vert_glsl, - datatoc_gpu_shader_image_depth_copy_frag_glsl }, - [GPU_SHADER_2D_IMAGE_MULTISAMPLE_2] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_image_multisample_resolve_frag_glsl }, - [GPU_SHADER_2D_IMAGE_MULTISAMPLE_4] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_image_multisample_resolve_frag_glsl }, - [GPU_SHADER_2D_IMAGE_MULTISAMPLE_8] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_image_multisample_resolve_frag_glsl }, - [GPU_SHADER_2D_IMAGE_MULTISAMPLE_16] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_image_multisample_resolve_frag_glsl }, - [GPU_SHADER_2D_IMAGE_MULTISAMPLE_2_DEPTH_TEST] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_image_multisample_resolve_frag_glsl }, - [GPU_SHADER_2D_IMAGE_MULTISAMPLE_4_DEPTH_TEST] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_image_multisample_resolve_frag_glsl }, - [GPU_SHADER_2D_IMAGE_MULTISAMPLE_8_DEPTH_TEST] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_image_multisample_resolve_frag_glsl }, - [GPU_SHADER_2D_IMAGE_MULTISAMPLE_16_DEPTH_TEST] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_image_multisample_resolve_frag_glsl }, - - [GPU_SHADER_2D_IMAGE_INTERLACE] = - { datatoc_gpu_shader_2D_image_vert_glsl, - datatoc_gpu_shader_image_interlace_frag_glsl }, - [GPU_SHADER_2D_CHECKER] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_checker_frag_glsl }, - - [GPU_SHADER_2D_DIAG_STRIPES] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_diag_stripes_frag_glsl }, - - [GPU_SHADER_2D_UNIFORM_COLOR] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_uniform_color_frag_glsl }, - [GPU_SHADER_2D_FLAT_COLOR] = - { datatoc_gpu_shader_2D_flat_color_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl }, - [GPU_SHADER_2D_SMOOTH_COLOR] = - { datatoc_gpu_shader_2D_smooth_color_vert_glsl, - datatoc_gpu_shader_2D_smooth_color_frag_glsl }, - [GPU_SHADER_2D_SMOOTH_COLOR_DITHER] = - { datatoc_gpu_shader_2D_smooth_color_vert_glsl, - datatoc_gpu_shader_2D_smooth_color_dithered_frag_glsl }, - [GPU_SHADER_2D_IMAGE_LINEAR_TO_SRGB] = - { datatoc_gpu_shader_2D_image_vert_glsl, - datatoc_gpu_shader_image_linear_frag_glsl }, - [GPU_SHADER_2D_IMAGE] = - { datatoc_gpu_shader_2D_image_vert_glsl, - datatoc_gpu_shader_image_frag_glsl }, - [GPU_SHADER_2D_IMAGE_COLOR] = - { datatoc_gpu_shader_2D_image_vert_glsl, - datatoc_gpu_shader_image_color_frag_glsl }, - [GPU_SHADER_2D_IMAGE_DESATURATE_COLOR] = - { datatoc_gpu_shader_2D_image_vert_glsl, - datatoc_gpu_shader_image_desaturate_frag_glsl }, - [GPU_SHADER_2D_IMAGE_ALPHA_COLOR] = - { datatoc_gpu_shader_2D_image_vert_glsl, - datatoc_gpu_shader_image_alpha_color_frag_glsl }, - [GPU_SHADER_2D_IMAGE_SHUFFLE_COLOR] = - { datatoc_gpu_shader_2D_image_vert_glsl, - datatoc_gpu_shader_image_shuffle_color_frag_glsl }, - [GPU_SHADER_2D_IMAGE_RECT_COLOR] = - { datatoc_gpu_shader_2D_image_rect_vert_glsl, - datatoc_gpu_shader_image_color_frag_glsl }, - [GPU_SHADER_2D_IMAGE_MULTI_RECT_COLOR] = - { datatoc_gpu_shader_2D_image_multi_rect_vert_glsl, - datatoc_gpu_shader_image_varying_color_frag_glsl }, - - [GPU_SHADER_3D_UNIFORM_COLOR] = - { datatoc_gpu_shader_3D_vert_glsl, - datatoc_gpu_shader_uniform_color_frag_glsl }, - [GPU_SHADER_3D_UNIFORM_COLOR_BACKGROUND] = - { datatoc_gpu_shader_3D_vert_glsl, - datatoc_gpu_shader_uniform_color_frag_glsl }, - [GPU_SHADER_3D_FLAT_COLOR] = - { datatoc_gpu_shader_3D_flat_color_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl }, - [GPU_SHADER_3D_SMOOTH_COLOR] = - { datatoc_gpu_shader_3D_smooth_color_vert_glsl, - datatoc_gpu_shader_3D_smooth_color_frag_glsl }, - [GPU_SHADER_3D_DEPTH_ONLY] = - { datatoc_gpu_shader_3D_vert_glsl, - datatoc_gpu_shader_depth_only_frag_glsl }, - [GPU_SHADER_3D_CLIPPED_UNIFORM_COLOR] = - { datatoc_gpu_shader_3D_clipped_uniform_color_vert_glsl, - datatoc_gpu_shader_uniform_color_frag_glsl }, - - [GPU_SHADER_3D_GROUNDPOINT] = - { datatoc_gpu_shader_3D_groundpoint_vert_glsl, - datatoc_gpu_shader_point_uniform_color_frag_glsl }, - [GPU_SHADER_3D_GROUNDLINE] = - { datatoc_gpu_shader_3D_passthrough_vert_glsl, - datatoc_gpu_shader_uniform_color_frag_glsl, - datatoc_gpu_shader_3D_groundline_geom_glsl }, - - [GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR] = - { datatoc_gpu_shader_2D_line_dashed_uniform_color_vert_glsl, - datatoc_gpu_shader_2D_line_dashed_frag_glsl, - datatoc_gpu_shader_2D_line_dashed_geom_glsl }, - [GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR] = - { datatoc_gpu_shader_3D_line_dashed_uniform_color_vert_glsl, - datatoc_gpu_shader_2D_line_dashed_frag_glsl, - datatoc_gpu_shader_2D_line_dashed_geom_glsl }, - - [GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR] = - { datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl, - datatoc_gpu_shader_simple_lighting_frag_glsl}, - [GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR] = - { datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl}, - [GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR] = - { datatoc_gpu_shader_instance_screenspace_variying_color_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl}, - [GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS] = - { datatoc_gpu_shader_instance_screen_aligned_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl}, - [GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED] = - { datatoc_gpu_shader_instance_screen_aligned_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl}, - - [GPU_SHADER_CAMERA] = - { datatoc_gpu_shader_instance_camera_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl}, - [GPU_SHADER_DISTANCE_LINES] = - { datatoc_gpu_shader_instance_distance_line_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl}, - - [GPU_SHADER_2D_POINT_FIXED_SIZE_UNIFORM_COLOR] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_point_uniform_color_frag_glsl }, - [GPU_SHADER_2D_POINT_VARYING_SIZE_VARYING_COLOR] = - { datatoc_gpu_shader_2D_point_varying_size_varying_color_vert_glsl, - datatoc_gpu_shader_point_varying_color_frag_glsl }, - [GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA] = - { datatoc_gpu_shader_2D_point_uniform_size_aa_vert_glsl, - datatoc_gpu_shader_point_uniform_color_aa_frag_glsl }, - [GPU_SHADER_2D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA] = - { datatoc_gpu_shader_2D_point_uniform_size_outline_aa_vert_glsl, - datatoc_gpu_shader_point_uniform_color_outline_aa_frag_glsl }, - [GPU_SHADER_2D_POINT_UNIFORM_SIZE_VARYING_COLOR_OUTLINE_AA] = - { datatoc_gpu_shader_2D_point_uniform_size_varying_color_outline_aa_vert_glsl, - datatoc_gpu_shader_point_varying_color_outline_aa_frag_glsl }, - [GPU_SHADER_3D_POINT_FIXED_SIZE_UNIFORM_COLOR] = - { datatoc_gpu_shader_3D_vert_glsl, - datatoc_gpu_shader_point_uniform_color_frag_glsl }, - [GPU_SHADER_3D_POINT_FIXED_SIZE_VARYING_COLOR] = - { datatoc_gpu_shader_3D_point_fixed_size_varying_color_vert_glsl, - datatoc_gpu_shader_point_varying_color_frag_glsl }, - [GPU_SHADER_3D_POINT_VARYING_SIZE_UNIFORM_COLOR] = - { datatoc_gpu_shader_3D_point_varying_size_vert_glsl, - datatoc_gpu_shader_point_uniform_color_frag_glsl }, - [GPU_SHADER_3D_POINT_VARYING_SIZE_VARYING_COLOR] = - { datatoc_gpu_shader_3D_point_varying_size_varying_color_vert_glsl, - datatoc_gpu_shader_point_varying_color_frag_glsl }, - [GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_AA] = - { datatoc_gpu_shader_3D_point_uniform_size_aa_vert_glsl, - datatoc_gpu_shader_point_uniform_color_aa_frag_glsl }, - [GPU_SHADER_3D_POINT_UNIFORM_SIZE_UNIFORM_COLOR_OUTLINE_AA] = - { datatoc_gpu_shader_3D_point_uniform_size_outline_aa_vert_glsl, - datatoc_gpu_shader_point_uniform_color_outline_aa_frag_glsl }, - - [GPU_SHADER_INSTANCE_UNIFORM_COLOR] = - { datatoc_gpu_shader_instance_vert_glsl, - datatoc_gpu_shader_uniform_color_frag_glsl }, - [GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE] = - { datatoc_gpu_shader_instance_variying_size_variying_id_vert_glsl, - datatoc_gpu_shader_flat_id_frag_glsl }, - [GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SIZE] = - { datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl }, - [GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE] = - { datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl }, - [GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR] = - { datatoc_gpu_shader_instance_edges_variying_color_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl, - datatoc_gpu_shader_instance_edges_variying_color_geom_glsl}, - - [GPU_SHADER_2D_AREA_EDGES] = - { datatoc_gpu_shader_2D_area_borders_vert_glsl, - datatoc_gpu_shader_2D_area_borders_frag_glsl}, - [GPU_SHADER_2D_WIDGET_BASE] = - { datatoc_gpu_shader_2D_widget_base_vert_glsl, - datatoc_gpu_shader_2D_widget_base_frag_glsl}, - [GPU_SHADER_2D_WIDGET_BASE_INST] = - { datatoc_gpu_shader_2D_widget_base_vert_glsl, - datatoc_gpu_shader_2D_widget_base_frag_glsl}, - [GPU_SHADER_2D_WIDGET_SHADOW] = - { datatoc_gpu_shader_2D_widget_shadow_vert_glsl, - datatoc_gpu_shader_2D_widget_shadow_frag_glsl }, - [GPU_SHADER_2D_NODELINK] = - { datatoc_gpu_shader_2D_nodelink_vert_glsl, - datatoc_gpu_shader_2D_nodelink_frag_glsl }, - [GPU_SHADER_2D_NODELINK_INST] = - { datatoc_gpu_shader_2D_nodelink_vert_glsl, - datatoc_gpu_shader_2D_nodelink_frag_glsl }, - - [GPU_SHADER_2D_UV_UNIFORM_COLOR] = - { datatoc_gpu_shader_2D_vert_glsl, - datatoc_gpu_shader_uniform_color_frag_glsl }, - [GPU_SHADER_2D_UV_VERTS] = - { datatoc_gpu_shader_2D_edituvs_points_vert_glsl, - datatoc_gpu_shader_point_varying_color_varying_outline_aa_frag_glsl }, - [GPU_SHADER_2D_UV_FACEDOTS] = - { datatoc_gpu_shader_2D_edituvs_facedots_vert_glsl, - datatoc_gpu_shader_point_varying_color_frag_glsl }, - [GPU_SHADER_2D_UV_EDGES] = - { datatoc_gpu_shader_2D_edituvs_edges_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl }, - [GPU_SHADER_2D_UV_EDGES_SMOOTH] = - { datatoc_gpu_shader_2D_edituvs_edges_vert_glsl, - datatoc_gpu_shader_2D_smooth_color_frag_glsl }, - [GPU_SHADER_2D_UV_FACES] = - { datatoc_gpu_shader_2D_edituvs_faces_vert_glsl, - datatoc_gpu_shader_flat_color_frag_glsl }, - [GPU_SHADER_2D_UV_FACES_STRETCH_AREA] = - { datatoc_gpu_shader_2D_edituvs_stretch_vert_glsl, - datatoc_gpu_shader_2D_smooth_color_frag_glsl }, - [GPU_SHADER_2D_UV_FACES_STRETCH_ANGLE] = - { datatoc_gpu_shader_2D_edituvs_stretch_vert_glsl, - datatoc_gpu_shader_2D_smooth_color_frag_glsl }, - - [GPU_SHADER_3D_FLAT_SELECT_ID] = - { datatoc_gpu_shader_3D_selection_id_vert_glsl, - datatoc_gpu_shader_selection_id_frag_glsl }, - [GPU_SHADER_3D_UNIFORM_SELECT_ID] = - { datatoc_gpu_shader_3D_selection_id_vert_glsl, - datatoc_gpu_shader_selection_id_frag_glsl }, - - [GPU_SHADER_GPENCIL_STROKE] = - { datatoc_gpu_shader_gpencil_stroke_vert_glsl, - datatoc_gpu_shader_gpencil_stroke_frag_glsl, - datatoc_gpu_shader_gpencil_stroke_geom_glsl }, - - [GPU_SHADER_GPENCIL_FILL] = - { datatoc_gpu_shader_gpencil_fill_vert_glsl, - datatoc_gpu_shader_gpencil_fill_frag_glsl }, + [GPU_SHADER_SIMPLE_LIGHTING_FLAT_COLOR] = { + .vert = datatoc_gpu_shader_3D_normal_smooth_color_vert_glsl, + .frag = datatoc_gpu_shader_simple_lighting_smooth_color_frag_glsl, + }, + [GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR] = { + .vert = datatoc_gpu_shader_3D_normal_smooth_color_vert_glsl, + .frag = datatoc_gpu_shader_simple_lighting_smooth_color_frag_glsl, + }, + [GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR_ALPHA] = { + .vert = datatoc_gpu_shader_3D_normal_smooth_color_vert_glsl, + .frag = datatoc_gpu_shader_simple_lighting_smooth_color_alpha_frag_glsl, + }, + + [GPU_SHADER_2D_IMAGE_MASK_UNIFORM_COLOR] = { + .vert = datatoc_gpu_shader_3D_image_vert_glsl, + .frag = datatoc_gpu_shader_image_mask_uniform_color_frag_glsl, + }, + [GPU_SHADER_3D_IMAGE_MODULATE_ALPHA] = { + .vert = datatoc_gpu_shader_3D_image_vert_glsl, + .frag = datatoc_gpu_shader_image_modulate_alpha_frag_glsl, + }, + [GPU_SHADER_3D_IMAGE_DEPTH] = { + .vert = datatoc_gpu_shader_3D_image_vert_glsl, + .frag = datatoc_gpu_shader_image_depth_linear_frag_glsl, + }, + [GPU_SHADER_3D_IMAGE_DEPTH_COPY] = { + .vert = datatoc_gpu_shader_3D_image_vert_glsl, + .frag = datatoc_gpu_shader_image_depth_copy_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_MULTISAMPLE_2] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_image_multisample_resolve_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_MULTISAMPLE_4] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_image_multisample_resolve_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_MULTISAMPLE_8] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_image_multisample_resolve_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_MULTISAMPLE_16] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_image_multisample_resolve_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_MULTISAMPLE_2_DEPTH_TEST] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_image_multisample_resolve_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_MULTISAMPLE_4_DEPTH_TEST] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_image_multisample_resolve_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_MULTISAMPLE_8_DEPTH_TEST] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_image_multisample_resolve_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_MULTISAMPLE_16_DEPTH_TEST] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_image_multisample_resolve_frag_glsl, + }, + + [GPU_SHADER_2D_IMAGE_INTERLACE] = { + .vert = datatoc_gpu_shader_2D_image_vert_glsl, + .frag = datatoc_gpu_shader_image_interlace_frag_glsl, + }, + [GPU_SHADER_2D_CHECKER] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_checker_frag_glsl, + }, + + [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] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_uniform_color_frag_glsl, + }, + [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] = { + .vert = datatoc_gpu_shader_2D_smooth_color_vert_glsl, + .frag = datatoc_gpu_shader_2D_smooth_color_frag_glsl, + }, + [GPU_SHADER_2D_SMOOTH_COLOR_DITHER] = { + .vert = datatoc_gpu_shader_2D_smooth_color_vert_glsl, + .frag = datatoc_gpu_shader_2D_smooth_color_dithered_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_LINEAR_TO_SRGB] = { + .vert = datatoc_gpu_shader_2D_image_vert_glsl, + .frag = datatoc_gpu_shader_image_linear_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE] = { + .vert = datatoc_gpu_shader_2D_image_vert_glsl, + .frag = datatoc_gpu_shader_image_frag_glsl, + }, + [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] = { + .vert = datatoc_gpu_shader_2D_image_vert_glsl, + .frag = datatoc_gpu_shader_image_desaturate_frag_glsl, + }, + [GPU_SHADER_2D_IMAGE_ALPHA_COLOR] = { + .vert = datatoc_gpu_shader_2D_image_vert_glsl, + .frag = datatoc_gpu_shader_image_alpha_color_frag_glsl, + }, + [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] = { + .vert = datatoc_gpu_shader_2D_image_rect_vert_glsl, + .frag = datatoc_gpu_shader_image_color_frag_glsl, + }, + [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] = { + .vert = datatoc_gpu_shader_3D_vert_glsl, + .frag = datatoc_gpu_shader_uniform_color_frag_glsl, + }, + [GPU_SHADER_3D_UNIFORM_COLOR_BACKGROUND] = { + .vert = datatoc_gpu_shader_3D_vert_glsl, + .frag = datatoc_gpu_shader_uniform_color_frag_glsl, + }, + [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] = { + .vert = datatoc_gpu_shader_3D_smooth_color_vert_glsl, + .frag = datatoc_gpu_shader_3D_smooth_color_frag_glsl, + }, + [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] = { + .vert = datatoc_gpu_shader_3D_clipped_uniform_color_vert_glsl, + .frag = datatoc_gpu_shader_uniform_color_frag_glsl, + }, + + [GPU_SHADER_3D_GROUNDPOINT] = { + .vert= datatoc_gpu_shader_3D_groundpoint_vert_glsl, + .frag = datatoc_gpu_shader_point_uniform_color_frag_glsl, + }, + [GPU_SHADER_3D_GROUNDLINE] = { + .vert = datatoc_gpu_shader_3D_passthrough_vert_glsl, + .geom = datatoc_gpu_shader_3D_groundline_geom_glsl, + .frag = datatoc_gpu_shader_uniform_color_frag_glsl, + }, + + [GPU_SHADER_2D_LINE_DASHED_UNIFORM_COLOR] = { + .vert = datatoc_gpu_shader_2D_line_dashed_uniform_color_vert_glsl, + .geom = datatoc_gpu_shader_2D_line_dashed_geom_glsl, + .frag = datatoc_gpu_shader_2D_line_dashed_frag_glsl, + }, + [GPU_SHADER_3D_LINE_DASHED_UNIFORM_COLOR] = { + .vert = datatoc_gpu_shader_3D_line_dashed_uniform_color_vert_glsl, + .geom = datatoc_gpu_shader_2D_line_dashed_geom_glsl, + .frag = datatoc_gpu_shader_2D_line_dashed_frag_glsl, + }, + + [GPU_SHADER_3D_OBJECTSPACE_SIMPLE_LIGHTING_VARIYING_COLOR] = { + .vert = datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl, + .frag = datatoc_gpu_shader_simple_lighting_frag_glsl, + }, + [GPU_SHADER_3D_OBJECTSPACE_VARIYING_COLOR] = { + .vert = datatoc_gpu_shader_instance_objectspace_variying_color_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + [GPU_SHADER_3D_SCREENSPACE_VARIYING_COLOR] = { + .vert = datatoc_gpu_shader_instance_screenspace_variying_color_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + [GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED_AXIS] = { + .vert = datatoc_gpu_shader_instance_screen_aligned_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + [GPU_SHADER_3D_INSTANCE_SCREEN_ALIGNED] = { + .vert = datatoc_gpu_shader_instance_screen_aligned_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + + [GPU_SHADER_CAMERA] = { + .vert = datatoc_gpu_shader_instance_camera_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + [GPU_SHADER_DISTANCE_LINES] = { + .vert = datatoc_gpu_shader_instance_distance_line_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + + [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] = { + .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] = { + .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] = { + .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] = { + .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] = { + .vert = datatoc_gpu_shader_3D_vert_glsl, + .frag = datatoc_gpu_shader_point_uniform_color_frag_glsl, + }, + [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] = { + .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] = { + .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] = { + .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] = { + .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_UNIFORM_COLOR] = { + .vert = datatoc_gpu_shader_instance_vert_glsl, + .frag = datatoc_gpu_shader_uniform_color_frag_glsl, + }, + [GPU_SHADER_INSTANCE_VARIYING_ID_VARIYING_SIZE] = { + .vert = datatoc_gpu_shader_instance_variying_size_variying_id_vert_glsl, + .frag = datatoc_gpu_shader_flat_id_frag_glsl, + }, + [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, + }, + [GPU_SHADER_INSTANCE_VARIYING_COLOR_VARIYING_SCALE] = { + .vert = datatoc_gpu_shader_instance_variying_size_variying_color_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + [GPU_SHADER_INSTANCE_EDGES_VARIYING_COLOR] = { + .vert = datatoc_gpu_shader_instance_edges_variying_color_vert_glsl, + .geom = datatoc_gpu_shader_instance_edges_variying_color_geom_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + + [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] = { + .vert = datatoc_gpu_shader_2D_widget_base_vert_glsl, + .frag = datatoc_gpu_shader_2D_widget_base_frag_glsl, + }, + [GPU_SHADER_2D_WIDGET_BASE_INST] = { + .vert = datatoc_gpu_shader_2D_widget_base_vert_glsl, + .frag = datatoc_gpu_shader_2D_widget_base_frag_glsl, + }, + [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] = { + .vert = datatoc_gpu_shader_2D_nodelink_vert_glsl, + .frag = datatoc_gpu_shader_2D_nodelink_frag_glsl, + }, + [GPU_SHADER_2D_NODELINK_INST] = { + .vert = datatoc_gpu_shader_2D_nodelink_vert_glsl, + .frag = datatoc_gpu_shader_2D_nodelink_frag_glsl, + }, + + [GPU_SHADER_2D_UV_UNIFORM_COLOR] = { + .vert = datatoc_gpu_shader_2D_vert_glsl, + .frag = datatoc_gpu_shader_uniform_color_frag_glsl, + }, + [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] = { + .vert = datatoc_gpu_shader_2D_edituvs_facedots_vert_glsl, + .frag = datatoc_gpu_shader_point_varying_color_frag_glsl, + }, + [GPU_SHADER_2D_UV_EDGES] = { + .vert = datatoc_gpu_shader_2D_edituvs_edges_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_frag_glsl, + }, + [GPU_SHADER_2D_UV_EDGES_SMOOTH] = { + .vert = datatoc_gpu_shader_2D_edituvs_edges_vert_glsl, + .frag = datatoc_gpu_shader_2D_smooth_color_frag_glsl, + }, + [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] = { + .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] = { + .vert = datatoc_gpu_shader_2D_edituvs_stretch_vert_glsl, + .frag = datatoc_gpu_shader_2D_smooth_color_frag_glsl, + }, + + [GPU_SHADER_3D_FLAT_SELECT_ID] = { + .vert = datatoc_gpu_shader_3D_selection_id_vert_glsl, + .frag = datatoc_gpu_shader_selection_id_frag_glsl, + }, + [GPU_SHADER_3D_UNIFORM_SELECT_ID] = { + .vert = datatoc_gpu_shader_3D_selection_id_vert_glsl, + .frag = datatoc_gpu_shader_selection_id_frag_glsl, + }, + + [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, + }, + + [GPU_SHADER_GPENCIL_FILL] = { + .vert = datatoc_gpu_shader_gpencil_fill_vert_glsl, + .frag = datatoc_gpu_shader_gpencil_fill_frag_glsl, + }, }; /* just a few special cases */ @@ -1052,8 +1143,8 @@ GPUShader *GPU_shader_get_builtin_shader(eGPUBuiltinShader shader) if (shader == GPU_SHADER_EDGES_FRONT_BACK_PERSP && !GLEW_VERSION_3_2) { /* TODO: remove after switch to core profile (maybe) */ static const GPUShaderStages legacy_fancy_edges = { - datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl, - datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl, + .vert = datatoc_gpu_shader_edges_front_back_persp_legacy_vert_glsl, + .frag = datatoc_gpu_shader_flat_color_alpha_test_0_frag_glsl, }; stages = &legacy_fancy_edges; } @@ -1062,8 +1153,8 @@ GPUShader *GPU_shader_get_builtin_shader(eGPUBuiltinShader shader) /* Dashed need geometry shader, which are not supported by legacy OpenGL, fallback to solid lines. */ /* TODO: remove after switch to core profile (maybe) */ static const GPUShaderStages legacy_dashed_lines = { - datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl, - datatoc_gpu_shader_2D_line_dashed_frag_glsl, + .vert = datatoc_gpu_shader_3D_line_dashed_uniform_color_legacy_vert_glsl, + .frag = datatoc_gpu_shader_2D_line_dashed_frag_glsl, }; stages = &legacy_dashed_lines; } |