From 091004f1b84387db1ca3c31cc2669e40b4df84db Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Foucault?= Date: Tue, 12 Nov 2024 18:53:34 +0100 Subject: [PATCH] GPU: GLSL compilation as C++ for gpu static shaders Allow compilation of shaders using C++ for linting and IDE support. Related #127983 Pull Request: https://projects.blender.org/blender/blender/pulls/128724 --- CMakeLists.txt | 16 +++ source/blender/CMakeLists.txt | 1 + .../engines/overlay/overlay_next_shader.cc | 2 +- .../shaders/infos/overlay_armature_info.hh | 4 +- .../shaders/infos/overlay_edit_mode_info.hh | 12 +- .../shaders/infos/overlay_extra_info.hh | 2 +- .../shaders/infos/overlay_outline_info.hh | 2 +- .../shaders/infos/overlay_wireframe_info.hh | 2 +- .../shaders/infos/workbench_shadow_info.hh | 2 +- .../gpu/intern/gpu_shader_create_info.hh | 9 +- source/blender/gpu/shaders/CMakeLists.txt | 110 ++++++++++++++++++ .../common/gpu_shader_attribute_load_lib.glsl | 2 + .../gpu_shader_bicubic_sampler_lib.glsl | 2 + .../common/gpu_shader_common_color_ramp.glsl | 4 + .../common/gpu_shader_common_color_utils.glsl | 4 + .../common/gpu_shader_common_curves.glsl | 4 + .../common/gpu_shader_common_hash.glsl | 4 + .../common/gpu_shader_common_math.glsl | 4 + .../common/gpu_shader_common_math_utils.glsl | 4 + .../common/gpu_shader_common_mix_rgb.glsl | 4 + .../gpu_shader_debug_gradients_lib.glsl | 2 + .../common/gpu_shader_index_load_lib.glsl | 6 +- .../common/gpu_shader_math_rotation_lib.glsl | 8 +- .../shaders/common/gpu_shader_print_lib.glsl | 4 + .../common/gpu_shader_sequencer_lib.glsl | 4 + .../gpu_shader_shared_exponent_lib.glsl | 2 + .../shaders/common/gpu_shader_smaa_lib.glsl | 2 + .../shaders/common/gpu_shader_test_lib.glsl | 2 + .../common/gpu_shader_utildefines_lib.glsl | 2 + .../blender/gpu/shaders/gpu_glsl_cpp_stubs.hh | 5 +- .../gpu_shader_2D_area_borders_frag.glsl | 4 + .../gpu_shader_2D_area_borders_vert.glsl | 4 + .../gpu_shader_2D_image_rect_vert.glsl | 4 + .../gpu/shaders/gpu_shader_2D_image_vert.glsl | 9 +- .../gpu_shader_2D_line_dashed_frag.glsl | 4 + .../shaders/gpu_shader_2D_nodelink_frag.glsl | 5 +- .../shaders/gpu_shader_2D_nodelink_vert.glsl | 4 + ..._shader_2D_point_uniform_size_aa_vert.glsl | 4 + ...2D_point_uniform_size_outline_aa_vert.glsl | 4 + ...point_varying_size_varying_color_vert.glsl | 4 + .../gpu/shaders/gpu_shader_2D_vert.glsl | 4 + .../gpu_shader_2D_widget_base_frag.glsl | 4 + .../gpu_shader_2D_widget_base_vert.glsl | 6 +- .../gpu_shader_2D_widget_shadow_frag.glsl | 4 + .../gpu_shader_2D_widget_shadow_vert.glsl | 4 + ..._shader_3D_clipped_uniform_color_vert.glsl | 4 + .../gpu_shader_3D_flat_color_vert.glsl | 4 + .../gpu/shaders/gpu_shader_3D_image_vert.glsl | 4 + ...der_3D_line_dashed_uniform_color_vert.glsl | 4 + .../shaders/gpu_shader_3D_normal_vert.glsl | 4 + ..._shader_3D_point_uniform_size_aa_vert.glsl | 8 +- ...point_varying_size_varying_color_vert.glsl | 4 + .../shaders/gpu_shader_3D_polyline_frag.glsl | 4 + .../gpu_shader_3D_smooth_color_frag.glsl | 4 + .../gpu_shader_3D_smooth_color_vert.glsl | 4 + .../gpu/shaders/gpu_shader_3D_vert.glsl | 4 + .../gpu_shader_cfg_world_clip_lib.glsl | 30 +++-- .../gpu/shaders/gpu_shader_checker_frag.glsl | 4 + .../shaders/gpu_shader_colorspace_lib.glsl | 8 +- .../shaders/gpu_shader_depth_only_frag.glsl | 2 + .../shaders/gpu_shader_diag_stripes_frag.glsl | 4 + .../gpu_shader_display_fallback_frag.glsl | 4 + .../gpu_shader_display_fallback_vert.glsl | 4 + .../shaders/gpu_shader_flat_color_frag.glsl | 4 + .../gpu_shader_gpencil_stroke_frag.glsl | 4 + .../gpu_shader_gpencil_stroke_vert.glsl | 4 + .../gpu/shaders/gpu_shader_icon_frag.glsl | 4 + .../shaders/gpu_shader_icon_multi_vert.glsl | 4 + .../gpu/shaders/gpu_shader_icon_vert.glsl | 4 + .../shaders/gpu_shader_image_color_frag.glsl | 4 + .../gpu_shader_image_desaturate_frag.glsl | 4 + .../gpu/shaders/gpu_shader_image_frag.glsl | 4 + .../gpu_shader_image_overlays_merge_frag.glsl | 11 +- ...ader_image_overlays_stereo_merge_frag.glsl | 4 + .../gpu_shader_image_shuffle_color_frag.glsl | 4 + .../gpu_shader_index_2d_array_lines.glsl | 4 + .../gpu_shader_index_2d_array_points.glsl | 4 + .../gpu_shader_index_2d_array_tris.glsl | 4 + .../gpu_shader_keyframe_shape_frag.glsl | 4 + .../gpu_shader_keyframe_shape_vert.glsl | 4 + ...pu_shader_point_uniform_color_aa_frag.glsl | 4 + ...r_point_uniform_color_outline_aa_frag.glsl | 4 + .../gpu_shader_point_varying_color_frag.glsl | 13 +-- .../gpu_shader_sequencer_strips_frag.glsl | 6 +- .../gpu_shader_sequencer_strips_vert.glsl | 4 + .../gpu_shader_sequencer_thumbs_frag.glsl | 6 +- .../gpu_shader_sequencer_thumbs_vert.glsl | 4 + .../gpu_shader_simple_lighting_frag.glsl | 4 + .../gpu/shaders/gpu_shader_text_frag.glsl | 4 + .../gpu/shaders/gpu_shader_text_vert.glsl | 4 + .../gpu_shader_uniform_color_frag.glsl | 4 + .../gpu/shaders/infos/gpu_clip_planes_info.hh | 9 ++ .../gpu/shaders/infos/gpu_index_load_info.hh | 11 +- .../infos/gpu_shader_2D_area_borders_info.hh | 7 ++ .../infos/gpu_shader_2D_checker_info.hh | 7 ++ .../infos/gpu_shader_2D_diag_stripes_info.hh | 7 ++ ...u_shader_2D_image_desaturate_color_info.hh | 8 ++ .../shaders/infos/gpu_shader_2D_image_info.hh | 7 ++ ...gpu_shader_2D_image_overlays_merge_info.hh | 7 ++ ...der_2D_image_overlays_stereo_merge_info.hh | 7 ++ .../gpu_shader_2D_image_rect_color_info.hh | 7 ++ .../gpu_shader_2D_image_shuffle_color_info.hh | 8 ++ .../infos/gpu_shader_2D_nodelink_info.hh | 7 ++ ...oint_uniform_size_uniform_color_aa_info.hh | 8 ++ ...form_size_uniform_color_outline_aa_info.hh | 7 ++ ...D_point_varying_size_varying_color_info.hh | 7 ++ .../infos/gpu_shader_2D_widget_info.hh | 10 ++ .../infos/gpu_shader_3D_depth_only_info.hh | 8 ++ .../infos/gpu_shader_3D_flat_color_info.hh | 9 ++ .../shaders/infos/gpu_shader_3D_image_info.hh | 7 ++ .../shaders/infos/gpu_shader_3D_point_info.hh | 10 ++ .../infos/gpu_shader_3D_polyline_info.hh | 9 ++ .../infos/gpu_shader_3D_smooth_color_info.hh | 9 ++ .../infos/gpu_shader_3D_uniform_color_info.hh | 9 ++ .../infos/gpu_shader_gpencil_stroke_info.hh | 9 +- .../gpu/shaders/infos/gpu_shader_icon_info.hh | 8 ++ .../shaders/infos/gpu_shader_index_info.hh | 7 ++ .../infos/gpu_shader_keyframe_shape_info.hh | 7 ++ ...u_shader_line_dashed_uniform_color_info.hh | 8 ++ .../shaders/infos/gpu_shader_print_info.hh | 8 +- .../infos/gpu_shader_sequencer_info.hh | 7 ++ .../infos/gpu_shader_simple_lighting_info.hh | 7 ++ .../gpu/shaders/infos/gpu_shader_test_info.hh | 7 ++ .../gpu/shaders/infos/gpu_shader_text_info.hh | 8 ++ .../gpu_srgb_to_framebuffer_space_info.hh | 7 ++ 125 files changed, 722 insertions(+), 81 deletions(-) create mode 100644 source/blender/gpu/shaders/CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt index 6bfd9e512d9..12110075f60 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,10 @@ if(POLICY CMP0087) cmake_policy(SET CMP0087 NEW) endif() +# Allow to specify language per file. +if(POLICY CMP0119) + cmake_policy(SET CMP0119 NEW) +endif() # ----------------------------------------------------------------------------- # Load Blender's Local Macros @@ -883,6 +887,18 @@ mark_as_advanced( WITH_GPU_SHADER_ASSERT ) +if(POLICY CMP0119) + option(WITH_GPU_SHADER_CPP_COMPILATION "\ + Compiler shaders using C++. \ + Allows testing Metal compilation on other platform and enable C++ IDE support for shader code" + OFF + ) + mark_as_advanced(WITH_GPU_SHADER_CPP_COMPILATION) +else() + set(WITH_GPU_SHADER_CPP_COMPILATION OFF) +endif() + + # OpenGL if(NOT APPLE) option(WITH_OPENGL_BACKEND "Enable OpenGL support as graphic backend" ON) diff --git a/source/blender/CMakeLists.txt b/source/blender/CMakeLists.txt index 636de9aa40f..638c43d74f0 100644 --- a/source/blender/CMakeLists.txt +++ b/source/blender/CMakeLists.txt @@ -155,6 +155,7 @@ add_subdirectory(ikplugin) add_subdirectory(simulation) add_subdirectory(geometry) add_subdirectory(gpu) +add_subdirectory(gpu/shaders) add_subdirectory(imbuf) add_subdirectory(imbuf/intern/oiio) add_subdirectory(nodes) diff --git a/source/blender/draw/engines/overlay/overlay_next_shader.cc b/source/blender/draw/engines/overlay/overlay_next_shader.cc index c9137a9bc1b..1ac99e9a1d1 100644 --- a/source/blender/draw/engines/overlay/overlay_next_shader.cc +++ b/source/blender/draw/engines/overlay/overlay_next_shader.cc @@ -117,7 +117,7 @@ static void shader_patch_edit_mesh_normal_common(gpu::shader::ShaderCreateInfo & shader_patch_common(info); info.defines_.clear(); /* Removes WORKAROUND_INDEX_LOAD_INCLUDE. */ info.vertex_inputs_.clear(); - info.additional_info("gpu_index_load"); + info.additional_info("gpu_index_buffer_load"); info.storage_buf(1, Qualifier::READ, "float", "pos[]", Frequency::GEOMETRY); } diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh index 32d92e87c0b..4a9a0971b55 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_armature_info.hh @@ -135,7 +135,7 @@ VERTEX_SOURCE("overlay_armature_shape_outline_next_vert.glsl") FRAGMENT_SOURCE("overlay_armature_wire_frag.glsl") ADDITIONAL_INFO(overlay_frag_output) ADDITIONAL_INFO(overlay_armature_common) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_globals) GPU_SHADER_CREATE_END() @@ -255,7 +255,7 @@ FRAGMENT_SOURCE("overlay_armature_shape_wire_frag.glsl") TYPEDEF_SOURCE("overlay_shader_shared.h") ADDITIONAL_INFO(overlay_frag_output) ADDITIONAL_INFO(overlay_armature_common) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_globals) GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh index 4cf68042b0b..fc7726e5fd7 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh @@ -173,7 +173,7 @@ FRAGMENT_SOURCE("overlay_edit_mesh_frag.glsl") ADDITIONAL_INFO(draw_view) ADDITIONAL_INFO(draw_modelmat_new) ADDITIONAL_INFO(draw_resource_handle_new) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(overlay_edit_mesh_common) GPU_SHADER_CREATE_END() @@ -464,7 +464,7 @@ FRAGMENT_SOURCE("overlay_edit_uv_edges_next_frag.glsl") ADDITIONAL_INFO(draw_view) ADDITIONAL_INFO(draw_modelmat_new) ADDITIONAL_INFO(draw_resource_handle_new) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_globals) GPU_SHADER_CREATE_END() @@ -657,7 +657,7 @@ FRAGMENT_SOURCE("overlay_varying_color.glsl") ADDITIONAL_INFO(draw_view) ADDITIONAL_INFO(draw_modelmat_new) ADDITIONAL_INFO(draw_resource_handle_new) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_globals) GPU_SHADER_CREATE_END() @@ -738,7 +738,7 @@ FRAGMENT_SOURCE("overlay_varying_color.glsl") ADDITIONAL_INFO(draw_view) ADDITIONAL_INFO(draw_modelmat_new) ADDITIONAL_INFO(draw_resource_handle_new) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_globals) GPU_SHADER_CREATE_END() @@ -794,7 +794,7 @@ FRAGMENT_SOURCE("overlay_varying_color.glsl") ADDITIONAL_INFO(draw_view) ADDITIONAL_INFO(draw_modelmat_new) ADDITIONAL_INFO(draw_resource_handle_new) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_globals) GPU_SHADER_CREATE_END() @@ -1066,7 +1066,7 @@ FRAGMENT_SOURCE("overlay_depth_only_frag.glsl") ADDITIONAL_INFO(draw_globals) ADDITIONAL_INFO(draw_view) ADDITIONAL_INFO(draw_modelmat_new) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_resource_handle_new) GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_extra_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_extra_info.hh index c4aba12ca50..1dd5c74d8c7 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_extra_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_extra_info.hh @@ -282,7 +282,7 @@ FRAGMENT_OUT(0, VEC4, fragColor) VERTEX_SOURCE("overlay_motion_path_line_next_vert.glsl") FRAGMENT_SOURCE("overlay_motion_path_line_frag.glsl") ADDITIONAL_INFO(draw_view) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_globals) GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_outline_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_outline_info.hh index ee7312dfced..2eeac82d344 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_outline_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_outline_info.hh @@ -78,7 +78,7 @@ ADDITIONAL_INFO(draw_view) ADDITIONAL_INFO(draw_mesh_new) ADDITIONAL_INFO(draw_object_infos_new) ADDITIONAL_INFO(draw_resource_handle_new) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) STORAGE_BUF_FREQ(0, READ, float, pos[], GEOMETRY) PUSH_CONSTANT(IVEC2, gpu_attr_0) VERTEX_SOURCE("overlay_outline_prepass_wire_vert.glsl") diff --git a/source/blender/draw/engines/overlay/shaders/infos/overlay_wireframe_info.hh b/source/blender/draw/engines/overlay/shaders/infos/overlay_wireframe_info.hh index 1e44ffe6c47..da970005ec7 100644 --- a/source/blender/draw/engines/overlay/shaders/infos/overlay_wireframe_info.hh +++ b/source/blender/draw/engines/overlay/shaders/infos/overlay_wireframe_info.hh @@ -127,6 +127,6 @@ FRAGMENT_SOURCE("overlay_edit_uv_edges_next_frag.glsl") ADDITIONAL_INFO(draw_view) ADDITIONAL_INFO(draw_modelmat_new) ADDITIONAL_INFO(draw_resource_handle_new) -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_globals) GPU_SHADER_CREATE_END() diff --git a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh index 0606d621b7f..f4631c2a082 100644 --- a/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh +++ b/source/blender/draw/engines/workbench/shaders/infos/workbench_shadow_info.hh @@ -16,7 +16,7 @@ STORAGE_BUF_FREQ(3, READ, float, pos[], GEOMETRY) PUSH_CONSTANT(IVEC2, gpu_attr_3) UNIFORM_BUF(1, ShadowPassData, pass_data) TYPEDEF_SOURCE("workbench_shader_shared.h") -ADDITIONAL_INFO(gpu_index_load) +ADDITIONAL_INFO(gpu_index_buffer_load) ADDITIONAL_INFO(draw_view) ADDITIONAL_INFO(draw_modelmat_new) ADDITIONAL_INFO(draw_resource_handle_new) diff --git a/source/blender/gpu/intern/gpu_shader_create_info.hh b/source/blender/gpu/intern/gpu_shader_create_info.hh index c553b2f58fd..057afa4b9be 100644 --- a/source/blender/gpu/intern/gpu_shader_create_info.hh +++ b/source/blender/gpu/intern/gpu_shader_create_info.hh @@ -242,11 +242,12 @@ # define PUSH_CONSTANT(type, name) const type name = type(1); # define PUSH_CONSTANT_ARRAY(type, name, array_size) const type name[array_size] = {type(1)}; -# define UNIFORM_BUF(slot, type_name, name) const type_name name = {}; -# define UNIFORM_BUF_FREQ(slot, type_name, name, freq) const type_name name = {}; +# define UNIFORM_BUF(slot, type_name, name) const type_name name = {type_name()}; +# define UNIFORM_BUF_FREQ(slot, type_name, name, freq) const type_name name = {type_name()}; -# define STORAGE_BUF(slot, qualifiers, type_name, name) qualifiers type_name name = {}; -# define STORAGE_BUF_FREQ(slot, qualifiers, type_name, name, freq) qualifiers type_name name = {}; +# define STORAGE_BUF(slot, qualifiers, type_name, name) qualifiers type_name name = {type_name()}; +# define STORAGE_BUF_FREQ(slot, qualifiers, type_name, name, freq) \ + qualifiers type_name name = {type_name()}; # define SAMPLER(slot, type, name) _##type(sampler) name; # define SAMPLER_FREQ(slot, type, name, freq) _##type(sampler) name; diff --git a/source/blender/gpu/shaders/CMakeLists.txt b/source/blender/gpu/shaders/CMakeLists.txt new file mode 100644 index 00000000000..552fcf56735 --- /dev/null +++ b/source/blender/gpu/shaders/CMakeLists.txt @@ -0,0 +1,110 @@ +# SPDX-FileCopyrightText: 2024 Blender Authors +# +# SPDX-License-Identifier: GPL-2.0-or-later + +set(INC_GLSL + . + .. + ../intern + + common + infos +) + +set(SRC_GLSL_VERT + gpu_shader_2D_area_borders_vert.glsl + gpu_shader_2D_image_rect_vert.glsl + gpu_shader_2D_image_vert.glsl + gpu_shader_2D_nodelink_vert.glsl + gpu_shader_2D_point_uniform_size_aa_vert.glsl + gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl + gpu_shader_2D_point_varying_size_varying_color_vert.glsl + gpu_shader_2D_vert.glsl + gpu_shader_2D_widget_base_vert.glsl + gpu_shader_2D_widget_shadow_vert.glsl + gpu_shader_3D_clipped_uniform_color_vert.glsl + gpu_shader_3D_flat_color_vert.glsl + gpu_shader_3D_image_vert.glsl + gpu_shader_3D_line_dashed_uniform_color_vert.glsl + gpu_shader_3D_normal_vert.glsl + gpu_shader_3D_point_uniform_size_aa_vert.glsl + gpu_shader_3D_point_varying_size_varying_color_vert.glsl + gpu_shader_3D_smooth_color_vert.glsl + gpu_shader_display_fallback_vert.glsl + gpu_shader_gpencil_stroke_vert.glsl + gpu_shader_icon_multi_vert.glsl + gpu_shader_icon_vert.glsl + gpu_shader_keyframe_shape_vert.glsl + gpu_shader_sequencer_strips_vert.glsl + gpu_shader_sequencer_thumbs_vert.glsl + gpu_shader_text_vert.glsl +) + +set(SRC_GLSL_FRAG + gpu_shader_2D_area_borders_frag.glsl + gpu_shader_2D_line_dashed_frag.glsl + gpu_shader_2D_nodelink_frag.glsl + gpu_shader_2D_widget_base_frag.glsl + gpu_shader_2D_widget_shadow_frag.glsl + gpu_shader_3D_polyline_frag.glsl + gpu_shader_3D_smooth_color_frag.glsl + gpu_shader_checker_frag.glsl + gpu_shader_depth_only_frag.glsl + gpu_shader_diag_stripes_frag.glsl + gpu_shader_display_fallback_frag.glsl + gpu_shader_flat_color_frag.glsl + gpu_shader_gpencil_stroke_frag.glsl + gpu_shader_icon_frag.glsl + gpu_shader_image_color_frag.glsl + gpu_shader_image_desaturate_frag.glsl + gpu_shader_image_frag.glsl + gpu_shader_image_overlays_merge_frag.glsl + gpu_shader_image_overlays_stereo_merge_frag.glsl + gpu_shader_image_shuffle_color_frag.glsl + gpu_shader_keyframe_shape_frag.glsl + gpu_shader_point_uniform_color_aa_frag.glsl + gpu_shader_point_uniform_color_outline_aa_frag.glsl + gpu_shader_point_varying_color_frag.glsl + gpu_shader_sequencer_strips_frag.glsl + gpu_shader_sequencer_thumbs_frag.glsl + gpu_shader_simple_lighting_frag.glsl + gpu_shader_text_frag.glsl + gpu_shader_uniform_color_frag.glsl +) + +set(SRC_GLSL_COMP + # TODO rename them properly to enable compilatio + # gpu_shader_index_2d_array_lines.glsl + # gpu_shader_index_2d_array_points.glsl + # gpu_shader_index_2d_array_tris.glsl +) + +set(SRC_GLSL_LIB + common/gpu_shader_print_lib.glsl +) + +add_definitions(-DGPU_SHADER) + +function(compile_sources_as_cpp + executable + sources + define + ) + + foreach(glsl_file ${sources}) + set_source_files_properties(${glsl_file} PROPERTIES LANGUAGE CXX) + endforeach() + + add_library(${executable} OBJECT ${sources}) + set_target_properties(${executable} PROPERTIES LINKER_LANGUAGE CXX) + target_include_directories(${executable} PUBLIC ${INC_GLSL}) + target_compile_definitions(${executable} PRIVATE ${define}) +endfunction() + + +# Compile shaders with shader code. +if (WITH_GPU_SHADER_CPP_COMPILATION) + compile_sources_as_cpp(gpu_cpp_shaders_vert "${SRC_GLSL_VERT}" "GPU_VERTEX_SHADER") + compile_sources_as_cpp(gpu_cpp_shaders_frag "${SRC_GLSL_FRAG}" "GPU_FRAGMENT_SHADER") + compile_sources_as_cpp(gpu_cpp_shaders_lib "${SRC_GLSL_LIB}" "GPU_FRAGMENT_SHADER") +endif() diff --git a/source/blender/gpu/shaders/common/gpu_shader_attribute_load_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_attribute_load_lib.glsl index fee3d2eb7c4..6ac4279873f 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_attribute_load_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_attribute_load_lib.glsl @@ -4,6 +4,8 @@ #pragma once +#include "gpu_glsl_cpp_stubs.hh" + /** * Library to read packed vertex buffer data of a `gpu::Batch` using a SSBO rather than using input * assembly. It is **not** needed to use these macros if the data is known to be aligned and diff --git a/source/blender/gpu/shaders/common/gpu_shader_bicubic_sampler_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_bicubic_sampler_lib.glsl index c865e602bca..f771be97b98 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_bicubic_sampler_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_bicubic_sampler_lib.glsl @@ -4,6 +4,8 @@ #pragma once +#include "gpu_glsl_cpp_stubs.hh" + /** \param f: Offset from texel center in pixel space. */ void cubic_bspline_coefficients(vec2 f, out vec2 w0, out vec2 w1, out vec2 w2, out vec2 w3) { diff --git a/source/blender/gpu/shaders/common/gpu_shader_common_color_ramp.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_color_ramp.glsl index 9f42105d9fe..b61a27c78ec 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_common_color_ramp.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_common_color_ramp.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#pragma once + +#include "gpu_glsl_cpp_stubs.hh" + void valtorgb_opti_constant( float fac, float edge, vec4 color1, vec4 color2, out vec4 outcol, out float outalpha) { diff --git a/source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl index 571e4290733..f4509bf8b31 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_common_color_utils.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#pragma once + +#include "gpu_glsl_cpp_stubs.hh" + void rgb_to_hsv(vec4 rgb, out vec4 outcol) { float cmax, cmin, h, s, v, cdelta; diff --git a/source/blender/gpu/shaders/common/gpu_shader_common_curves.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_curves.glsl index e63ad4df409..49cc0f89101 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_common_curves.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_common_curves.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#pragma once + +#include "gpu_glsl_cpp_stubs.hh" + vec4 white_balance(vec4 color, vec4 black_level, vec4 white_level) { vec4 range = max(white_level - black_level, vec4(1e-5f)); diff --git a/source/blender/gpu/shaders/common/gpu_shader_common_hash.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_hash.glsl index e89a6642f22..6914c2c39d9 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_common_hash.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_common_hash.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#pragma once + +#include "gpu_glsl_cpp_stubs.hh" + /* ***** Jenkins Lookup3 Hash Functions ***** */ /* Source: http://burtleburtle.net/bob/c/lookup3.c */ diff --git a/source/blender/gpu/shaders/common/gpu_shader_common_math.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_math.glsl index 0329f39e327..775c20d1bce 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_common_math.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_common_math.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#pragma once + +#include "gpu_glsl_cpp_stubs.hh" + #include "gpu_shader_common_math_utils.glsl" void math_add(float a, float b, float c, out float result) diff --git a/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl index 4f6dcc7ca65..a156d478806 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_common_math_utils.glsl @@ -4,6 +4,10 @@ /* Float Math */ +#pragma once + +#include "gpu_glsl_cpp_stubs.hh" + /* WORKAROUND: To be removed once we port all code to use `gpu_shader_math_base_lib.glsl`. */ #ifndef GPU_SHADER_MATH_BASE_LIB_GLSL diff --git a/source/blender/gpu/shaders/common/gpu_shader_common_mix_rgb.glsl b/source/blender/gpu/shaders/common/gpu_shader_common_mix_rgb.glsl index 714cae53a68..09b16fb518d 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_common_mix_rgb.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_common_mix_rgb.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#pragma once + +#include "gpu_glsl_cpp_stubs.hh" + #include "gpu_shader_common_color_utils.glsl" void mix_blend(float fac, vec4 col1, vec4 col2, out vec4 outcol) diff --git a/source/blender/gpu/shaders/common/gpu_shader_debug_gradients_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_debug_gradients_lib.glsl index 529b9918968..be61dcad0cf 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_debug_gradients_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_debug_gradients_lib.glsl @@ -4,6 +4,8 @@ #pragma once +#include "gpu_glsl_cpp_stubs.hh" + /* * For debugging purpose mainly. * From https://www.shadertoy.com/view/4dsSzr diff --git a/source/blender/gpu/shaders/common/gpu_shader_index_load_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_index_load_lib.glsl index 8a791f8bc71..23e53fae996 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_index_load_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_index_load_lib.glsl @@ -4,6 +4,10 @@ #pragma once +#include "infos/gpu_index_load_info.hh" + +SHADER_LIBRARY_CREATE_INFO(gpu_index_buffer_load) + /** * Library to read the index buffer of a `gpu::Batch` using a SSBO rather than using `gl_VertexID`. * This is required for primitive expansion without geometry shader. @@ -13,7 +17,7 @@ #ifndef WORKAROUND_INDEX_LOAD_INCLUDE # ifndef GPU_INDEX_LOAD -# error Missing gpu_index_load create info dependency +# error Missing gpu_index_buffer_load create info dependency # endif /** diff --git a/source/blender/gpu/shaders/common/gpu_shader_math_rotation_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_math_rotation_lib.glsl index 6da2b198f9a..f876673c73c 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_math_rotation_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_math_rotation_lib.glsl @@ -18,7 +18,7 @@ struct Angle { /* Angle in radian. */ float angle; -# ifdef GPU_METAL +# ifdef __cplusplus Angle() = default; Angle(float angle_) : angle(angle_){}; # endif @@ -28,7 +28,7 @@ struct AxisAngle { vec3 axis; float angle; -# ifdef GPU_METAL +# ifdef __cplusplus AxisAngle() = default; AxisAngle(vec3 axis_, float angle_) : axis(axis_), angle(angle_){}; # endif @@ -41,7 +41,7 @@ AxisAngle AxisAngle_identity() struct Quaternion { float x, y, z, w; -# ifdef GPU_METAL +# ifdef __cplusplus Quaternion() = default; Quaternion(float x_, float y_, float z_, float w_) : x(x_), y(y_), z(z_), w(w_){}; # endif @@ -59,7 +59,7 @@ Quaternion Quaternion_identity() struct EulerXYZ { float x, y, z; -# ifdef GPU_METAL +# ifdef __cplusplus EulerXYZ() = default; EulerXYZ(float x_, float y_, float z_) : x(x_), y(y_), z(z_){}; # endif diff --git a/source/blender/gpu/shaders/common/gpu_shader_print_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_print_lib.glsl index 7c00145f4e4..bcd8de5d84a 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_print_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_print_lib.glsl @@ -4,6 +4,10 @@ #pragma once +#include "infos/gpu_shader_print_info.hh" + +SHADER_LIBRARY_CREATE_INFO(gpu_print) + uint print_data(uint offset, uint data) { if (offset < GPU_SHADER_PRINTF_MAX_CAPACITY) { diff --git a/source/blender/gpu/shaders/common/gpu_shader_sequencer_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_sequencer_lib.glsl index 311135869f2..a3dc1516aca 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_sequencer_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_sequencer_lib.glsl @@ -4,6 +4,10 @@ #pragma once +#include "infos/gpu_shader_sequencer_info.hh" + +SHADER_LIBRARY_CREATE_INFO(gpu_shader_sequencer_strips) + /* Signed distance to rounded box, centered at origin. * Reference: https://iquilezles.org/articles/distfunctions2d/ */ float sdf_rounded_box(vec2 pos, vec2 size, float radius) diff --git a/source/blender/gpu/shaders/common/gpu_shader_shared_exponent_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_shared_exponent_lib.glsl index 8da7cf60f5c..24727d97d86 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_shared_exponent_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_shared_exponent_lib.glsl @@ -4,6 +4,8 @@ #pragma once +#include "gpu_glsl_cpp_stubs.hh" + /** * Software implementation of encoding and decoding of shared exponent texture as described by the * OpenGL extension EXT_texture_shared_exponent Appendix diff --git a/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl index d25b07902bd..a9955edf806 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_smaa_lib.glsl @@ -9,6 +9,8 @@ #pragma once +#include "gpu_glsl_cpp_stubs.hh" + /** * _______ ___ ___ ___ ___ * / || \/ | / \ / \ diff --git a/source/blender/gpu/shaders/common/gpu_shader_test_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_test_lib.glsl index 149286e36b0..8a288870916 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_test_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_test_lib.glsl @@ -4,6 +4,8 @@ #pragma once +#include "gpu_glsl_cpp_stubs.hh" + /* clang-format off */ #ifndef GPU_METAL bool is_integer(bool v) { return true; } diff --git a/source/blender/gpu/shaders/common/gpu_shader_utildefines_lib.glsl b/source/blender/gpu/shaders/common/gpu_shader_utildefines_lib.glsl index 4ec769e1980..142159536b4 100644 --- a/source/blender/gpu/shaders/common/gpu_shader_utildefines_lib.glsl +++ b/source/blender/gpu/shaders/common/gpu_shader_utildefines_lib.glsl @@ -4,6 +4,8 @@ #pragma once +#include "gpu_glsl_cpp_stubs.hh" + /* WORKAROUND: to guard against double include in EEVEE. */ #ifndef GPU_SHADER_UTILDEFINES_GLSL # define GPU_SHADER_UTILDEFINES_GLSL diff --git a/source/blender/gpu/shaders/gpu_glsl_cpp_stubs.hh b/source/blender/gpu/shaders/gpu_glsl_cpp_stubs.hh index d44dffa4495..d4e9dced4c8 100644 --- a/source/blender/gpu/shaders/gpu_glsl_cpp_stubs.hh +++ b/source/blender/gpu/shaders/gpu_glsl_cpp_stubs.hh @@ -647,9 +647,8 @@ template T abs(T) RET; template T max(T, T) RET; template T min(T, T) RET; template T sign(T) RET; -template T clamp(T, T, T) RET; -template T clamp(T, double, double) RET; template T clamp(T, U, U) RET; +template T clamp(T, double, double) RET; template T max(T, U) RET; template T min(T, U) RET; /* TODO(fclem): These should be restricted to floats. */ @@ -658,7 +657,9 @@ template T exp(T) RET; template T exp2(T) RET; template T floor(T) RET; template T fma(T, T, T) RET; +#ifndef _MSC_VER /* Avoid function redefinition which triggers a compile time error. */ double fma(double, double, double) RET; +#endif template T fract(T) RET; template T frexp(T, T) RET; template T inversesqrt(T) RET; diff --git a/source/blender/gpu/shaders/gpu_shader_2D_area_borders_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_area_borders_frag.glsl index 54eca22d492..0b5c245921e 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_area_borders_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_area_borders_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_area_borders_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_area_borders) + void main() { /* Should be 0.8 but minimize the AA on the edges. */ diff --git a/source/blender/gpu/shaders/gpu_shader_2D_area_borders_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_area_borders_vert.glsl index cc22d4750b6..f7c1d7ecc9d 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_area_borders_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_area_borders_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_area_borders_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_area_borders) + void main() { int corner_id = (gl_VertexID / cornerLen) % 4; diff --git a/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl index fb768e919b2..ba318ec3a10 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_image_rect_vert.glsl @@ -7,6 +7,10 @@ * does not need any vertex input (producing less call to immBegin/End) */ +#include "infos/gpu_shader_2D_image_rect_color_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_image_rect_color) + void main() { vec2 uv; diff --git a/source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl index a75f5ff7c3e..22e9dd13ecb 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_image_vert.glsl @@ -2,14 +2,9 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#ifndef USE_GPU_SHADER_CREATE_INFO -uniform mat4 ModelViewProjectionMatrix; +#include "infos/gpu_shader_2D_image_info.hh" -/* Keep in sync with intern/opencolorio/gpu_shader_display_transform_vertex.glsl */ -in vec2 texCoord; -in vec2 pos; -out vec2 texCoord_interp; -#endif +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_image_common) void main() { diff --git a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl index d1823f93610..9779f4e9c43 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_line_dashed_frag.glsl @@ -9,6 +9,10 @@ * Dashed is performed in screen space. */ +#include "infos/gpu_shader_line_dashed_uniform_color_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_3D_line_dashed_uniform_color) + void main() { float distance_along_line = distance(stipple_pos, stipple_start); diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl index ac61efdc02c..cd1820b3b88 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_nodelink_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_nodelink) + #define ANTIALIAS 0.75 float get_line_alpha(float center, float relative_radius) @@ -16,7 +20,6 @@ void main() float dash_frag_alpha = 1.0; if (dashFactor < 1.0) { float distance_along_line = lineLength * lineUV.x; - float normalized_distance = fract(distance_along_line / dashLength); /* Checking if `normalized_distance <= dashFactor` is already enough for a basic * dash, however we want to handle a nice anti-alias. */ diff --git a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl index 2fc98a6eea7..bb75f261e3d 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_nodelink_vert.glsl @@ -12,6 +12,10 @@ * `pos` is the verts position in the curve tangent space */ +#include "infos/gpu_shader_2D_nodelink_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_nodelink) + #define MID_VERTEX 65 void main() diff --git a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_aa_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_aa_vert.glsl index c49c3e348bf..1aa17fff91a 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_aa_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_aa_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_point_uniform_size_uniform_color_aa) + void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl index b8feb55aee6..79414992705 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_point_uniform_size_uniform_color_outline_aa) + void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_2D_point_varying_size_varying_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_point_varying_size_varying_color_vert.glsl index 5997f71212a..5576aaf3741 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_point_varying_size_varying_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_point_varying_size_varying_color_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_point_varying_size_varying_color_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_point_varying_size_varying_color) + void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_2D_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_vert.glsl index 6905f5b795e..9f9695d103a 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_checker_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_checker) + void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 0.0, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl index 69380ecca66..f6eaba79e9f 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_frag.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_widget_info.hh" + #include "gpu_shader_colorspace_lib.glsl" +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_widget_shared) + vec3 compute_masks(vec2 uv) { bool upper_half = uv.y > outRectSize.y * 0.5; diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl index e1e56f8f391..01b9d131fb9 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_base_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_widget_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_widget_base) + #define recti parameters[widgetID * MAX_PARAM + 0] #define rect parameters[widgetID * MAX_PARAM + 1] #define radsi parameters[widgetID * MAX_PARAM + 2].x @@ -25,7 +29,7 @@ #define doAlphaCheck (alphaDiscard < 0.0) #define discardFactor abs(alphaDiscard) -vec2 do_widget(void) +vec2 do_widget() { /* Offset to avoid losing pixels (mimics conservative rasterization). */ const vec2 ofs = vec2(0.5, -0.5); diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_shadow_frag.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_shadow_frag.glsl index bdaf9234a4f..b270aaf4fe9 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_widget_shadow_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_shadow_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_widget_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_widget_shadow) + void main() { fragColor = vec4(0.0); diff --git a/source/blender/gpu/shaders/gpu_shader_2D_widget_shadow_vert.glsl b/source/blender/gpu/shaders/gpu_shader_2D_widget_shadow_vert.glsl index 14f66848d70..fb7cd91aa80 100644 --- a/source/blender/gpu/shaders/gpu_shader_2D_widget_shadow_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_2D_widget_shadow_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_widget_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_2D_widget_shadow) + #define BIT_RANGE(x) uint((1 << x) - 1) /* 2 bits for corner */ diff --git a/source/blender/gpu/shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl index efefd62f9e9..c211603e15d 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_clipped_uniform_color_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_uniform_color_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_3D_clipped_uniform_color) + void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl index 3a19ff0af59..2c34b2acef3 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_flat_color_vert.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_flat_color_info.hh" + #include "gpu_shader_cfg_world_clip_lib.glsl" +VERTEX_SHADER_CREATE_INFO(gpu_shader_3D_flat_color) + void main() { vec4 pos_4d = vec4(pos, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_3D_image_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_image_vert.glsl index e32d4169b21..bb7a885f7b9 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_image_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_image_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_image_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_3D_image_common) + void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos.xyz, 1.0f); diff --git a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl index b39908fdf56..3dee259a04f 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_line_dashed_uniform_color_vert.glsl @@ -9,8 +9,12 @@ * Dashed is performed in screen space. */ +#include "infos/gpu_shader_line_dashed_uniform_color_info.hh" + #include "gpu_shader_cfg_world_clip_lib.glsl" +VERTEX_SHADER_CREATE_INFO(gpu_shader_3D_line_dashed_uniform_color_clipped) + void main() { vec4 pos_4d = vec4(pos, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_3D_normal_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_normal_vert.glsl index c87e81c912e..263215e0050 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_normal_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_normal_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_simple_lighting_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_simple_lighting) + void main() { normal = normalize(NormalMatrix * nor); diff --git a/source/blender/gpu/shaders/gpu_shader_3D_point_uniform_size_aa_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_point_uniform_size_aa_vert.glsl index 0f1b7f5d05d..4f55de79e31 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_point_uniform_size_aa_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_point_uniform_size_aa_vert.glsl @@ -2,7 +2,9 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ -#include "gpu_shader_cfg_world_clip_lib.glsl" +#include "infos/gpu_shader_3D_point_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_3D_point_uniform_size_uniform_color_aa) void main() { @@ -19,8 +21,4 @@ void main() /* Convert to PointCoord units. */ radii /= size; - -#ifdef USE_WORLD_CLIP_PLANES - world_clip_planes_calc_clip_distance((clipPlanes.ClipModelMatrix * pos_4d).xyz); -#endif } diff --git a/source/blender/gpu/shaders/gpu_shader_3D_point_varying_size_varying_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_point_varying_size_varying_color_vert.glsl index 83fb297bc88..df7ed641057 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_point_varying_size_varying_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_point_varying_size_varying_color_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_point_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_3D_point_varying_size_varying_color) + void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_3D_polyline_frag.glsl b/source/blender/gpu/shaders/gpu_shader_3D_polyline_frag.glsl index 0154e6aebbb..065bdaaf836 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_polyline_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_polyline_frag.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_polyline_info.hh" + #include "gpu_shader_colorspace_lib.glsl" +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color) + void main() { #ifdef CLIP diff --git a/source/blender/gpu/shaders/gpu_shader_3D_smooth_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_3D_smooth_color_frag.glsl index f2c788316f2..3a566e3e824 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_smooth_color_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_smooth_color_frag.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_smooth_color_info.hh" + #include "gpu_shader_colorspace_lib.glsl" +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_3D_smooth_color) + void main() { fragColor = finalColor; diff --git a/source/blender/gpu/shaders/gpu_shader_3D_smooth_color_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_smooth_color_vert.glsl index 177c8f1c4a3..33b34834e0f 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_smooth_color_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_smooth_color_vert.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_smooth_color_info.hh" + #include "gpu_shader_cfg_world_clip_lib.glsl" +VERTEX_SHADER_CREATE_INFO(gpu_shader_3D_smooth_color) + void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_3D_vert.glsl b/source/blender/gpu/shaders/gpu_shader_3D_vert.glsl index 5a5a137ae26..fa2f5fd1dda 100644 --- a/source/blender/gpu/shaders/gpu_shader_3D_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_3D_vert.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_depth_only_info.hh" + #include "gpu_shader_cfg_world_clip_lib.glsl" +VERTEX_SHADER_CREATE_INFO(gpu_shader_3D_depth_only) + void main() { gl_Position = ModelViewProjectionMatrix * vec4(pos, 1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl b/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl index 01e512d4770..93455d7c4d5 100644 --- a/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_cfg_world_clip_lib.glsl @@ -4,28 +4,26 @@ #pragma once -#ifdef USE_WORLD_CLIP_PLANES -# if defined(GPU_VERTEX_SHADER) || defined(GPU_GEOMETRY_SHADER) +#include "infos/gpu_clip_planes_info.hh" -/* When all shaders are builtin shaders are migrated this could be applied directly. */ -# ifdef USE_GPU_SHADER_CREATE_INFO -# define WorldClipPlanes clipPlanes.world -# else -uniform vec4 WorldClipPlanes[6]; -# endif +#ifdef GPU_FRAGMENT_SHADER +# error File should not be included in fragment shader +#endif + +#ifdef USE_WORLD_CLIP_PLANES + +VERTEX_SHADER_CREATE_INFO(gpu_clip_planes) void world_clip_planes_calc_clip_distance(vec3 wpos) { vec4 pos = vec4(wpos, 1.0); - gl_ClipDistance[0] = dot(WorldClipPlanes[0], pos); - gl_ClipDistance[1] = dot(WorldClipPlanes[1], pos); - gl_ClipDistance[2] = dot(WorldClipPlanes[2], pos); - gl_ClipDistance[3] = dot(WorldClipPlanes[3], pos); - gl_ClipDistance[4] = dot(WorldClipPlanes[4], pos); - gl_ClipDistance[5] = dot(WorldClipPlanes[5], pos); + gl_ClipDistance[0] = dot(clipPlanes.world[0], pos); + gl_ClipDistance[1] = dot(clipPlanes.world[1], pos); + gl_ClipDistance[2] = dot(clipPlanes.world[2], pos); + gl_ClipDistance[3] = dot(clipPlanes.world[3], pos); + gl_ClipDistance[4] = dot(clipPlanes.world[4], pos); + gl_ClipDistance[5] = dot(clipPlanes.world[5], pos); } -# endif - #endif diff --git a/source/blender/gpu/shaders/gpu_shader_checker_frag.glsl b/source/blender/gpu/shaders/gpu_shader_checker_frag.glsl index bd2c7f07833..54342f66f69 100644 --- a/source/blender/gpu/shaders/gpu_shader_checker_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_checker_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_checker_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_checker) + void main() { vec2 phase = mod(gl_FragCoord.xy, (size * 2)); diff --git a/source/blender/gpu/shaders/gpu_shader_colorspace_lib.glsl b/source/blender/gpu/shaders/gpu_shader_colorspace_lib.glsl index 13df450bf4c..15168359272 100644 --- a/source/blender/gpu/shaders/gpu_shader_colorspace_lib.glsl +++ b/source/blender/gpu/shaders/gpu_shader_colorspace_lib.glsl @@ -4,13 +4,13 @@ #pragma once +#include "infos/gpu_srgb_to_framebuffer_space_info.hh" + +SHADER_LIBRARY_CREATE_INFO(gpu_srgb_to_framebuffer_space) + /* Undefine the macro that avoids compilation errors. */ #undef blender_srgb_to_framebuffer_space -#ifndef USE_GPU_SHADER_CREATE_INFO -uniform bool srgbTarget = false; -#endif - vec4 blender_srgb_to_framebuffer_space(vec4 in_color) { if (srgbTarget) { diff --git a/source/blender/gpu/shaders/gpu_shader_depth_only_frag.glsl b/source/blender/gpu/shaders/gpu_shader_depth_only_frag.glsl index 7b3c473373a..7f0506399ee 100644 --- a/source/blender/gpu/shaders/gpu_shader_depth_only_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_depth_only_frag.glsl @@ -2,6 +2,8 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_depth_only_info.hh" + void main() { /* No color output, only depth (line below is implicit). */ diff --git a/source/blender/gpu/shaders/gpu_shader_diag_stripes_frag.glsl b/source/blender/gpu/shaders/gpu_shader_diag_stripes_frag.glsl index ec68cd38772..72927b8940d 100644 --- a/source/blender/gpu/shaders/gpu_shader_diag_stripes_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_diag_stripes_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_diag_stripes_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_diag_stripes) + void main() { float phase = mod((gl_FragCoord.x + gl_FragCoord.y), float(size1 + size2)); diff --git a/source/blender/gpu/shaders/gpu_shader_display_fallback_frag.glsl b/source/blender/gpu/shaders/gpu_shader_display_fallback_frag.glsl index d7be790f085..17284154be4 100644 --- a/source/blender/gpu/shaders/gpu_shader_display_fallback_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_display_fallback_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_image_overlays_merge_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_cycles_display_fallback) + void main() { fragColor = texture(image_texture, texCoord_interp); diff --git a/source/blender/gpu/shaders/gpu_shader_display_fallback_vert.glsl b/source/blender/gpu/shaders/gpu_shader_display_fallback_vert.glsl index 6816493cafa..03a319bc448 100644 --- a/source/blender/gpu/shaders/gpu_shader_display_fallback_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_display_fallback_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_image_overlays_merge_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_cycles_display_fallback) + vec2 normalize_coordinates() { return (vec2(2.0) * (pos / fullscreen)) - vec2(1.0); diff --git a/source/blender/gpu/shaders/gpu_shader_flat_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_flat_color_frag.glsl index f2c788316f2..1612f249af0 100644 --- a/source/blender/gpu/shaders/gpu_shader_flat_color_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_flat_color_frag.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_flat_color_info.hh" + #include "gpu_shader_colorspace_lib.glsl" +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_3D_flat_color) + void main() { fragColor = finalColor; diff --git a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_frag.glsl b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_frag.glsl index 687df1362a5..241619ab577 100644 --- a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_gpencil_stroke_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke) + void main() { const vec2 center = vec2(0, 0.5); diff --git a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl index b81f5d72068..7d881081c02 100644 --- a/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_gpencil_stroke_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_gpencil_stroke_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke) + #include "gpu_shader_attribute_load_lib.glsl" #include "gpu_shader_math_base_lib.glsl" #include "gpu_shader_utildefines_lib.glsl" diff --git a/source/blender/gpu/shaders/gpu_shader_icon_frag.glsl b/source/blender/gpu/shaders/gpu_shader_icon_frag.glsl index 1a5c80c8341..3a263df581a 100644 --- a/source/blender/gpu/shaders/gpu_shader_icon_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_icon_frag.glsl @@ -10,6 +10,10 @@ * the rounded corner, and the rectangle sides. */ +#include "infos/gpu_shader_icon_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_icon) + void main() { /* Sample texture with LOD BIAS. Used instead of custom LOD bias in GPU_SAMPLER_CUSTOM_ICON. */ diff --git a/source/blender/gpu/shaders/gpu_shader_icon_multi_vert.glsl b/source/blender/gpu/shaders/gpu_shader_icon_multi_vert.glsl index 045ea22cdaf..48c448d7b35 100644 --- a/source/blender/gpu/shaders/gpu_shader_icon_multi_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_icon_multi_vert.glsl @@ -7,6 +7,10 @@ * does not need any vertex input (producing less call to immBegin/End) */ +#include "infos/gpu_shader_icon_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_icon_multi) + void main() { vec4 rect = multi_icon_data.calls_data[gl_InstanceID * 3]; diff --git a/source/blender/gpu/shaders/gpu_shader_icon_vert.glsl b/source/blender/gpu/shaders/gpu_shader_icon_vert.glsl index 8250a0181b9..6d8e6be4d6c 100644 --- a/source/blender/gpu/shaders/gpu_shader_icon_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_icon_vert.glsl @@ -7,6 +7,10 @@ * does not need any vertex input (producing less call to immBegin/End) */ +#include "infos/gpu_shader_icon_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_icon) + void main() { vec2 uv; diff --git a/source/blender/gpu/shaders/gpu_shader_image_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_color_frag.glsl index bf91c3e0dd6..6c93dd81069 100644 --- a/source/blender/gpu/shaders/gpu_shader_image_color_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_image_color_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_image_rect_color_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_image_rect_color) + void main() { fragColor = texture(image, texCoord_interp) * color; diff --git a/source/blender/gpu/shaders/gpu_shader_image_desaturate_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_desaturate_frag.glsl index 418a782f8ed..cc3842e2f80 100644 --- a/source/blender/gpu/shaders/gpu_shader_image_desaturate_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_image_desaturate_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_image_desaturate_color_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_image_desaturate_color) + void main() { vec4 tex = texture(image, texCoord_interp); diff --git a/source/blender/gpu/shaders/gpu_shader_image_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_frag.glsl index 95bff5e62bf..87a78d8c122 100644 --- a/source/blender/gpu/shaders/gpu_shader_image_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_image_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_image_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_image_common) + void main() { fragColor = texture(image, texCoord_interp); diff --git a/source/blender/gpu/shaders/gpu_shader_image_overlays_merge_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_overlays_merge_frag.glsl index d6d217439fe..e17fbf238be 100644 --- a/source/blender/gpu/shaders/gpu_shader_image_overlays_merge_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_image_overlays_merge_frag.glsl @@ -4,16 +4,9 @@ /* Merge overlays texture on top of image texture and transform to display space (assume sRGB) */ -#ifndef USE_GPU_SHADER_CREATE_INFO -uniform sampler2D image_texture; -uniform sampler2D overlays_texture; -uniform bool display_transform; -uniform bool overlay; +#include "infos/gpu_shader_2D_image_overlays_merge_info.hh" -in vec2 texCoord_interp; - -out vec4 fragColor; -#endif +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_merge) float linearrgb_to_srgb(float c) { diff --git a/source/blender/gpu/shaders/gpu_shader_image_overlays_stereo_merge_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_overlays_stereo_merge_frag.glsl index 54ce4220a39..22146adc28d 100644 --- a/source/blender/gpu/shaders/gpu_shader_image_overlays_stereo_merge_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_image_overlays_stereo_merge_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_stereo_merge) + #define S3D_DISPLAY_ANAGLYPH 0 #define S3D_DISPLAY_INTERLACE 1 diff --git a/source/blender/gpu/shaders/gpu_shader_image_shuffle_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_image_shuffle_color_frag.glsl index 61ed735653b..d9ba34c6c56 100644 --- a/source/blender/gpu/shaders/gpu_shader_image_shuffle_color_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_image_shuffle_color_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_image_shuffle_color_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_image_shuffle_color) + void main() { vec4 sampled_color = texture(image, texCoord_interp); diff --git a/source/blender/gpu/shaders/gpu_shader_index_2d_array_lines.glsl b/source/blender/gpu/shaders/gpu_shader_index_2d_array_lines.glsl index 86ed213f4fc..d7de4fb40bb 100644 --- a/source/blender/gpu/shaders/gpu_shader_index_2d_array_lines.glsl +++ b/source/blender/gpu/shaders/gpu_shader_index_2d_array_lines.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_index_info.hh" + +COMPUTE_SHADER_CREATE_INFO(gpu_shader_index_2d_array_lines) + /** * Constructs a 2D array index buffer with 'ncurves' rows and 'elements_per_curve*2' * columns. Each row contains 'elements_per_curve' pairs of indexes. diff --git a/source/blender/gpu/shaders/gpu_shader_index_2d_array_points.glsl b/source/blender/gpu/shaders/gpu_shader_index_2d_array_points.glsl index ac2dff0640d..ef4f6d806b0 100644 --- a/source/blender/gpu/shaders/gpu_shader_index_2d_array_points.glsl +++ b/source/blender/gpu/shaders/gpu_shader_index_2d_array_points.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_index_info.hh" + +COMPUTE_SHADER_CREATE_INFO(gpu_shader_index_2d_array_points) + /** * Constructs a simple 2D array index buffer, with 'ncurves' rows and 'elements_per_curve' * columns. Each row contains 'elements_per_curve-1' indexes and a restart index. diff --git a/source/blender/gpu/shaders/gpu_shader_index_2d_array_tris.glsl b/source/blender/gpu/shaders/gpu_shader_index_2d_array_tris.glsl index 7a1dd718b60..af5d86f811e 100644 --- a/source/blender/gpu/shaders/gpu_shader_index_2d_array_tris.glsl +++ b/source/blender/gpu/shaders/gpu_shader_index_2d_array_tris.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_index_info.hh" + +COMPUTE_SHADER_CREATE_INFO(gpu_shader_index_2d_array_tris) + /** * Constructs a 2D array index buffer, with 'ncurves' rows and 'elements_per_curve*6' columns. * The index buffer can be used to draw 'ncurves' triangle strips with 'elements_per_curve*2' diff --git a/source/blender/gpu/shaders/gpu_shader_keyframe_shape_frag.glsl b/source/blender/gpu/shaders/gpu_shader_keyframe_shape_frag.glsl index 76b15364d79..828ad49e491 100644 --- a/source/blender/gpu/shaders/gpu_shader_keyframe_shape_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_keyframe_shape_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_keyframe_shape_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_keyframe_shape) + #define diagonal_scale sqrt(0.5) #define minmax_bias 0.7 diff --git a/source/blender/gpu/shaders/gpu_shader_keyframe_shape_vert.glsl b/source/blender/gpu/shaders/gpu_shader_keyframe_shape_vert.glsl index a5e2870bf90..c80833b7483 100644 --- a/source/blender/gpu/shaders/gpu_shader_keyframe_shape_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_keyframe_shape_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_keyframe_shape_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_keyframe_shape) + #define line_falloff 1.0 #define circle_scale sqrt(2.0 / 3.1416) #define square_scale sqrt(0.5) diff --git a/source/blender/gpu/shaders/gpu_shader_point_uniform_color_aa_frag.glsl b/source/blender/gpu/shaders/gpu_shader_point_uniform_color_aa_frag.glsl index bedf7440071..a20ed2a688d 100644 --- a/source/blender/gpu/shaders/gpu_shader_point_uniform_color_aa_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_point_uniform_color_aa_frag.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh" + #include "gpu_shader_colorspace_lib.glsl" +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_point_uniform_size_uniform_color_aa) + void main() { float dist = length(gl_PointCoord - vec2(0.5)); diff --git a/source/blender/gpu/shaders/gpu_shader_point_uniform_color_outline_aa_frag.glsl b/source/blender/gpu/shaders/gpu_shader_point_uniform_color_outline_aa_frag.glsl index c61f70b4c88..ebab3e9bb53 100644 --- a/source/blender/gpu/shaders/gpu_shader_point_uniform_color_outline_aa_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_point_uniform_color_outline_aa_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_point_uniform_size_uniform_color_outline_aa) + void main() { float dist = length(gl_PointCoord - vec2(0.5)); diff --git a/source/blender/gpu/shaders/gpu_shader_point_varying_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_point_varying_color_frag.glsl index e6514941cc8..259b23ccba3 100644 --- a/source/blender/gpu/shaders/gpu_shader_point_varying_color_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_point_varying_color_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_2D_point_varying_size_varying_color_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_2D_point_varying_size_varying_color) + void main() { vec2 centered = gl_PointCoord - vec2(0.5); @@ -13,14 +17,5 @@ void main() discard; } -#if defined(VERT) fragColor = finalColor; - - float midStroke = 0.5 * rad_squared; - if (vertexCrease > 0.0 && dist_squared > midStroke) { - fragColor.rgb = mix(finalColor.rgb, colorEdgeCrease.rgb, vertexCrease); - } -#else - fragColor = finalColor; -#endif } diff --git a/source/blender/gpu/shaders/gpu_shader_sequencer_strips_frag.glsl b/source/blender/gpu/shaders/gpu_shader_sequencer_strips_frag.glsl index 6d52ea0054b..fdd4c3173b4 100644 --- a/source/blender/gpu/shaders/gpu_shader_sequencer_strips_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_sequencer_strips_frag.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_sequencer_info.hh" + #include "gpu_shader_sequencer_lib.glsl" +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_sequencer_strips) + vec3 color_shade(vec3 rgb, float shade) { rgb += vec3(shade / 255.0); @@ -39,7 +43,7 @@ void main() SeqStripDrawData strip = strip_data[strip_id]; vec2 pos1, pos2, size, center, pos; - float radius; + float radius = 0.0; strip_box(strip.left_handle, strip.right_handle, strip.bottom, diff --git a/source/blender/gpu/shaders/gpu_shader_sequencer_strips_vert.glsl b/source/blender/gpu/shaders/gpu_shader_sequencer_strips_vert.glsl index 9e09e78555f..9545786dc8d 100644 --- a/source/blender/gpu/shaders/gpu_shader_sequencer_strips_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_sequencer_strips_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_sequencer_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_sequencer_strips) + void main() { int id = gl_InstanceID; diff --git a/source/blender/gpu/shaders/gpu_shader_sequencer_thumbs_frag.glsl b/source/blender/gpu/shaders/gpu_shader_sequencer_thumbs_frag.glsl index 79afd771c3e..cb16ed6e46a 100644 --- a/source/blender/gpu/shaders/gpu_shader_sequencer_thumbs_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_sequencer_thumbs_frag.glsl @@ -2,13 +2,17 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_sequencer_info.hh" + #include "gpu_shader_sequencer_lib.glsl" +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_sequencer_thumbs) + void main() { SeqStripThumbData thumb = thumb_data[thumb_id]; vec2 pos1, pos2, size, center, pos; - float radius; + float radius = 0.0; strip_box(thumb.left, thumb.right, thumb.bottom, diff --git a/source/blender/gpu/shaders/gpu_shader_sequencer_thumbs_vert.glsl b/source/blender/gpu/shaders/gpu_shader_sequencer_thumbs_vert.glsl index fc9b4e806c8..e48b4957553 100644 --- a/source/blender/gpu/shaders/gpu_shader_sequencer_thumbs_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_sequencer_thumbs_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_sequencer_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_sequencer_thumbs) + void main() { int id = gl_InstanceID; diff --git a/source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl b/source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl index 801f22d7dc8..b639ae2909b 100644 --- a/source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_simple_lighting_frag.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_simple_lighting_info.hh" + +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_simple_lighting) + void main() { fragColor = simple_lighting_data.l_color; diff --git a/source/blender/gpu/shaders/gpu_shader_text_frag.glsl b/source/blender/gpu/shaders/gpu_shader_text_frag.glsl index 180c84b388b..a2fa13c7d78 100644 --- a/source/blender/gpu/shaders/gpu_shader_text_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_text_frag.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_text_info.hh" + #include "gpu_shader_colorspace_lib.glsl" +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_text) + /* Font texture is conceptually laid out like a big 1D buffer: each glyph * rectangle is flattened in row-major order into a "pixel strip". Inside * the texture, glyphs strips are put one after another. The texture pixel diff --git a/source/blender/gpu/shaders/gpu_shader_text_vert.glsl b/source/blender/gpu/shaders/gpu_shader_text_vert.glsl index 2ae92713f60..5c907b34889 100644 --- a/source/blender/gpu/shaders/gpu_shader_text_vert.glsl +++ b/source/blender/gpu/shaders/gpu_shader_text_vert.glsl @@ -2,6 +2,10 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_text_info.hh" + +VERTEX_SHADER_CREATE_INFO(gpu_shader_text) + void main() { color_flat = col; diff --git a/source/blender/gpu/shaders/gpu_shader_uniform_color_frag.glsl b/source/blender/gpu/shaders/gpu_shader_uniform_color_frag.glsl index 5cb04478b2c..b912d706f41 100644 --- a/source/blender/gpu/shaders/gpu_shader_uniform_color_frag.glsl +++ b/source/blender/gpu/shaders/gpu_shader_uniform_color_frag.glsl @@ -2,8 +2,12 @@ * * SPDX-License-Identifier: GPL-2.0-or-later */ +#include "infos/gpu_shader_3D_uniform_color_info.hh" + #include "gpu_shader_colorspace_lib.glsl" +FRAGMENT_SHADER_CREATE_INFO(gpu_shader_3D_clipped_uniform_color) + void main() { fragColor = blender_srgb_to_framebuffer_space(color); diff --git a/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh b/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh index 9462e50c213..11aec0a4ac2 100644 --- a/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh @@ -6,6 +6,15 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" + +# define USE_WORLD_CLIP_PLANES +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_clip_planes) diff --git a/source/blender/gpu/shaders/infos/gpu_index_load_info.hh b/source/blender/gpu/shaders/infos/gpu_index_load_info.hh index fc189f9863d..3fca9fd9648 100644 --- a/source/blender/gpu/shaders/infos/gpu_index_load_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_index_load_info.hh @@ -8,9 +8,18 @@ #pragma once +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" + +# define GPU_INDEX_LOAD +#endif + #include "gpu_shader_create_info.hh" -GPU_SHADER_CREATE_INFO(gpu_index_load) +GPU_SHADER_CREATE_INFO(gpu_index_buffer_load) PUSH_CONSTANT(BOOL, gpu_index_no_buffer) PUSH_CONSTANT(BOOL, gpu_index_16bit) PUSH_CONSTANT(INT, gpu_index_base_index) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh index c53229e3127..02d55710144 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_INTERFACE_INFO(smooth_uv_iface) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh index 84e82a7c3fa..54c91d36f86 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_checker) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh index 53ef9b3ec3b..405b6cfb293 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_diag_stripes) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh index 4cded825133..9db9872df63 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh @@ -6,6 +6,14 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_shader_2D_image_info.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_desaturate_color) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh index 7bfafb4d2b5..c41a3863fb8 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh index 230719e268f..5744b96daac 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh index 435efcba121..7a263cdf9cd 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_stereo_merge) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh index 42e863bca1e..b7317793aff 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh index 13c28ae0b44..5c239c2d106 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh @@ -6,6 +6,14 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_shader_2D_image_info.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_shuffle_color) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh index c63d32f1038..0e7b7c52733 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_INTERFACE_INFO(nodelink_iface) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh index 73da34416b0..0ef3490c73f 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh @@ -6,6 +6,14 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_srgb_to_framebuffer_space_info.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh index 9b4c549eacb..74dc73b556d 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh index 582af0f1d20..78662e61b8d 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_widget_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_widget_info.hh index 4375d4cc22e..3de94f5fe78 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_2D_widget_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_widget_info.hh @@ -6,6 +6,16 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_srgb_to_framebuffer_space_info.hh" + +# define widgetID 0 +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh index 4566e7decf5..4f8a4004270 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh @@ -6,6 +6,14 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_clip_planes_info.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh index 2adef85f16b..a8fed26f91a 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh @@ -6,6 +6,15 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_clip_planes_info.hh" +# include "gpu_srgb_to_framebuffer_space_info.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_image_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_image_info.hh index 34780456701..adf94b3be0d 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_image_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_image_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh index 6897b437f21..57d70e3c244 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh @@ -6,6 +6,16 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_clip_planes_info.hh" +# include "gpu_interface_info.hh" +# include "gpu_srgb_to_framebuffer_space_info.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_3D_point_varying_size_varying_color) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh index 53114f110e7..96daf65155f 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh @@ -6,6 +6,15 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_srgb_to_framebuffer_space_info.hh" +# define SMOOTH_WIDTH 1.0 +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh index d5989786fb3..1c077b419fc 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh @@ -6,6 +6,15 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_clip_planes_info.hh" +# include "gpu_srgb_to_framebuffer_space_info.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh index 0a347628f51..60abe902952 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh @@ -6,6 +6,15 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_clip_planes_info.hh" +# include "gpu_srgb_to_framebuffer_space_info.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_shader_3D_uniform_color) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh index 0f82e58f712..c27a37c9126 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh @@ -6,12 +6,19 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_NAMED_INTERFACE_INFO(gpencil_stroke_vert_iface, interp) SMOOTH(VEC4, mColor) SMOOTH(VEC2, mTexCoord) -GPU_SHADER_NAMED_INTERFACE_END(geometry_out) +GPU_SHADER_NAMED_INTERFACE_END(interp) GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke) TYPEDEF_SOURCE("GPU_shader_shared.hh") diff --git a/source/blender/gpu/shaders/infos/gpu_shader_icon_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_icon_info.hh index 27cdc063cf7..8620c9fae8f 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_icon_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_icon_info.hh @@ -6,6 +6,14 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# define DO_CORNER_MASKING +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_index_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_index_info.hh index 51faa169441..c82526ef506 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_index_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_index_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh index a8fa31d6c75..f481fdc49b1 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_INTERFACE_INFO(keyframe_shape_iface) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh index 6c0ed1d687a..4617c5c1824 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_line_dashed_uniform_color_info.hh @@ -6,6 +6,14 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_clip_planes_info.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_print_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_print_info.hh index b8462d05a2b..5bc0e1c4039 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_print_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_print_info.hh @@ -6,10 +6,16 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_print) STORAGE_BUF_FREQ(GPU_SHADER_PRINTF_SLOT, READ_WRITE, uint, gpu_print_buf[], PASS) DEFINE_VALUE("GPU_SHADER_PRINTF_MAX_CAPACITY", STRINGIFY(GPU_SHADER_PRINTF_MAX_CAPACITY)) -DEFINE("GPU_PRINT") GPU_SHADER_CREATE_END() diff --git a/source/blender/gpu/shaders/infos/gpu_shader_sequencer_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_sequencer_info.hh index a7f22cd8aed..af9a4a836e2 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_sequencer_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_sequencer_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh index 997c15a6a2a..617e2c79ae8 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_INTERFACE_INFO(smooth_normal_iface) diff --git a/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh index 216a122dab4..8ed92bb85d7 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_test_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +#endif + #include "gpu_interface_info.hh" #include "gpu_shader_create_info.hh" diff --git a/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh index 3592858243c..de67a47a805 100644 --- a/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh @@ -6,6 +6,14 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "GPU_shader_shared.hh" +# include "gpu_srgb_to_framebuffer_space_info.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_INTERFACE_INFO(text_iface) diff --git a/source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh b/source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh index 62030deda70..fcb7bd353e4 100644 --- a/source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh +++ b/source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh @@ -6,6 +6,13 @@ * \ingroup gpu */ +#ifdef GPU_SHADER +# pragma once +# include "gpu_glsl_cpp_stubs.hh" + +# include "gpu_srgb_to_framebuffer_space_info.hh" +#endif + #include "gpu_shader_create_info.hh" GPU_SHADER_CREATE_INFO(gpu_srgb_to_framebuffer_space)