Blender V4.3
gpu_shader_2D_widget_info.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2022 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
11
12GPU_SHADER_INTERFACE_INFO(gpu_widget_iface, "")
13 .flat(Type::FLOAT, "discardFac")
14 .flat(Type::FLOAT, "lineWidth")
15 .flat(Type::VEC2, "outRectSize")
16 .flat(Type::VEC4, "borderColor")
17 .flat(Type::VEC4, "embossColor")
18 .flat(Type::VEC4, "outRoundCorners")
19 .no_perspective(Type::FLOAT, "butCo")
20 .no_perspective(Type::VEC2, "uvInterp")
21 .no_perspective(Type::VEC4, "innerColor");
22
23/* TODO(fclem): Share with C code. */
24#define MAX_PARAM 12
25#define MAX_INSTANCE 6
26
27GPU_SHADER_CREATE_INFO(gpu_shader_2D_widget_shared)
28 .define("MAX_PARAM", STRINGIFY(MAX_PARAM))
29 .push_constant(Type::MAT4, "ModelViewProjectionMatrix")
30 .push_constant(Type::VEC3, "checkerColorAndSize")
31 .vertex_out(gpu_widget_iface)
32 .fragment_out(0, Type::VEC4, "fragColor")
33 .vertex_source("gpu_shader_2D_widget_base_vert.glsl")
34 .fragment_source("gpu_shader_2D_widget_base_frag.glsl")
35 .additional_info("gpu_srgb_to_framebuffer_space");
36
37GPU_SHADER_CREATE_INFO(gpu_shader_2D_widget_base)
38 .do_static_compilation(true)
39 /* gl_InstanceID is supposed to be 0 if not drawing instances, but this seems
40 * to be violated in some drivers. For example, macOS 10.15.4 and Intel Iris
41 * causes #78307 when using gl_InstanceID outside of instance. */
42 .define("widgetID", "0")
43 .push_constant(Type::VEC4, "parameters", MAX_PARAM)
44 .additional_info("gpu_shader_2D_widget_shared");
45
46GPU_SHADER_CREATE_INFO(gpu_shader_2D_widget_base_inst)
47 .do_static_compilation(true)
48 .define("widgetID", "gl_InstanceID")
49 .push_constant(Type::VEC4, "parameters", (MAX_PARAM * MAX_INSTANCE))
50 .additional_info("gpu_shader_2D_widget_shared");
51
52GPU_SHADER_INTERFACE_INFO(gpu_widget_shadow_iface, "")
53 .smooth(Type::FLOAT, "shadowFalloff")
54 .smooth(Type::FLOAT, "innerMask");
55
56GPU_SHADER_CREATE_INFO(gpu_shader_2D_widget_shadow)
57 .do_static_compilation(true)
58 .push_constant(Type::MAT4, "ModelViewProjectionMatrix")
59 .push_constant(Type::VEC4, "parameters", 4)
60 .push_constant(Type::FLOAT, "alpha")
61 .vertex_in(0, Type::UINT, "vflag")
62 .vertex_out(gpu_widget_shadow_iface)
63 .fragment_out(0, Type::VEC4, "fragColor")
64 .vertex_source("gpu_shader_2D_widget_shadow_vert.glsl")
65 .fragment_source("gpu_shader_2D_widget_shadow_frag.glsl");
#define STRINGIFY(x)
#define MAX_PARAM
#define MAX_INSTANCE
#define GPU_SHADER_INTERFACE_INFO(_interface, _inst_name)
#define GPU_SHADER_CREATE_INFO(_info)