diff options
author | Jason Fielder <jason_apple> | 2022-09-22 18:40:45 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2022-09-22 18:43:04 +0300 |
commit | 1514e1a5b7e15ec0c11cd40c2b9389982bd5d00e (patch) | |
tree | 3c7028d7d8e9a96b3047d2e5ad84f0c2276f2530 /source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh | |
parent | 697b447c2069bbbbaa9929aab0ea1f66ef8bf4d0 (diff) |
Metal: First set of Geometry Shader alternative implementations using SSBO vertex shader fetch.
These implementations remove dependency on the Geometry pass by instead invoking one vertex shader instance for each expected output vertex, matching what a geometry shader would emit. Each vertex shader instance is then responsible for calculating the same output position based on its vertex_id as the logic would in the geometry shader version.
SSBO Vertex fetch enables full random-access into a vertex buffer by binding it as a read-only SSBO. This enables each instance to read neighbouring vertex data to perform contextual calculations as a geometry shader would, for cases where attribute Multiload is not supported.
Authored by Apple: Michael Parkin-White
Ref T96261
Reviewed By: fclem
Differential Revision: https://developer.blender.org/D15901
Diffstat (limited to 'source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh')
-rw-r--r-- | source/blender/draw/engines/overlay/shaders/infos/overlay_edit_mode_info.hh | 55 |
1 files changed, 55 insertions, 0 deletions
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 9396a6d3f2f..92a35a049a4 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 @@ -22,6 +22,17 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_common) .vertex_source("overlay_edit_mesh_vert.glsl") .additional_info("draw_modelmat", "draw_globals"); +GPU_SHADER_CREATE_INFO(overlay_edit_mesh_common_no_geom) + .define("blender_srgb_to_framebuffer_space(a)", "a") + .sampler(0, ImageType::DEPTH_2D, "depthTex") + .fragment_out(0, Type::VEC4, "fragColor") + .push_constant(Type::BOOL, "selectFaces") + .push_constant(Type::BOOL, "selectEdges") + .push_constant(Type::FLOAT, "alpha") + .push_constant(Type::IVEC4, "dataMask") + .vertex_source("overlay_edit_mesh_vert_no_geom.glsl") + .additional_info("draw_modelmat", "draw_globals"); + GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_vert_iface, "") .smooth(Type::VEC4, "finalColor") .smooth(Type::FLOAT, "vertexCrease"); @@ -61,11 +72,28 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge) .fragment_source("overlay_edit_mesh_frag.glsl") .additional_info("overlay_edit_mesh_common"); +/* The Non-Geometry shader variant passes directly to fragment. */ +GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_no_geom) + .do_static_compilation(true) + .define("EDGE") + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::UCHAR4, "data") + .vertex_in(2, Type::VEC3_101010I2, "vnor") + .push_constant(Type::BOOL, "do_smooth_wire") + .vertex_out(overlay_edit_mesh_edge_geom_iface) + .fragment_source("overlay_edit_mesh_frag.glsl") + .additional_info("overlay_edit_mesh_common_no_geom"); + GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat) .do_static_compilation(true) .define("FLAT") .additional_info("overlay_edit_mesh_edge"); +GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_no_geom) + .do_static_compilation(true) + .define("FLAT") + .additional_info("overlay_edit_mesh_edge_no_geom"); + GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face) .do_static_compilation(true) .define("FACE") @@ -136,10 +164,18 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_clipped) .do_static_compilation(true) .additional_info("overlay_edit_mesh_edge", "drw_clipped"); +GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_clipped_no_geom) + .do_static_compilation(true) + .additional_info("overlay_edit_mesh_edge_no_geom", "drw_clipped"); + GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_clipped) .do_static_compilation(true) .additional_info("overlay_edit_mesh_edge_flat", "drw_clipped"); +GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge_flat_clipped_no_geom) + .do_static_compilation(true) + .additional_info("overlay_edit_mesh_edge_flat_no_geom", "drw_clipped"); + GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face_clipped) .do_static_compilation(true) .additional_info("overlay_edit_mesh_face", "drw_clipped"); @@ -326,10 +362,29 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle) .fragment_source("overlay_varying_color.glsl") .additional_info("draw_mesh", "draw_globals"); +GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_no_geom) + .do_static_compilation(true) + .typedef_source("overlay_shader_shared.h") + /* NOTE: Color already in Linear space. Which is what we want. */ + .define("srgbTarget", "false") + .vertex_in(0, Type::VEC3, "pos") + .vertex_in(1, Type::INT, "data") + .vertex_out(overlay_edit_curve_handle_iface) + .push_constant(Type::BOOL, "showCurveHandles") + .push_constant(Type::INT, "curveHandleDisplay") + .fragment_out(0, Type::VEC4, "fragColor") + .vertex_source("overlay_edit_curve_handle_vert_no_geom.glsl") + .fragment_source("overlay_varying_color.glsl") + .additional_info("draw_mesh", "draw_globals"); + GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_clipped) .do_static_compilation(true) .additional_info("overlay_edit_curve_handle", "drw_clipped"); +GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_clipped_no_geom) + .do_static_compilation(true) + .additional_info("overlay_edit_curve_handle_no_geom", "drw_clipped"); + GPU_SHADER_CREATE_INFO(overlay_edit_curve_point) .do_static_compilation(true) .typedef_source("overlay_shader_shared.h") |