From 8fb2ff458ba579dba08bfdf57d043ad158b5db07 Mon Sep 17 00:00:00 2001 From: Jeroen Bakker Date: Mon, 17 Jan 2022 14:32:03 +0100 Subject: GPUShaderCreateInfo for interface abstraction This is a first part of the Shader Create Info system could be. A shader create info provides a way to define shader structure, resources and interfaces. This makes for a quick way to provide backend agnostic binding informations while also making shader variations easy to declare. - Clear source input (only one file). Cleans up the GPU api since we can create a shader from one descriptor - Resources and interfaces are generated by the backend (much simpler than parsing). - Bindings are explicit from position in the array. - GPUShaderInterface becomes a trivial translation of enums and string copy. - No external dependency to third party lib. - Cleaner code, less fragmentation of resources in several libs. - Easy to modify / extend at runtime. - no parser involve, very easy to code. - Does not hold any data, can be static and kept on disc. - Could hold precompiled bytecode for static shaders. This also includes a new global dependency system. GLSL shaders can include other sources by using #pragma BLENDER_REQUIRE(...). This patch already migrated several builtin shaders. Other shaders should be migrated one at a time, and could be done inside master. There is a new compile directive `WITH_GPU_SHADER_BUILDER` this is an optional directive for linting shaders to increase turn around time. What is remaining: - pyGPU API {T94975} - Migration of other shaders. This could be a community effort. Reviewed By: jbakker Maniphest Tasks: T94975 Differential Revision: https://developer.blender.org/D13360 --- .../gpu/shaders/infos/gpu_clip_planes_info.hh | 29 +++++++++ .../gpu/shaders/infos/gpu_interface_info.hh | 33 ++++++++++ .../infos/gpu_shader_2D_area_borders_info.hh | 39 ++++++++++++ .../shaders/infos/gpu_shader_2D_checker_info.hh | 36 +++++++++++ .../infos/gpu_shader_2D_diag_stripes_info.hh | 37 +++++++++++ .../shaders/infos/gpu_shader_2D_flat_color_info.hh | 38 ++++++++++++ .../infos/gpu_shader_2D_image_color_info.hh | 30 +++++++++ .../gpu_shader_2D_image_desaturate_color_info.hh | 31 ++++++++++ .../gpu/shaders/infos/gpu_shader_2D_image_info.hh | 39 ++++++++++++ .../gpu_shader_2D_image_overlays_merge_info.hh | 39 ++++++++++++ ...u_shader_2D_image_overlays_stereo_merge_info.hh | 36 +++++++++++ .../infos/gpu_shader_2D_image_rect_color_info.hh | 40 ++++++++++++ .../gpu_shader_2D_image_shuffle_color_info.hh | 31 ++++++++++ ...gpu_shader_2D_line_dashed_uniform_color_info.hh | 35 +++++++++++ .../shaders/infos/gpu_shader_2D_nodelink_info.hh | 72 ++++++++++++++++++++++ ..._2D_point_uniform_size_uniform_color_aa_info.hh | 36 +++++++++++ ...t_uniform_size_uniform_color_outline_aa_info.hh | 38 ++++++++++++ ...der_2D_point_varying_size_varying_color_info.hh | 36 +++++++++++ .../infos/gpu_shader_2D_smooth_color_info.hh | 37 +++++++++++ .../infos/gpu_shader_2D_uniform_color_info.hh | 35 +++++++++++ .../shaders/infos/gpu_shader_3D_depth_only_info.hh | 38 ++++++++++++ .../shaders/infos/gpu_shader_3D_flat_color_info.hh | 42 +++++++++++++ .../gpu_shader_3D_image_modulate_alpha_info.hh | 38 ++++++++++++ ...gpu_shader_3D_line_dashed_uniform_color_info.hh | 35 +++++++++++ .../gpu/shaders/infos/gpu_shader_3D_point_info.hh | 62 +++++++++++++++++++ .../shaders/infos/gpu_shader_3D_polyline_info.hh | 33 ++++++++++ .../infos/gpu_shader_3D_smooth_color_info.hh | 41 ++++++++++++ .../infos/gpu_shader_3D_uniform_color_info.hh | 39 ++++++++++++ .../infos/gpu_shader_gpencil_stroke_info.hh | 51 +++++++++++++++ ...der_instance_varying_color_varying_size_info.hh | 39 ++++++++++++ .../infos/gpu_shader_keyframe_shape_info.hh | 47 ++++++++++++++ .../infos/gpu_shader_simple_lighting_info.hh | 40 ++++++++++++ .../gpu/shaders/infos/gpu_shader_text_info.hh | 46 ++++++++++++++ .../infos/gpu_srgb_to_framebuffer_space_info.hh | 27 ++++++++ 34 files changed, 1325 insertions(+) create mode 100644 source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_interface_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_flat_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_image_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_line_dashed_uniform_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_smooth_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_2D_uniform_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_3D_image_modulate_alpha_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_3D_line_dashed_uniform_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_instance_varying_color_varying_size_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_shader_text_info.hh create mode 100644 source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh (limited to 'source/blender/gpu/shaders/infos') diff --git a/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh b/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh new file mode 100644 index 00000000000..81b3c523628 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_clip_planes_info.hh @@ -0,0 +1,29 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_clip_planes) + .uniform_buf(1, "GPUClipPlanes", "clipPlanes", Frequency::PASS) + .typedef_source("GPU_shader_shared.h") + .define("USE_WORLD_CLIP_PLANES"); diff --git a/source/blender/gpu/shaders/infos/gpu_interface_info.hh b/source/blender/gpu/shaders/infos/gpu_interface_info.hh new file mode 100644 index 00000000000..b53b60fa587 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_interface_info.hh @@ -0,0 +1,33 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#pragma once + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_INTERFACE_INFO(flat_color_iface, "").flat(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(no_perspective_color_iface, "").no_perspective(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(smooth_color_iface, "").smooth(Type::VEC4, "finalColor"); +GPU_SHADER_INTERFACE_INFO(smooth_tex_coord_interp_iface, "").smooth(Type::VEC2, "texCoord_interp"); +GPU_SHADER_INTERFACE_INFO(smooth_radii_iface, "").smooth(Type::VEC2, "radii"); +GPU_SHADER_INTERFACE_INFO(smooth_radii_outline_iface, "").smooth(Type::VEC4, "radii"); 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 new file mode 100644 index 00000000000..56c30e79e6d --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_area_borders_info.hh @@ -0,0 +1,39 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_INTERFACE_INFO(smooth_uv_iface, "").smooth(Type::VEC2, "uv"); + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_area_borders) + .vertex_in(0, Type::VEC2, "pos") + .vertex_out(smooth_uv_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::VEC4, "rect") + .push_constant(20, Type::VEC4, "color") + .push_constant(24, Type::FLOAT, "scale") + .push_constant(25, Type::INT, "cornerLen") + .vertex_source("gpu_shader_2D_area_borders_vert.glsl") + .fragment_source("gpu_shader_2D_area_borders_frag.glsl") + .do_static_compilation(true); \ No newline at end of file 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 new file mode 100644 index 00000000000..a69420bede4 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_checker_info.hh @@ -0,0 +1,36 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_checker) + .vertex_in(0, Type::VEC2, "pos") + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::VEC4, "color1") + .push_constant(20, Type::VEC4, "color2") + .push_constant(24, Type::INT, "size") + .vertex_source("gpu_shader_2D_vert.glsl") + .fragment_source("gpu_shader_checker_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..fa715cdcb1d --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_diag_stripes_info.hh @@ -0,0 +1,37 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_diag_stripes) + .vertex_in(0, Type::VEC2, "pos") + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::VEC4, "color1") + .push_constant(20, Type::VEC4, "color2") + .push_constant(24, Type::INT, "size1") + .push_constant(28, Type::INT, "size2") + .vertex_source("gpu_shader_2D_vert.glsl") + .fragment_source("gpu_shader_diag_stripes_frag.glsl") + .do_static_compilation(true); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_flat_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_flat_color_info.hh new file mode 100644 index 00000000000..93d46f8acd8 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_flat_color_info.hh @@ -0,0 +1,38 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_shader_create_info.hh" + +#include "gpu_interface_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_flat_color) + .vertex_in(0, Type::VEC2, "pos") + .vertex_in(1, Type::VEC4, "color") + .vertex_out(flat_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_2D_flat_color_vert.glsl") + .fragment_source("gpu_shader_flat_color_frag.glsl") + .additional_info("gpu_srgb_to_framebuffer_space") + .do_static_compilation(true); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_image_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_color_info.hh new file mode 100644 index 00000000000..a6cc9076d4a --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_color_info.hh @@ -0,0 +1,30 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_color) + .additional_info("gpu_shader_2D_image_common") + .push_constant(16, Type::VEC4, "color") + .fragment_source("gpu_shader_image_color_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..e11d6746446 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_desaturate_color_info.hh @@ -0,0 +1,31 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_desaturate_color) + .additional_info("gpu_shader_2D_image_common") + .push_constant(16, Type::VEC4, "color") + .push_constant(20, Type::FLOAT, "factor") + .fragment_source("gpu_shader_image_desaturate_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..3d20b63c265 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_info.hh @@ -0,0 +1,39 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_common) + .vertex_in(0, Type::VEC2, "pos") + .vertex_in(1, Type::VEC2, "texCoord") + .vertex_out(smooth_tex_coord_interp_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .sampler(0, ImageType::FLOAT_2D, "image") + .vertex_source("gpu_shader_2D_image_vert.glsl"); + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_image) + .additional_info("gpu_shader_2D_image_common") + .fragment_source("gpu_shader_image_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..c2c0e9fec78 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_merge_info.hh @@ -0,0 +1,39 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_merge) + .vertex_in(0, Type::VEC2, "pos") + .vertex_in(1, Type::VEC2, "texCoord") + .vertex_out(smooth_tex_coord_interp_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::BOOL, "display_transform") + .push_constant(17, Type::BOOL, "overlay") + .sampler(0, ImageType::FLOAT_2D, "image_texture") + .sampler(1, ImageType::FLOAT_2D, "overlays_texture") + .vertex_source("gpu_shader_2D_image_vert.glsl") + .fragment_source("gpu_shader_image_overlays_merge_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..c1e6c3957d3 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_overlays_stereo_merge_info.hh @@ -0,0 +1,36 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_overlays_stereo_merge) + .vertex_in(0, Type::VEC2, "pos") + .fragment_out(0, Type::VEC4, "imageColor") + .fragment_out(1, Type::VEC4, "overlayColor") + .sampler(0, ImageType::FLOAT_2D, "imageTexture") + .sampler(1, ImageType::FLOAT_2D, "overlayTexture") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::INT, "stereoDisplaySettings") + .vertex_source("gpu_shader_2D_vert.glsl") + .fragment_source("gpu_shader_image_overlays_stereo_merge_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..b9b4381eb50 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_rect_color_info.hh @@ -0,0 +1,40 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_rect_color) + .vertex_in(0, Type::VEC2, "pos") + .vertex_in(1, Type::VEC2, "texCoord") + .vertex_out(smooth_tex_coord_interp_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::VEC4, "color") + .push_constant(20, Type::VEC4, "rect_icon") + .push_constant(24, Type::VEC4, "rect_geom") + .sampler(0, ImageType::FLOAT_2D, "image") + .vertex_source("gpu_shader_2D_image_rect_vert.glsl") + .fragment_source("gpu_shader_image_color_frag.glsl") + .do_static_compilation(true); + 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 new file mode 100644 index 00000000000..3663de0a98f --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_image_shuffle_color_info.hh @@ -0,0 +1,31 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_image_shuffle_color) + .additional_info("gpu_shader_2D_image_common") + .push_constant(16, Type::VEC4, "color") + .push_constant(20, Type::VEC4, "shuffle") + .fragment_source("gpu_shader_image_shuffle_color_frag.glsl") + .do_static_compilation(true); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_line_dashed_uniform_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_line_dashed_uniform_color_info.hh new file mode 100644 index 00000000000..419cd4bc47c --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_line_dashed_uniform_color_info.hh @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +/* TODO(jbakker): Skipped as data doesn't fit as push constant. */ +GPU_SHADER_CREATE_INFO(gpu_shader_2D_line_dashed_uniform_color) + .vertex_in(0, Type::VEC3, "pos") + .vertex_out(flat_color_iface) + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_2D_line_dashed_uniform_color_vert.glsl") + .fragment_source("gpu_shader_2D_line_dashed_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..b15d7ba3ada --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_nodelink_info.hh @@ -0,0 +1,72 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_INTERFACE_INFO(nodelink_iface, "") + .smooth(Type::VEC4, "finalColor") + .smooth(Type::FLOAT, "colorGradient") + .smooth(Type::FLOAT, "lineU") + .flat(Type::FLOAT, "lineLength") + .flat(Type::FLOAT, "dashFactor") + .flat(Type::FLOAT, "dashAlpha") + .flat(Type::INT, "isMainLine"); + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_nodelink) + .vertex_in(0, Type::VEC2, "uv") + .vertex_in(1, Type::VEC2, "pos") + .vertex_in(2, Type::VEC2, "expand") + .vertex_out(nodelink_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .uniform_buf(0, "NodeLinkData", "node_link_data", Frequency::PASS) + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_2D_nodelink_vert.glsl") + .fragment_source("gpu_shader_2D_nodelink_frag.glsl") + .typedef_source("GPU_shader_shared.h") + .do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_nodelink_inst) + .vertex_in(0, Type::VEC2, "uv") + .vertex_in(1, Type::VEC2, "pos") + .vertex_in(2, Type::VEC2, "expand") + .vertex_in(3, Type::VEC2, "P0") + .vertex_in(4, Type::VEC2, "P1") + .vertex_in(5, Type::VEC2, "P2") + .vertex_in(6, Type::VEC2, "P3") + .vertex_in(7, Type::IVEC4, "colid_doarrow") + .vertex_in(8, Type::VEC4, "start_color") + .vertex_in(9, Type::VEC4, "end_color") + .vertex_in(10, Type::IVEC2, "domuted") + .vertex_in(11, Type::FLOAT, "dim_factor") + .vertex_in(12, Type::FLOAT, "thickness") + .vertex_in(13, Type::FLOAT, "dash_factor") + .vertex_in(14, Type::FLOAT, "dash_alpha") + .vertex_out(nodelink_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .uniform_buf(0, "NodeLinkInstanceData", "node_link_data", Frequency::PASS) + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_2D_nodelink_vert.glsl") + .fragment_source("gpu_shader_2D_nodelink_frag.glsl") + .typedef_source("GPU_shader_shared.h") + .define("USE_INSTANCE") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..d2753af8e9b --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_aa_info.hh @@ -0,0 +1,36 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_point_uniform_size_uniform_color_aa) + .vertex_in(0, Type::VEC2, "pos") + .vertex_out(smooth_radii_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::VEC4, "color") + .push_constant(20, Type::FLOAT, "size") + .vertex_source("gpu_shader_2D_point_uniform_size_aa_vert.glsl") + .fragment_source("gpu_shader_point_uniform_color_aa_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..edc83534573 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_uniform_size_uniform_color_outline_aa_info.hh @@ -0,0 +1,38 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_point_uniform_size_uniform_color_outline_aa) + .vertex_in(0, Type::VEC2, "pos") + .vertex_out(smooth_radii_outline_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(20, Type::VEC4, "color") + .push_constant(24, Type::VEC4, "outlineColor") + .push_constant(28, Type::FLOAT, "size") + .push_constant(29, Type::FLOAT, "outlineWidth") + .vertex_source("gpu_shader_2D_point_uniform_size_outline_aa_vert.glsl") + .fragment_source("gpu_shader_point_uniform_color_outline_aa_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..4358e94f91f --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_point_varying_size_varying_color_info.hh @@ -0,0 +1,36 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_point_varying_size_varying_color) + .vertex_in(0, Type::VEC2, "pos") + .vertex_in(1, Type::FLOAT, "size") + .vertex_in(2, Type::VEC4, "color") + .vertex_out(smooth_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_2D_point_varying_size_varying_color_vert.glsl") + .fragment_source("gpu_shader_point_varying_color_frag.glsl") + .do_static_compilation(true); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_smooth_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_smooth_color_info.hh new file mode 100644 index 00000000000..60612a51135 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_smooth_color_info.hh @@ -0,0 +1,37 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_smooth_color) + .vertex_in(0, Type::VEC2, "pos") + .vertex_in(1, Type::VEC4, "color") + .vertex_out(smooth_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_2D_smooth_color_vert.glsl") + .fragment_source("gpu_shader_2D_smooth_color_frag.glsl") + .additional_info("gpu_srgb_to_framebuffer_space") + .do_static_compilation(true); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_2D_uniform_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_2D_uniform_color_info.hh new file mode 100644 index 00000000000..8977a34986e --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_2D_uniform_color_info.hh @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_2D_uniform_color) + .vertex_in(0, Type::VEC2, "pos") + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::VEC4, "color") + .vertex_source("gpu_shader_2D_vert.glsl") + .fragment_source("gpu_shader_uniform_color_frag.glsl") + .additional_info("gpu_srgb_to_framebuffer_space") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..7ea067010cd --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_depth_only_info.hh @@ -0,0 +1,38 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_depth_only) + .vertex_in(0, Type::VEC3, "pos") + .vertex_out(flat_color_iface) + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_3D_vert.glsl") + .fragment_source("gpu_shader_depth_only_frag.glsl") + .do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_depth_only_clipped) + .additional_info("gpu_shader_3D_depth_only") + .additional_info("gpu_clip_planes"); 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 new file mode 100644 index 00000000000..5857e4cab03 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_flat_color_info.hh @@ -0,0 +1,42 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_flat_color) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC4, "color") + .vertex_out(flat_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(1, Type::BOOL, "srgbTarget") + .vertex_source("gpu_shader_3D_flat_color_vert.glsl") + .fragment_source("gpu_shader_flat_color_frag.glsl") + .additional_info("gpu_srgb_to_framebuffer_space") + .do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_flat_color_clipped) + .additional_info("gpu_shader_3D_flat_color") + .additional_info("gpu_clip_planes"); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_image_modulate_alpha_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_image_modulate_alpha_info.hh new file mode 100644 index 00000000000..a838f6581dc --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_image_modulate_alpha_info.hh @@ -0,0 +1,38 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_image_modulate_alpha) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC2, "texCoord") + .vertex_out(smooth_tex_coord_interp_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::FLOAT, "alpha") + .sampler(0, ImageType::FLOAT_2D, "image", Frequency::PASS) + .vertex_source("gpu_shader_3D_image_vert.glsl") + .fragment_source("gpu_shader_image_modulate_alpha_frag.glsl") + .do_static_compilation(true); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_3D_line_dashed_uniform_color_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_3D_line_dashed_uniform_color_info.hh new file mode 100644 index 00000000000..93cbf1ab06f --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_line_dashed_uniform_color_info.hh @@ -0,0 +1,35 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +/* TODO(jbakker): Skipped as data doesn't fit as push constant. */ +GPU_SHADER_CREATE_INFO(gpu_shader_3D_line_dashed_uniform_color) + .vertex_in(0, Type::VEC3, "pos") + .vertex_out(flat_color_iface) + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_3D_line_dashed_uniform_color_vert.glsl") + .fragment_source("gpu_shader_2D_line_dashed_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..b62c8fe7518 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_point_info.hh @@ -0,0 +1,62 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_point_fixed_size_varying_color) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC4, "color") + .vertex_out(smooth_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::FLOAT, "size") + .vertex_source("gpu_shader_3D_point_fixed_size_varying_color_vert.glsl") + .fragment_source("gpu_shader_point_varying_color_frag.glsl") + .do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_point_varying_size_varying_color) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC4, "color") + .vertex_in(2, Type::FLOAT, "size") + .vertex_out(smooth_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_3D_point_varying_size_varying_color_vert.glsl") + .fragment_source("gpu_shader_point_varying_color_frag.glsl") + .do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_point_uniform_size_uniform_color_aa) + .vertex_in(0, Type::VEC3, "pos") + .vertex_out(smooth_radii_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::VEC4, "color") + .push_constant(20, Type::FLOAT, "size") + .push_constant(24, Type::FLOAT, "outlineWidth") + .vertex_source("gpu_shader_3D_point_uniform_size_aa_vert.glsl") + .fragment_source("gpu_shader_point_uniform_color_aa_frag.glsl") + .do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_point_uniform_size_uniform_color_aa_clipped) + .additional_info("gpu_shader_3D_point_uniform_size_uniform_color_aa") + .additional_info("gpu_clip_planes"); 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 new file mode 100644 index 00000000000..1e195e7ff23 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_polyline_info.hh @@ -0,0 +1,33 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +/* TODO(jbakker): Skipped as it needs a uniform/storage buffer. */ +GPU_SHADER_CREATE_INFO(gpu_shader_3D_polyline_uniform_color) + .vertex_source("gpu_shader_3D_polyline_vert.glsl") + .geometry_source("gpu_shader_3D_polyline_geom.glsl") + .fragment_source("gpu_shader_3D_polyline_frag.glsl") + .do_static_compilation(true); 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 new file mode 100644 index 00000000000..91797b9b414 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_smooth_color_info.hh @@ -0,0 +1,41 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_smooth_color) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC4, "color") + .vertex_out(smooth_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .vertex_source("gpu_shader_3D_smooth_color_vert.glsl") + .fragment_source("gpu_shader_3D_smooth_color_frag.glsl") + .additional_info("gpu_srgb_to_framebuffer_space") + .do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_smooth_color_clipped) + .additional_info("gpu_shader_3D_smooth_color") + .additional_info("gpu_clip_planes"); 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 new file mode 100644 index 00000000000..6162d68cf2e --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_3D_uniform_color_info.hh @@ -0,0 +1,39 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_uniform_color) + .vertex_in(0, Type::VEC3, "pos") + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::VEC4, "color") + .vertex_source("gpu_shader_3D_vert.glsl") + .fragment_source("gpu_shader_uniform_color_frag.glsl") + .additional_info("gpu_srgb_to_framebuffer_space") + .do_static_compilation(true); + +GPU_SHADER_CREATE_INFO(gpu_shader_3D_uniform_color_clipped) + .additional_info("gpu_shader_3D_uniform_color") + .additional_info("gpu_clip_planes"); 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 new file mode 100644 index 00000000000..5fb6c61c5f9 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_gpencil_stroke_info.hh @@ -0,0 +1,51 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_INTERFACE_INFO(gpencil_stroke_vert_iface, "geometry_in") + .smooth(Type::VEC4, "finalColor") + .smooth(Type::FLOAT, "finalThickness"); +GPU_SHADER_INTERFACE_INFO(gpencil_stroke_geom_iface, "geometry_out") + .smooth(Type::VEC4, "mColor") + .smooth(Type::VEC2, "mTexCoord"); + +GPU_SHADER_CREATE_INFO(gpu_shader_gpencil_stroke) + .vertex_in(0, Type::VEC4, "color") + .vertex_in(1, Type::VEC3, "pos") + .vertex_in(2, Type::FLOAT, "thickness") + .vertex_out(gpencil_stroke_vert_iface) + .geometry_layout(InputLayout::LINES_ADJACENCY, OutputLayout::TRIANGLE_STRIP, 13) + .geometry_out(gpencil_stroke_geom_iface) + .fragment_out(0, Type::VEC4, "fragColor") + + .uniform_buf(0, "GPencilStrokeData", "gpencil_stroke_data") + + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::MAT4, "ProjectionMatrix") + .vertex_source("gpu_shader_gpencil_stroke_vert.glsl") + .geometry_source("gpu_shader_gpencil_stroke_geom.glsl") + .fragment_source("gpu_shader_gpencil_stroke_frag.glsl") + .typedef_source("GPU_shader_shared.h") + .do_static_compilation(true); + \ No newline at end of file diff --git a/source/blender/gpu/shaders/infos/gpu_shader_instance_varying_color_varying_size_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_instance_varying_color_varying_size_info.hh new file mode 100644 index 00000000000..0d2daf7388d --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_instance_varying_color_varying_size_info.hh @@ -0,0 +1,39 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_interface_info.hh" +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_shader_instance_varying_color_varying_size) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::MAT4, "InstanceModelMatrix") + .vertex_in(2, Type::VEC4, "color") + .vertex_in(3, Type::FLOAT, "size") + .vertex_out(flat_color_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ViewProjectionMatrix") + .vertex_source("gpu_shader_instance_variying_size_variying_color_vert.glsl") + .fragment_source("gpu_shader_flat_color_frag.glsl") + .additional_info("gpu_srgb_to_framebuffer_space") + .do_static_compilation(true); + \ No newline at end of file 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 new file mode 100644 index 00000000000..8e352af6c1f --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_keyframe_shape_info.hh @@ -0,0 +1,47 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_INTERFACE_INFO(keyframe_shape_iface, "") + .flat(Type::VEC4, "finalColor") + .flat(Type::VEC4, "finalOutlineColor") + .flat(Type::VEC4, "radii") + .flat(Type::VEC4, "thresholds") + .flat(Type::INT, "finalFlags"); + +GPU_SHADER_CREATE_INFO(gpu_shader_keyframe_shape) + .vertex_in(0, Type::VEC4, "color") + .vertex_in(1, Type::VEC4, "outlineColor") + .vertex_in(2, Type::VEC2, "pos") + .vertex_in(3, Type::FLOAT, "size") + .vertex_in(4, Type ::INT, "flags") + .vertex_out(keyframe_shape_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::VEC2, "ViewportSize") + .push_constant(24, Type::FLOAT, "outline_scale") + .vertex_source("gpu_shader_keyframe_shape_vert.glsl") + .fragment_source("gpu_shader_keyframe_shape_frag.glsl") + .do_static_compilation(true); + \ No newline at end of file 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 new file mode 100644 index 00000000000..c3f86ed2b6f --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_simple_lighting_info.hh @@ -0,0 +1,40 @@ + +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_INTERFACE_INFO(smooth_normal_iface, "").smooth(Type::VEC3, "normal"); + +GPU_SHADER_CREATE_INFO(gpu_shader_simple_lighting) + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::VEC3, "nor") + .vertex_out(smooth_normal_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .uniform_buf(0, "SimpleLightingData", "simple_lighting_data", Frequency::PASS) + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .push_constant(16, Type::MAT3, "NormalMatrix") + .typedef_source("GPU_shader_shared.h") + .vertex_source("gpu_shader_3D_normal_vert.glsl") + .fragment_source("gpu_shader_simple_lighting_frag.glsl") + .do_static_compilation(true); diff --git a/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh b/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh new file mode 100644 index 00000000000..a115972694e --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_shader_text_info.hh @@ -0,0 +1,46 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_INTERFACE_INFO(text_iface, "") + .flat(Type::VEC4, "color_flat") + .no_perspective(Type::VEC2, "texCoord_interp") + .flat(Type::INT, "glyph_offset") + .flat(Type::IVEC2, "glyph_dim") + .flat(Type::INT, "interp_size"); + +GPU_SHADER_CREATE_INFO(gpu_shader_text) + .vertex_in(0, Type::VEC4, "pos") + .vertex_in(1, Type::VEC4, "col") + .vertex_in(2, Type ::IVEC2, "glyph_size") + .vertex_in(3, Type ::INT, "offset") + .vertex_out(text_iface) + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(0, Type::MAT4, "ModelViewProjectionMatrix") + .sampler(0, ImageType::FLOAT_2D, "glyph", Frequency::PASS) + .vertex_source("gpu_shader_text_vert.glsl") + .fragment_source("gpu_shader_text_frag.glsl") + .additional_info("gpu_srgb_to_framebuffer_space") + .do_static_compilation(true); + \ No newline at end of file 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 new file mode 100644 index 00000000000..3af49b56ab1 --- /dev/null +++ b/source/blender/gpu/shaders/infos/gpu_srgb_to_framebuffer_space_info.hh @@ -0,0 +1,27 @@ +/* + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; either version 2 + * of the License, or (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * The Original Code is Copyright (C) 2022 Blender Foundation. + * All rights reserved. + */ + +/** \file + * \ingroup gpu + */ + +#include "gpu_shader_create_info.hh" + +GPU_SHADER_CREATE_INFO(gpu_srgb_to_framebuffer_space) + .define("blender_srgb_to_framebuffer_space(a) a"); -- cgit v1.2.3