13ShaderModule *ShaderModule::g_shader_modules[2][2] = {{
nullptr}};
15ShaderModule::ShaderPtr ShaderModule::shader(
16 const char *create_info_name,
17 const FunctionRef<
void(gpu::shader::ShaderCreateInfo &info)> patch)
20 gpu::shader::ShaderCreateInfo info(create_info_name);
22 reinterpret_cast<GPUShaderCreateInfo &
>(info));
26 info.define(
"OVERLAY_NEXT");
28 if (clipping_enabled_) {
29 info.define(
"USE_WORLD_CLIP_PLANES");
36ShaderModule::ShaderPtr ShaderModule::selectable_shader(
const char *create_info_name)
47 gpu::shader::ShaderCreateInfo info(create_info_name);
49 reinterpret_cast<GPUShaderCreateInfo &
>(info));
51 info.define(
"OVERLAY_NEXT");
53 if (selection_type_ != SelectionType::DISABLED) {
54 info.define(
"SELECT_ENABLE");
57 for (StringRefNull &
str : info.additional_infos_) {
58 if (
str ==
"draw_modelmat_new") {
59 str =
"draw_modelmat_new_with_custom_id";
62 info.additional_info(
"select_id_patch");
65 if (clipping_enabled_) {
66 info.define(
"USE_WORLD_CLIP_PLANES");
73ShaderModule::ShaderPtr ShaderModule::selectable_shader(
74 const char *create_info_name,
75 const FunctionRef<
void(gpu::shader::ShaderCreateInfo &info)> patch)
78 gpu::shader::ShaderCreateInfo info(create_info_name);
80 reinterpret_cast<GPUShaderCreateInfo &
>(info));
84 info.define(
"OVERLAY_NEXT");
86 if (selection_type_ != SelectionType::DISABLED) {
87 info.define(
"SELECT_ENABLE");
90 for (StringRefNull &
str : info.additional_infos_) {
91 if (
str ==
"draw_modelmat_new") {
92 str =
"draw_modelmat_new_with_custom_id";
95 info.additional_info(
"select_id_patch");
98 if (clipping_enabled_) {
99 info.define(
"USE_WORLD_CLIP_PLANES");
112 "draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_globals");
121 info.
storage_buf(1, Qualifier::READ,
"float",
"pos[]", Frequency::GEOMETRY);
125 : selection_type_(selection_type), clipping_enabled_(clipping_enabled)
132 info.
additional_info(
"overlay_viewer_attribute_common",
"draw_view",
"draw_modelmat_new");
138 "draw_pointcloud_new",
140 "draw_modelmat_new");
145 info.
additional_info(
"overlay_viewer_attribute_common",
"draw_view",
"draw_modelmat_new");
151 "overlay_viewer_attribute_common",
"draw_hair_new",
"draw_view",
"draw_modelmat_new");
156 info.
storage_buf(0, Qualifier::READ,
"ExtraInstanceData",
"data_buf[]");
157 info.
define(
"inst_obmat",
"data_buf[gl_InstanceID].object_to_world_");
158 info.
define(
"color",
"data_buf[gl_InstanceID].color_");
164 "overlay_edit_particle_point",
175 .
storage_buf(0, Qualifier::READ,
"VertexData",
"data_buf[]")
176 .
define(
"pos",
"data_buf[gl_VertexID].pos_.xyz")
177 .
define(
"ucolor",
"data_buf[gl_VertexID].color_");
183 info.
define(
"tile_pos",
"vec3(0.0)");
188 info.
storage_buf(0, Qualifier::READ,
"vec3",
"tile_pos_buf[]")
189 .
define(
"tile_pos",
"tile_pos_buf[gl_InstanceID]")
190 .
define(
"tile_scale",
"vec3(1.0)");
195 "overlay_edit_curve_wire",
198 "overlay_edit_curve_point",
220 info.
storage_buf(0, Qualifier::READ,
"float",
"size[]", Frequency::GEOMETRY);
222 info.
define(
"VERTEX_PULL");
227 info.
define(
"FACE_NORMAL");
229 info.
storage_buf(0, Qualifier::READ,
"uint",
"norAndFlag[]", Frequency::GEOMETRY);
235 info.
define(
"FACE_NORMAL");
236 info.
define(
"FLOAT_NORMAL");
237 info.
storage_buf(0, Qualifier::READ,
"vec4",
"norAndFlag[]", Frequency::GEOMETRY);
242 info.
define(
"LOOP_NORMAL");
244 info.
storage_buf(0, Qualifier::READ,
"uint",
"lnor[]", Frequency::GEOMETRY);
250 info.
define(
"LOOP_NORMAL");
251 info.
define(
"FLOAT_NORMAL");
252 info.
storage_buf(0, Qualifier::READ,
"vec4",
"lnor[]", Frequency::GEOMETRY);
257 info.
define(
"VERT_NORMAL");
258 info.
storage_buf(0, Qualifier::READ,
"uint",
"vnor[]", Frequency::GEOMETRY);
264 info.
additional_info(
"draw_object_infos_new",
"overlay_outline_prepass");
269 info.
additional_info(
"draw_hair_new",
"draw_object_infos_new",
"overlay_outline_prepass");
275 "draw_pointcloud_new",
"draw_object_infos_new",
"overlay_outline_prepass");
284 "overlay_edit_particle_point",
287 "overlay_edit_particle_strand",
306 info.
define(
"FAKE_SHADING");
318 "overlay_sculpt_curves_cage",
341 info.
define(
"tile_scale",
"vec3(1.0)");
359 info.
sampler(2, ImageType::DEPTH_2D,
"xrayDepthTexInfront");
366 info.
storage_buf(0, Qualifier::READ,
"BoneEnvelopeData",
"data_buf[]");
367 info.
define(
"headSphere",
"data_buf[gl_InstanceID].head_sphere");
368 info.
define(
"tailSphere",
"data_buf[gl_InstanceID].tail_sphere");
369 info.
define(
"xAxis",
"data_buf[gl_InstanceID].x_axis.xyz");
370 info.
define(
"stateColor",
"data_buf[gl_InstanceID].state_color.xyz");
371 info.
define(
"boneColor",
"data_buf[gl_InstanceID].bone_color_and_wire_width.xyz");
381 info.
storage_buf(0, Qualifier::READ,
"BoneEnvelopeData",
"data_buf[]");
382 info.
define(
"headSphere",
"data_buf[gl_InstanceID].head_sphere");
383 info.
define(
"tailSphere",
"data_buf[gl_InstanceID].tail_sphere");
384 info.
define(
"outlineColorSize",
"data_buf[gl_InstanceID].bone_color_and_wire_width");
385 info.
define(
"xAxis",
"data_buf[gl_InstanceID].x_axis.xyz");
397 info.
storage_buf(0, Qualifier::READ,
"mat4",
"data_buf[]");
398 info.
define(
"inst_obmat",
"data_buf[gl_InstanceID]");
407 info.
storage_buf(0, Qualifier::READ,
"mat4",
"data_buf[]");
408 info.
define(
"inst_obmat",
"data_buf[gl_InstanceID]");
413 info.
storage_buf(0, Qualifier::READ,
"mat4",
"data_buf[]");
414 info.
define(
"inst_obmat",
"data_buf[gl_InstanceID]");
422 "overlay_armature_common",
423 "draw_resource_handle_new",
426 info.
storage_buf(0, Qualifier::READ,
"BoneStickData",
"data_buf[]");
427 info.
define(
"boneStart",
"data_buf[gl_InstanceID].bone_start.xyz");
428 info.
define(
"boneEnd",
"data_buf[gl_InstanceID].bone_end.xyz");
429 info.
define(
"wireColor",
"data_buf[gl_InstanceID].wire_color");
430 info.
define(
"boneColor",
"data_buf[gl_InstanceID].bone_color");
431 info.
define(
"headColor",
"data_buf[gl_InstanceID].head_color");
432 info.
define(
"tailColor",
"data_buf[gl_InstanceID].tail_color");
441 info.
define(
"flag",
"vclass");
448 "overlay_frag_output",
449 "draw_resource_handle_new",
452 info.
storage_buf(0, Qualifier::READ,
"VertexData",
"data_buf[]");
453 info.
define(
"pos",
"data_buf[gl_VertexID].pos_.xyz");
454 info.
define(
"color",
"data_buf[gl_VertexID].color_");
462 "draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_globals");
468 info.
additional_info(
"draw_volume_new",
"draw_view",
"overlay_volume_gridlines");
474 info.
additional_info(
"draw_volume_new",
"draw_view",
"overlay_volume_gridlines");
480 info.
additional_info(
"draw_volume_new",
"draw_view",
"overlay_volume_gridlines");
486 info.
additional_info(
"draw_volume_new",
"draw_view",
"overlay_volume_velocity");
492 info.
additional_info(
"draw_volume_new",
"draw_view",
"overlay_volume_velocity");
498 info.
additional_info(
"draw_volume_new",
"draw_view",
"overlay_volume_velocity");
502 info.
storage_buf(0, Qualifier::READ,
"ExtraInstanceData",
"data_buf[]");
503 info.
define(
"color",
"data_buf[gl_InstanceID].color_");
504 info.
define(
"inst_obmat",
"data_buf[gl_InstanceID].object_to_world_");
511 info.
storage_buf(0, Qualifier::READ,
"VertexData",
"data_buf[]");
513 info.
define(
"pos",
"data_buf[gl_VertexID].pos_.xyz");
514 info.
define(
"color",
"data_buf[gl_VertexID].color_");
517 "draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_globals");
525 info.
define(
"OBJECT_WIRE");
528 "draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_globals");
534 info.
storage_buf(0, Qualifier::READ,
"VertexData",
"data_buf[]");
535 info.
define(
"pos",
"data_buf[gl_VertexID].pos_.xyz");
536 info.
define(
"vertex_color",
"data_buf[gl_VertexID].color_");
540 info.
additional_info(
"draw_view",
"draw_modelmat_new",
"draw_globals");
547 "draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_globals");
554 "draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_globals");
560 "draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_globals");
565 info.
storage_buf(0, Qualifier::READ,
"vec4",
"data_buf[]");
566 info.
define(
"inst_pos",
"data_buf[gl_InstanceID].xyz");
573 "draw_view",
"draw_globals",
"draw_modelmat_new",
"draw_resource_handle_new");
576 particle_dot = selectable_shader(
"overlay_particle_dot",
582 "draw_resource_handle_new",
589 particle_hair = selectable_shader(
"overlay_particle_hair_next",
595 "draw_view",
"draw_modelmat_new",
"draw_resource_handle_new",
"draw_globals");
602 .
storage_buf(0, Qualifier::READ,
"ObjectMatrices",
"matrix_buf[]")
603 .
define(
"DRAW_MODELMAT_CREATE_INFO")
604 .
define(
"drw_ModelMatrixInverse",
"matrix_buf[gl_InstanceID].model_inverse")
605 .
define(
"drw_ModelMatrix",
"matrix_buf[gl_InstanceID].model")
607 .
define(
"ModelMatrixInverse",
"drw_ModelMatrixInverse")
608 .
define(
"ModelMatrix",
"drw_ModelMatrix");
613 info.
define(
"CUSTOM_DEPTH_BIAS_CONST");
617 "draw_resource_handle_new",
618 "draw_object_infos_new",
631 int selection_index = selection_type == SelectionType::DISABLED ? 0 : 1;
632 ShaderModule *&g_shader_module = g_shader_modules[selection_index][clipping_enabled];
633 if (g_shader_module ==
nullptr) {
635 g_shader_module =
new ShaderModule(selection_type, clipping_enabled);
637 return *g_shader_module;
644 if (g_shader_modules[i][j] !=
nullptr) {
646 delete g_shader_modules[i][j];
647 g_shader_modules[i][j] =
nullptr;
GPUShader * GPU_shader_create_from_info(const GPUShaderCreateInfo *_info)
void GPU_shader_create_info_get_unfinalized_copy(const char *info_name, GPUShaderCreateInfo &r_info)
ShaderPtr attribute_viewer_pointcloud
ShaderModule(const SelectionType selection_type, const bool clipping_enabled)
ShaderPtr legacy_curve_edit_points
ShaderPtr uv_brush_stencil
ShaderPtr uv_edit_facedot
ShaderPtr armature_envelope_fill
ShaderPtr paint_region_edge
ShaderPtr paint_region_face
ShaderPtr paint_weight_fake_shading
ShaderPtr sculpt_curves_cage
ShaderPtr outline_prepass_gpencil
ShaderPtr fluid_velocity_needle
ShaderPtr armature_envelope_outline
ShaderPtr mesh_loop_normal
ShaderPtr fluid_grid_lines_flat
ShaderPtr mesh_face_normal_subdiv
ShaderPtr fluid_grid_lines_flags
ShaderPtr outline_prepass_curves
ShaderPtr uv_image_borders
ShaderPtr curve_edit_line
ShaderPtr extra_wire_object
ShaderPtr particle_edit_edge
ShaderPtr particle_edit_vert
ShaderPtr uv_analysis_stretch_angle
ShaderPtr armature_sphere_fill
ShaderPtr attribute_viewer_mesh
ShaderPtr mesh_vert_normal
ShaderPtr fluid_velocity_mac
ShaderPtr fluid_grid_lines_range
ShaderPtr uniform_color_batch
ShaderPtr fluid_velocity_streamline
ShaderPtr wireframe_points
static void module_free()
ShaderPtr armature_shape_fill
ShaderPtr wireframe_curve
ShaderPtr attribute_viewer_curves
ShaderPtr mesh_face_normal
ShaderPtr armature_sphere_outline
ShaderPtr armature_degrees_of_freedom
ShaderPtr armature_shape_wire
ShaderPtr mesh_edit_skin_root
ShaderPtr legacy_curve_edit_wires
ShaderPtr extra_ground_line
ShaderPtr curve_edit_points
ShaderPtr outline_prepass_mesh
ShaderPtr mesh_edit_depth
ShaderPtr paint_region_vert
ShaderPtr outline_prepass_pointcloud
ShaderPtr grid_background
ShaderPtr mesh_loop_normal_subdiv
ShaderPtr uv_analysis_stretch_area
ShaderPtr armature_shape_outline
ShaderPtr attribute_viewer_curve
ShaderPtr extra_loose_points
static ShaderModule * module_get()
input_tx typedef_source("gpu_shader_compositor_type_conversion.glsl") .compute_source("compositor_convert.glsl")
output_img define("CONVERT_EXPRESSION(value)", "value") .do_static_compilation(true)
DOF_REDUCE_GROUP_SIZE dof_buf scatter_fg_list_buf[] storage_buf(1, Qualifier::WRITE, "ScatterRect", "scatter_bg_list_buf[]") .storage_buf(2
static void shader_patch_common(gpu::shader::ShaderCreateInfo &info)
static void shader_patch_edit_mesh_normal_common(gpu::shader::ShaderCreateInfo &info)
Describe inputs & outputs, stage interfaces, resources and sources of a shader. If all data is correc...
Vector< std::array< StringRefNull, 2 > > defines_
Self & vertex_in(int slot, Type type, StringRefNull name)
Vector< VertIn > vertex_inputs_
Self & push_constant(Type type, StringRefNull name, int array_size=0)
Vector< StringRefNull > additional_infos_
Self & additional_info(StringRefNull info_name)
Self & typedef_source(StringRefNull filename)
Self & storage_buf(int slot, Qualifier qualifiers, StringRefNull type_name, StringRefNull name, Frequency freq=Frequency::PASS)
Self & sampler(int slot, ImageType type, StringRefNull name, Frequency freq=Frequency::PASS, GPUSamplerState sampler=GPUSamplerState::internal_sampler())
Self & specialization_constant(Type type, StringRefNull name, double default_value)
Self & define(StringRefNull name, StringRefNull value="")
Vector< PushConst > push_constants_