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