Metal: GLSL compatibility.

Additional mat3 constructors added, global variable namespace collisions
for uniform and object color avoided via re-name.

Metal vertex format compatibility added for shaders wherein vertex data
goes through a double-conversion and cannot be implicitly converted during
Metal vertex assembly e.g. bitmasks passed directly as unsigned type in
shader interface for certain shader interfaces.

Authored by Apple: Michael Parkin-White

Ref T96261

Reviewed By: fclem
Differential Revision: https://developer.blender.org/D16433
This commit is contained in:
Jason Fielder 2022-12-08 21:29:40 +01:00 committed by Clément Foucault
parent 6b8bb26c45
commit d90a2b0ab7
Notes: blender-bot 2023-02-14 08:59:10 +01:00
Referenced by issue #96261, Metal Viewport
29 changed files with 380 additions and 140 deletions

View File

@ -605,6 +605,7 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_edit_uv_edges_frag.glsl
engines/overlay/shaders/overlay_edit_uv_edges_geom.glsl
engines/overlay/shaders/overlay_edit_uv_edges_vert.glsl
engines/overlay/shaders/overlay_edit_uv_edges_vert_no_geom.glsl
engines/overlay/shaders/overlay_edit_uv_face_dots_vert.glsl
engines/overlay/shaders/overlay_edit_uv_faces_vert.glsl
engines/overlay/shaders/overlay_edit_uv_image_mask_frag.glsl
@ -642,6 +643,7 @@ set(GLSL_SRC
engines/overlay/shaders/overlay_outline_prepass_gpencil_vert.glsl
engines/overlay/shaders/overlay_outline_prepass_pointcloud_vert.glsl
engines/overlay/shaders/overlay_outline_prepass_vert.glsl
engines/overlay/shaders/overlay_outline_prepass_vert_no_geom.glsl
engines/overlay/shaders/overlay_paint_face_vert.glsl
engines/overlay/shaders/overlay_paint_point_vert.glsl
engines/overlay/shaders/overlay_paint_texture_frag.glsl

View File

@ -241,7 +241,7 @@ void OVERLAY_grid_cache_init(OVERLAY_Data *ved)
DRWShadingGroup *grp = DRW_shgroup_create(sh, psl->grid_ps);
float color_back[4];
interp_v4_v4v4(color_back, G_draw.block.color_background, G_draw.block.color_grid, 0.5);
DRW_shgroup_uniform_vec4_copy(grp, "color", color_back);
DRW_shgroup_uniform_vec4_copy(grp, "ucolor", color_back);
DRW_shgroup_uniform_texture_ref(grp, "depthBuffer", &dtxl->depth);
unit_m4(mat);
mat[0][0] = grid->size[0];

View File

@ -57,14 +57,14 @@ BLI_STATIC_ASSERT_ALIGN(OVERLAY_GridData, 16)
#ifdef GPU_SHADER
/* Keep the same values as in `draw_cache_imp_curve.c` */
# define ACTIVE_NURB (1 << 2)
# define BEZIER_HANDLE (1 << 3)
# define EVEN_U_BIT (1 << 4)
# define COLOR_SHIFT 5
# define ACTIVE_NURB (1u << 2)
# define BEZIER_HANDLE (1u << 3)
# define EVEN_U_BIT (1u << 4)
# define COLOR_SHIFT 5u
/* Keep the same value in `handle_display` in `DNA_view3d_types.h` */
# define CURVE_HANDLE_SELECTED 0
# define CURVE_HANDLE_ALL 1
# define CURVE_HANDLE_SELECTED 0u
# define CURVE_HANDLE_ALL 1u
# define GP_EDIT_POINT_SELECTED 1u /* 1 << 0 */
# define GP_EDIT_STROKE_SELECTED 2u /* 1 << 1 */
@ -73,15 +73,15 @@ BLI_STATIC_ASSERT_ALIGN(OVERLAY_GridData, 16)
# define GP_EDIT_STROKE_END 16u /* 1 << 4 */
# define GP_EDIT_POINT_DIMMED 32u /* 1 << 5 */
# define MOTIONPATH_VERT_SEL (1 << 0)
# define MOTIONPATH_VERT_KEY (1 << 1)
# define MOTIONPATH_VERT_SEL (1u << 0)
# define MOTIONPATH_VERT_KEY (1u << 1)
#else
/* TODO(fclem): Find a better way to share enums/defines from DNA files with GLSL. */
BLI_STATIC_ASSERT(CURVE_HANDLE_SELECTED == 0, "Ensure value is sync");
BLI_STATIC_ASSERT(CURVE_HANDLE_ALL == 1, "Ensure value is sync");
BLI_STATIC_ASSERT(MOTIONPATH_VERT_SEL == (1 << 0), "Ensure value is sync");
BLI_STATIC_ASSERT(MOTIONPATH_VERT_KEY == (1 << 1), "Ensure value is sync");
BLI_STATIC_ASSERT(CURVE_HANDLE_SELECTED == 0u, "Ensure value is sync");
BLI_STATIC_ASSERT(CURVE_HANDLE_ALL == 1u, "Ensure value is sync");
BLI_STATIC_ASSERT(MOTIONPATH_VERT_SEL == (1u << 0), "Ensure value is sync");
BLI_STATIC_ASSERT(MOTIONPATH_VERT_KEY == (1u << 1), "Ensure value is sync");
#endif
#ifndef GPU_SHADER

View File

@ -42,7 +42,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_vert)
.builtins(BuiltinBits::POINT_SIZE)
.define("VERT")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::IVEC4, "data")
.vertex_in(1, Type::UVEC4, "data")
.vertex_in(2, Type::VEC3, "vnor")
.vertex_out(overlay_edit_mesh_vert_iface)
.fragment_source("overlay_point_varying_color_frag.glsl")
@ -51,7 +51,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_vert)
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_edge_iface, "geometry_in")
.smooth(Type::VEC4, "finalColor_")
.smooth(Type::VEC4, "finalColorOuter_")
.smooth(Type::INT, "selectOverride_");
.smooth(Type::UINT, "selectOverride_");
GPU_SHADER_INTERFACE_INFO(overlay_edit_mesh_edge_geom_iface, "geometry_out")
.smooth(Type::VEC4, "finalColor")
@ -62,7 +62,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_edge)
.do_static_compilation(true)
.define("EDGE")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::IVEC4, "data")
.vertex_in(1, Type::UVEC4, "data")
.vertex_in(2, Type::VEC3, "vnor")
.push_constant(Type::BOOL, "do_smooth_wire")
.vertex_out(overlay_edit_mesh_edge_iface)
@ -98,7 +98,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_face)
.do_static_compilation(true)
.define("FACE")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::IVEC4, "data")
.vertex_in(1, Type::UVEC4, "data")
.vertex_in(2, Type::VEC3, "vnor")
.vertex_out(overlay_edit_flat_color_iface)
.fragment_source("overlay_varying_color.glsl")
@ -108,7 +108,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_mesh_facedot)
.do_static_compilation(true)
.define("FACEDOT")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::IVEC4, "data")
.vertex_in(1, Type::UVEC4, "data")
.vertex_in(2, Type::VEC4, "norAndFlag")
.define("vnor", "norAndFlag.xyz")
.vertex_out(overlay_edit_flat_color_iface)
@ -213,23 +213,32 @@ GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_geom_iface, "geom_out")
.no_perspective(Type::VEC2, "stipplePos")
.flat(Type::VEC2, "stippleStart");
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges)
.do_static_compilation(true)
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_common)
.vertex_in(0, Type::VEC2, "au")
.vertex_in(1, Type::INT, "flag")
.vertex_out(overlay_edit_uv_iface)
.geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
.geometry_out(overlay_edit_uv_geom_iface)
.vertex_in(1, Type::UINT, "flag")
.push_constant(Type::INT, "lineStyle")
.push_constant(Type::BOOL, "doSmoothWire")
.push_constant(Type::FLOAT, "alpha")
.push_constant(Type::FLOAT, "dashLength")
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_edit_uv_edges_vert.glsl")
.geometry_source("overlay_edit_uv_edges_geom.glsl")
.fragment_source("overlay_edit_uv_edges_frag.glsl")
.additional_info("draw_mesh", "draw_globals");
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges)
.additional_info("overlay_edit_uv_edges_common")
.do_static_compilation(true)
.vertex_out(overlay_edit_uv_iface)
.geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 4)
.geometry_out(overlay_edit_uv_geom_iface)
.vertex_source("overlay_edit_uv_edges_vert.glsl")
.geometry_source("overlay_edit_uv_edges_geom.glsl");
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_no_geom)
.additional_info("overlay_edit_uv_edges_common")
// .do_static_compilation(true)
.vertex_out(overlay_edit_uv_geom_iface)
.vertex_source("overlay_edit_uv_edges_vert_no_geom.glsl");
GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_select)
.do_static_compilation(true)
.define("USE_EDGE_SELECT")
@ -238,7 +247,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_uv_edges_select)
GPU_SHADER_CREATE_INFO(overlay_edit_uv_faces)
.do_static_compilation(true)
.vertex_in(0, Type::VEC2, "au")
.vertex_in(1, Type::INT, "flag")
.vertex_in(1, Type::UINT, "flag")
.push_constant(Type::FLOAT, "uvOpacity")
.vertex_out(overlay_edit_flat_color_iface)
.fragment_out(0, Type::VEC4, "fragColor")
@ -249,7 +258,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_uv_faces)
GPU_SHADER_CREATE_INFO(overlay_edit_uv_face_dots)
.do_static_compilation(true)
.vertex_in(0, Type::VEC2, "au")
.vertex_in(1, Type::INT, "flag")
.vertex_in(1, Type::UINT, "flag")
.push_constant(Type::FLOAT, "pointSize")
.vertex_out(overlay_edit_flat_color_iface)
.fragment_out(0, Type::VEC4, "fragColor")
@ -265,7 +274,7 @@ GPU_SHADER_INTERFACE_INFO(overlay_edit_uv_vert_iface, "")
GPU_SHADER_CREATE_INFO(overlay_edit_uv_verts)
.do_static_compilation(true)
.vertex_in(0, Type::VEC2, "au")
.vertex_in(1, Type::INT, "flag")
.vertex_in(1, Type::UINT, "flag")
.push_constant(Type::FLOAT, "pointSize")
.push_constant(Type::FLOAT, "outlineWidth")
.push_constant(Type::VEC4, "color")
@ -344,13 +353,13 @@ GPU_SHADER_CREATE_INFO(overlay_edit_uv_stretching_angle)
/** \name Edit Curve
* \{ */
GPU_SHADER_INTERFACE_INFO(overlay_edit_curve_handle_iface, "vert").flat(Type::INT, "flag");
GPU_SHADER_INTERFACE_INFO(overlay_edit_curve_handle_iface, "vert").flat(Type::UINT, "flag");
GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle)
.do_static_compilation(true)
.typedef_source("overlay_shader_shared.h")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::INT, "data")
.vertex_in(1, Type::UINT, "data")
.vertex_out(overlay_edit_curve_handle_iface)
.geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 10)
.geometry_out(overlay_edit_smooth_color_iface)
@ -368,7 +377,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_no_geom)
/* 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_in(1, Type::UINT, "data")
.vertex_out(overlay_edit_curve_handle_iface)
.push_constant(Type::BOOL, "showCurveHandles")
.push_constant(Type::INT, "curveHandleDisplay")
@ -389,7 +398,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_point)
.do_static_compilation(true)
.typedef_source("overlay_shader_shared.h")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::INT, "data")
.vertex_in(1, Type::UINT, "data")
.vertex_out(overlay_edit_flat_color_iface)
.push_constant(Type::BOOL, "showCurveHandles")
.push_constant(Type::INT, "curveHandleDisplay")
@ -428,7 +437,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_wire_clipped)
GPU_SHADER_CREATE_INFO(overlay_edit_lattice_point)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::INT, "data")
.vertex_in(1, Type::UINT, "data")
.vertex_out(overlay_edit_flat_color_iface)
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_edit_lattice_point_vert.glsl")
@ -539,7 +548,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_point_clipped)
GPU_SHADER_CREATE_INFO(overlay_edit_gpencil_guide_point)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::INT, "data")
.vertex_in(1, Type::UINT, "data")
.vertex_out(overlay_edit_flat_color_iface)
.push_constant(Type::VEC3, "pPosition")
.push_constant(Type::FLOAT, "pSize")

View File

@ -229,7 +229,7 @@ GPU_SHADER_CREATE_INFO(overlay_motion_path_point)
.do_static_compilation(true)
.typedef_source("overlay_shader_shared.h")
.vertex_in(0, Type::VEC3, "pos")
.vertex_in(1, Type::INT, "flag")
.vertex_in(1, Type::UINT, "flag")
.push_constant(Type::IVEC4, "mpathPointSettings")
.push_constant(Type::BOOL, "showKeyFrames")
.push_constant(Type::VEC3, "customColor")

View File

@ -23,7 +23,7 @@ GPU_SHADER_CREATE_INFO(overlay_grid_background)
.do_static_compilation(true)
.vertex_in(0, Type::VEC3, "pos")
.sampler(0, ImageType::DEPTH_2D, "depthBuffer")
.push_constant(Type::VEC4, "color")
.push_constant(Type::VEC4, "ucolor")
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_edit_uv_tiled_image_borders_vert.glsl")
.fragment_source("overlay_grid_background_frag.glsl")

View File

@ -39,17 +39,25 @@ GPU_SHADER_CREATE_INFO(overlay_outline_prepass_curves_clipped)
.do_static_compilation(true)
.additional_info("overlay_outline_prepass_curves", "drw_clipped");
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire_common)
.vertex_in(0, Type::VEC3, "pos")
.additional_info("draw_mesh", "overlay_outline_prepass")
.additional_info("draw_object_infos");
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire)
.do_static_compilation(true)
.additional_info("overlay_outline_prepass_wire_common")
.define("USE_GEOM")
.vertex_in(0, Type::VEC3, "pos")
.vertex_out(overlay_outline_prepass_wire_iface)
.geometry_layout(PrimitiveIn::LINES_ADJACENCY, PrimitiveOut::LINE_STRIP, 2)
.geometry_out(overlay_outline_prepass_iface)
.vertex_source("overlay_outline_prepass_vert.glsl")
.geometry_source("overlay_outline_prepass_geom.glsl")
.additional_info("draw_mesh", "overlay_outline_prepass")
.additional_info("draw_object_infos");
.geometry_source("overlay_outline_prepass_geom.glsl");
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire_no_geom)
// .do_static_compilation(true)
.additional_info("overlay_outline_prepass_wire_common")
.vertex_source("overlay_outline_prepass_vert_no_geom.glsl");
GPU_SHADER_CREATE_INFO(overlay_outline_prepass_wire_clipped)
.do_static_compilation(true)

View File

@ -22,24 +22,24 @@ void main()
vec4 v1 = gl_in[0].gl_Position;
vec4 v2 = gl_in[1].gl_Position;
int is_active_nurb = (vert[1].flag & ACTIVE_NURB);
int color_id = (vert[1].flag >> COLOR_SHIFT);
uint is_active_nurb = (vert[1].flag & ACTIVE_NURB);
uint color_id = (vert[1].flag >> COLOR_SHIFT);
/* Don't output any edges if we don't show handles */
if (!showCurveHandles && (color_id < 5)) {
return;
}
bool edge_selected = (((vert[1].flag | vert[0].flag) & VERT_SELECTED) != 0);
bool edge_selected = (((vert[1].flag | vert[0].flag) & VERT_SELECTED) != 0u);
bool handle_selected = (showCurveHandles &&
(((vert[1].flag | vert[0].flag) & VERT_SELECTED_BEZT_HANDLE) != 0));
(((vert[1].flag | vert[0].flag) & VERT_SELECTED_BEZT_HANDLE) != 0u));
bool is_gpencil = ((vert[1].flag & VERT_GPENCIL_BEZT_HANDLE) != 0);
bool is_gpencil = ((vert[1].flag & VERT_GPENCIL_BEZT_HANDLE) != 0u);
/* If handle type is only selected and the edge is not selected, don't show. */
if ((curveHandleDisplay != CURVE_HANDLE_ALL) && (!handle_selected)) {
/* Nurbs must show the handles always. */
bool is_u_segment = (((vert[1].flag ^ vert[0].flag) & EVEN_U_BIT) != 0);
bool is_u_segment = (((vert[1].flag ^ vert[0].flag) & EVEN_U_BIT) != 0u);
if ((!is_u_segment) && (color_id <= 4)) {
return;
}
@ -93,7 +93,7 @@ void main()
}
/* draw the transparent border (AA). */
if (is_active_nurb != 0) {
if (is_active_nurb != 0u) {
offset *= 0.75; /* Don't make the active "halo" appear very thick. */
output_line(offset * 2.0, vec4(colorActiveSpline.rgb, 0.0));
}
@ -108,7 +108,7 @@ void main()
output_line(-offset, outer_color);
/* draw the transparent border (AA). */
if (is_active_nurb != 0) {
if (is_active_nurb != 0u) {
output_line(offset * -2.0, vec4(colorActiveSpline.rgb, 0.0));
}

View File

@ -1,44 +1,44 @@
vec4 EDIT_MESH_edge_color_outer(int edge_flag, int face_flag, float crease, float bweight)
vec4 EDIT_MESH_edge_color_outer(uint edge_flag, uint face_flag, float crease, float bweight)
{
vec4 color = vec4(0.0);
color = ((edge_flag & EDGE_FREESTYLE) != 0) ? colorEdgeFreestyle : color;
color = ((edge_flag & EDGE_SHARP) != 0) ? colorEdgeSharp : color;
color = ((edge_flag & EDGE_FREESTYLE) != 0u) ? colorEdgeFreestyle : color;
color = ((edge_flag & EDGE_SHARP) != 0u) ? colorEdgeSharp : color;
color = (crease > 0.0) ? vec4(colorEdgeCrease.rgb, crease) : color;
color = (bweight > 0.0) ? vec4(colorEdgeBWeight.rgb, bweight) : color;
color = ((edge_flag & EDGE_SEAM) != 0) ? colorEdgeSeam : color;
color = ((edge_flag & EDGE_SEAM) != 0u) ? colorEdgeSeam : color;
return color;
}
vec4 EDIT_MESH_edge_color_inner(int edge_flag)
vec4 EDIT_MESH_edge_color_inner(uint edge_flag)
{
vec4 color = colorWireEdit;
vec4 color_select = (selectEdges) ? colorEdgeSelect : mix(colorEdgeSelect, colorWireEdit, .45);
color = ((edge_flag & EDGE_SELECTED) != 0) ? color_select : color;
color = ((edge_flag & EDGE_ACTIVE) != 0) ? colorEditMeshActive : color;
color = ((edge_flag & EDGE_SELECTED) != 0u) ? color_select : color;
color = ((edge_flag & EDGE_ACTIVE) != 0u) ? colorEditMeshActive : color;
color.a = (selectEdges || (edge_flag & (EDGE_SELECTED | EDGE_ACTIVE)) != 0) ? 1.0 : 0.7;
return color;
}
vec4 EDIT_MESH_edge_vertex_color(int vertex_flag)
vec4 EDIT_MESH_edge_vertex_color(uint vertex_flag)
{
vec4 color = colorWireEdit;
vec4 color_select = (selectEdges) ? colorEdgeSelect : mix(colorEdgeSelect, colorWireEdit, .45);
bool edge_selected = (vertex_flag & (VERT_ACTIVE | VERT_SELECTED)) != 0;
bool edge_selected = (vertex_flag & (VERT_ACTIVE | VERT_SELECTED)) != 0u;
color = (edge_selected) ? color_select : color;
color.a = (selectEdges || edge_selected) ? 1.0 : 0.7;
return color;
}
vec4 EDIT_MESH_vertex_color(int vertex_flag, float vertex_crease)
vec4 EDIT_MESH_vertex_color(uint vertex_flag, float vertex_crease)
{
if ((vertex_flag & VERT_ACTIVE) != 0) {
return vec4(colorEditMeshActive.xyz, 1.0);
}
else if ((vertex_flag & VERT_SELECTED) != 0) {
else if ((vertex_flag & VERT_SELECTED) != 0u) {
return colorVertexSelect;
}
else {
@ -50,13 +50,13 @@ vec4 EDIT_MESH_vertex_color(int vertex_flag, float vertex_crease)
}
}
vec4 EDIT_MESH_face_color(int face_flag)
vec4 EDIT_MESH_face_color(uint face_flag)
{
vec4 color = colorFace;
vec4 color_active = mix(colorFaceSelect, colorEditMeshActive, 0.5);
color = ((face_flag & FACE_FREESTYLE) != 0) ? colorFaceFreestyle : color;
color = ((face_flag & FACE_SELECTED) != 0) ? colorFaceSelect : color;
color = ((face_flag & FACE_ACTIVE) != 0) ? color_active : color;
color = ((face_flag & FACE_FREESTYLE) != 0u) ? colorFaceFreestyle : color;
color = ((face_flag & FACE_SELECTED) != 0u) ? colorFaceSelect : color;
color = ((face_flag & FACE_ACTIVE) != 0u) ? color_active : color;
color.a *= ((face_flag & (FACE_FREESTYLE | FACE_SELECTED | FACE_ACTIVE)) == 0 || selectFaces) ?
1.0 :
0.5;

View File

@ -68,8 +68,8 @@ void main()
do_vertex(geometry_in[0].finalColor_, pos0, -half_size, -edge_ofs.xy);
view_clipping_distances_set(gl_in[1]);
vec4 final_color = (geometry_in[0].selectOverride_ == 0) ? geometry_in[1].finalColor_ :
geometry_in[0].finalColor_;
vec4 final_color = (geometry_in[0].selectOverride_ == 0u) ? geometry_in[1].finalColor_ :
geometry_in[0].finalColor_;
do_vertex(final_color, pos1, half_size, edge_ofs.xy);
do_vertex(final_color, pos1, -half_size, -edge_ofs.xy);

View File

@ -31,7 +31,7 @@ void main()
vec3 world_pos = point_object_to_world(pos);
gl_Position = point_world_to_ndc(world_pos);
ivec4 m_data = data & dataMask;
uvec4 m_data = data & uvec4(dataMask);
#if defined(VERT)
vertexCrease = float(m_data.z >> 4) / 15.0;
@ -50,13 +50,13 @@ void main()
#elif defined(EDGE)
# ifdef FLAT
finalColor = EDIT_MESH_edge_color_inner(m_data.y);
selectOverride = 1;
selectOverride = 1u;
# else
finalColor = EDIT_MESH_edge_vertex_color(m_data.y);
selectOverride = (m_data.y & EDGE_SELECTED);
# endif
float edge_crease = float(m_data.z & 0xF) / 15.0;
float edge_crease = float(m_data.z & 0xFu) / 15.0;
float bweight = float(m_data.w) / 255.0;
finalColorOuter = EDIT_MESH_edge_color_outer(m_data.y, m_data.x, edge_crease, bweight);

View File

@ -84,8 +84,8 @@ void main()
vec3 world_pos1 = point_object_to_world(in_pos1);
vec4 out_pos0 = point_world_to_ndc(world_pos0);
vec4 out_pos1 = point_world_to_ndc(world_pos1);
ivec4 m_data0 = ivec4(in_data0) & dataMask;
ivec4 m_data1 = ivec4(in_data1) & dataMask;
uvec4 m_data0 = uvec4(in_data0) & uvec4(dataMask);
uvec4 m_data1 = uvec4(in_data1) & uvec4(dataMask);
#if defined(EDGE)
# ifdef FLAT

View File

@ -11,9 +11,9 @@ void main()
half_pixel_offset;
#ifdef USE_EDGE_SELECT
bool is_select = (flag & EDGE_UV_SELECT) != 0;
bool is_select = (flag & EDGE_UV_SELECT) != 0u;
#else
bool is_select = (flag & VERT_UV_SELECT) != 0;
bool is_select = (flag & VERT_UV_SELECT) != 0u;
#endif
geom_in.selectionFac = is_select ? 1.0 : 0.0;
/* Move selected edges to the top

View File

@ -0,0 +1,126 @@
#pragma USE_SSBO_VERTEX_FETCH(TriangleList, 6)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#pragma BLENDER_REQUIRE(overlay_common_lib.glsl)
#define DISCARD_VERTEX \
gl_Position = vec4(0.0); \
return;
void do_vertex(
vec4 pos, float selection_fac, vec2 stipple_start, vec2 stipple_pos, float coord, vec2 offset)
{
geom_out.selectionFac = selection_fac;
geom_out.edgeCoord = coord;
geom_out.stippleStart = stipple_start;
geom_out.stipplePos = stipple_pos;
gl_Position = pos;
/* Multiply offset by 2 because gl_Position range is [-1..1]. */
gl_Position.xy += offset * 2.0;
}
void main()
{
/* Determine output geometry parameters. */
int quad_id = gl_VertexID / 6;
int quad_vertex_id = gl_VertexID % 6;
int base_vertex_id = 0;
if (vertex_fetch_get_input_prim_type() == GPU_PRIM_LINES) {
base_vertex_id = quad_id * 2;
}
else if (vertex_fetch_get_input_prim_type() == GPU_PRIM_LINE_STRIP) {
base_vertex_id = quad_id;
}
else {
DISCARD_VERTEX
}
/* Read vertex attributes for line prims. */
vec2 root_au0 = vertex_fetch_attribute(base_vertex_id, au, vec2);
vec2 root_au1 = vertex_fetch_attribute(base_vertex_id + 1, au, vec2);
int root_flag0 = vertex_fetch_attribute(base_vertex_id, flag, int);
int root_flag1 = vertex_fetch_attribute(base_vertex_id + 1, flag, int);
/* Vertex shader per input vertex. */
vec3 world_pos0 = point_object_to_world(vec3(root_au0, 0.0));
vec3 world_pos1 = point_object_to_world(vec3(root_au1, 0.0));
vec4 gl_pos0 = point_world_to_ndc(world_pos0);
vec4 gl_pos1 = point_world_to_ndc(world_pos1);
/* Snap vertices to the pixel grid to reduce artifacts. */
vec2 half_viewport_res = sizeViewport * 0.5;
vec2 half_pixel_offset = sizeViewportInv * 0.5;
gl_pos0.xy = floor(gl_pos0.xy * half_viewport_res) / half_viewport_res + half_pixel_offset;
gl_pos1.xy = floor(gl_pos1.xy * half_viewport_res) / half_viewport_res + half_pixel_offset;
#ifdef USE_EDGE_SELECT
bool is_select0 = (root_flag0 & EDGE_UV_SELECT) != 0;
bool is_select1 = (root_flag1 & EDGE_UV_SELECT) != 0;
#else
bool is_select0 = (root_flag0 & VERT_UV_SELECT) != 0;
bool is_select1 = (root_flag1 & VERT_UV_SELECT) != 0;
#endif
float selectionFac0 = is_select0 ? 1.0 : 0.0; // out float selectionFac;
float selectionFac1 = is_select1 ? 1.0 : 0.0; // out float selectionFac;
#ifdef USE_EDGE_SELECT
/* No blending with edge selection. */
selectionFac1 = selectionFac0;
#endif
/* Move selected edges to the top
* Vertices are between 0.0 and 0.2, Edges between 0.2 and 0.4
* actual pixels are at 0.75, 1.0 is used for the background. */
float depth0 = is_select0 ? 0.25 : 0.35;
float depth1 = is_select1 ? 0.25 : 0.35;
gl_pos0.z = depth0;
gl_pos1.z = depth1;
/* Avoid precision loss. */
vec2 stipplePos0 = 500.0 + 500.0 * (gl_pos0.xy / gl_pos0.w);
vec2 stipplePos1 = 500.0 + 500.0 * (gl_pos1.xy / gl_pos1.w);
vec2 stippleStart0 = stipplePos0;
vec2 stippleStart1 = stipplePos1;
/* Geometry shader equivalent calculations. */
vec2 ss_pos[2];
ss_pos[0] = gl_pos0.xy / gl_pos0.w;
ss_pos[1] = gl_pos1.xy / gl_pos1.w;
float half_size = sizeEdge;
/* Enlarge edge for outline drawing. */
/* Factor of 3.0 out of nowhere! Seems to fix issues with float imprecision. */
half_size += (lineStyle == OVERLAY_UV_LINE_STYLE_OUTLINE) ?
max(sizeEdge * (doSmoothWire ? 1.0 : 3.0), 1.0) :
0.0;
/* Add 1 px for AA */
if (doSmoothWire) {
half_size += 0.5;
}
vec2 line = ss_pos[0] - ss_pos[1];
vec2 line_dir = normalize(line);
vec2 line_perp = vec2(-line_dir.y, line_dir.x);
vec2 edge_ofs = line_perp * sizeViewportInv * ceil(half_size);
switch (quad_vertex_id) {
case 1: /* vertex A */
case 3:
do_vertex(gl_pos1, selectionFac1, stippleStart1, stipplePos1, half_size, edge_ofs.xy);
break;
case 0: /* B */
do_vertex(gl_pos0, selectionFac0, stippleStart0, stipplePos0, half_size, edge_ofs.xy);
break;
case 2: /* C */
case 4:
do_vertex(gl_pos0, selectionFac0, stippleStart0, stipplePos0, -half_size, -edge_ofs.xy);
break;
case 5: /* D */
do_vertex(gl_pos1, selectionFac1, stippleStart1, stipplePos1, -half_size, -edge_ofs.xy);
break;
}
}

View File

@ -1,7 +1,7 @@
void main()
{
fragColor = color;
fragColor = ucolor;
float scene_depth = texelFetch(depthBuffer, ivec2(gl_FragCoord.xy), 0).r;
fragColor.a = (scene_depth == 1.0) ? 1.0 : 0.0;
}

View File

@ -0,0 +1,86 @@
#pragma USE_SSBO_VERTEX_FETCH(LineList, 2)
#pragma BLENDER_REQUIRE(common_view_clipping_lib.glsl)
#pragma BLENDER_REQUIRE(common_view_lib.glsl)
#define DISCARD_VERTEX gl_Position=vec4(0.0); return;
uint outline_colorid_get(void)
{
int flag = int(abs(ObjectInfo.w));
bool is_active = (flag & DRW_BASE_ACTIVE) != 0;
if (isTransform) {
return 0u; /* colorTransform */
}
else if (is_active) {
return 3u; /* colorActive */
}
else {
return 1u; /* colorSelect */
}
return 0u;
}
/* Replace top 2 bits (of the 16bit output) by outlineId.
* This leaves 16K different IDs to create outlines between objects.
* SHIFT = (32 - (16 - 2)) */
#define SHIFT 18u
void main()
{
/* Outputs a singular vertex as part of a LineList primitive, however, requires access to
* neighboring 4 vertices. */
/* Fetch verts from input type lines adjacency. */
int line_prim_id = (gl_VertexID / 2);
int line_vertex_id = gl_VertexID % 2;
int base_vertex_id = line_prim_id * 2;
vec4 gl_pos[4];
vec3 world_pos[4];
vec3 view_pos[4];
for(int i=0; i < 4; i++) {
vec3 in_pos = vertex_fetch_attribute_raw(vertex_id_from_index_id(4 * line_prim_id + i), pos, vec3);
world_pos[i] = point_object_to_world(in_pos);
view_pos[i] = point_world_to_view(world_pos[i]);
gl_pos[i] = point_world_to_ndc(world_pos[i]);
gl_pos[i].z -= 1e-3;
}
/* Perform geometry shader equivalent logic. */
bool is_persp = (drw_view.winmat[3][3] == 0.0);
vec3 view_vec = (is_persp) ? normalize(view_pos[1]) : vec3(0.0, 0.0, -1.0);
vec3 v10 = view_pos[0] - view_pos[1];
vec3 v12 = view_pos[2] - view_pos[1];
vec3 v13 = view_pos[3] - view_pos[1];
vec3 n0 = cross(v12, v10);
vec3 n3 = cross(v13, v12);
float fac0 = dot(view_vec, n0);
float fac3 = dot(view_vec, n3);
/* If both adjacent verts are facing the camera the same way,
* then it isn't an outline edge. */
if (sign(fac0) == sign(fac3)) {
DISCARD_VERTEX
}
/* Output final position. */
int output_vert_select = (line_vertex_id + 1);
gl_Position = gl_pos[output_vert_select];
/* ID 0 is nothing (background). */
interp.ob_id = uint(resource_handle + 1);
/* Should be 2 bits only [0..3]. */
uint outline_id = outline_colorid_get();
/* Combine for 16bit uint target. */
interp.ob_id = (outline_id << 14u) | ((interp.ob_id << SHIFT) >> SHIFT);
/* Clip final output position. */
view_clipping_distances(world_pos[output_vert_select]);
}

View File

@ -244,24 +244,24 @@ BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
#endif
/* See: 'draw_cache_impl.h' for matching includes. */
#define VERT_GPENCIL_BEZT_HANDLE (1 << 30)
#define VERT_GPENCIL_BEZT_HANDLE (1u << 30)
/* data[0] (1st byte flags) */
#define FACE_ACTIVE (1 << 0)
#define FACE_SELECTED (1 << 1)
#define FACE_FREESTYLE (1 << 2)
#define VERT_UV_SELECT (1 << 3)
#define VERT_UV_PINNED (1 << 4)
#define EDGE_UV_SELECT (1 << 5)
#define FACE_UV_ACTIVE (1 << 6)
#define FACE_UV_SELECT (1 << 7)
#define FACE_ACTIVE (1u << 0)
#define FACE_SELECTED (1u << 1)
#define FACE_FREESTYLE (1u << 2)
#define VERT_UV_SELECT (1u << 3)
#define VERT_UV_PINNED (1u << 4)
#define EDGE_UV_SELECT (1u << 5)
#define FACE_UV_ACTIVE (1u << 6)
#define FACE_UV_SELECT (1u << 7)
/* data[1] (2st byte flags) */
#define VERT_ACTIVE (1 << 0)
#define VERT_SELECTED (1 << 1)
#define VERT_SELECTED_BEZT_HANDLE (1 << 2)
#define EDGE_ACTIVE (1 << 3)
#define EDGE_SELECTED (1 << 4)
#define EDGE_SEAM (1 << 5)
#define EDGE_SHARP (1 << 6)
#define EDGE_FREESTYLE (1 << 7)
#define VERT_ACTIVE (1u << 0)
#define VERT_SELECTED (1u << 1)
#define VERT_SELECTED_BEZT_HANDLE (1u << 2)
#define EDGE_ACTIVE (1u << 3)
#define EDGE_SELECTED (1u << 4)
#define EDGE_SEAM (1u << 5)
#define EDGE_SHARP (1u << 6)
#define EDGE_FREESTYLE (1u << 7)
#define COMMON_GLOBALS_LIB

View File

@ -352,7 +352,7 @@ DRWDebugVert DebugDraw::vert_pack(float3 pos, uint color)
vert.pos0 = *reinterpret_cast<uint32_t *>(&pos.x);
vert.pos1 = *reinterpret_cast<uint32_t *>(&pos.y);
vert.pos2 = *reinterpret_cast<uint32_t *>(&pos.z);
vert.color = color;
vert.vert_color = color;
return vert;
}

View File

@ -70,7 +70,7 @@ inline void ObjectInfos::sync(const blender::draw::ObjectRef ref, bool is_active
object_attrs_len = 0;
object_attrs_offset = 0;
color = ref.object->color;
ob_color = ref.object->color;
index = ref.object->index;
SET_FLAG_FROM_TEST(flag, is_active_object, eObjectInfoFlag::OBJECT_ACTIVE);
SET_FLAG_FROM_TEST(
@ -140,7 +140,7 @@ inline std::ostream &operator<<(std::ostream &stream, const ObjectInfos &infos)
}
stream << "orco_add=" << infos.orco_add << ", ";
stream << "orco_mul=" << infos.orco_mul << ", ";
stream << "color=" << infos.color << ", ";
stream << "ob_color=" << infos.ob_color << ", ";
stream << "index=" << infos.index << ", ";
stream << "random=" << infos.random << ", ";
stream << "flag=" << infos.flag << ")" << std::endl;

View File

@ -151,7 +151,7 @@ struct ObjectInfos {
#if defined(GPU_SHADER) && !defined(DRAW_FINALIZE_SHADER)
/* TODO Rename to struct member for glsl too. */
float4 orco_mul_bias[2];
float4 color;
float4 ob_color;
float4 infos;
#else
/** Uploaded as center + size. Converted to mul+bias to local coord. */
@ -160,7 +160,7 @@ struct ObjectInfos {
float3 orco_mul;
uint object_attrs_len;
float4 color;
float4 ob_color;
uint index;
uint _pad2;
float random;
@ -327,7 +327,8 @@ struct DRWDebugVert {
uint pos0;
uint pos1;
uint pos2;
uint color;
/* Named vert_color to avoid global namespace collision with uniform color.*/
uint vert_color;
};
BLI_STATIC_ASSERT_ALIGN(DRWDebugVert, 16)

View File

@ -21,23 +21,23 @@ uint drw_debug_start_draw(uint v_needed)
return vertid;
}
uint drw_debug_color_pack(vec4 color)
uint drw_debug_color_pack(vec4 v_color)
{
color = clamp(color, 0.0, 1.0);
v_color = clamp(v_color, 0.0, 1.0);
uint result = 0;
result |= uint(color.x * 255.0) << 0u;
result |= uint(color.y * 255.0) << 8u;
result |= uint(color.z * 255.0) << 16u;
result |= uint(color.w * 255.0) << 24u;
result |= uint(v_color.x * 255.0) << 0u;
result |= uint(v_color.y * 255.0) << 8u;
result |= uint(v_color.z * 255.0) << 16u;
result |= uint(v_color.w * 255.0) << 24u;
return result;
}
void drw_debug_line(inout uint vertid, vec3 v1, vec3 v2, uint color)
void drw_debug_line(inout uint vertid, vec3 v1, vec3 v2, uint v_color)
{
drw_debug_verts_buf[vertid++] = DRWDebugVert(
floatBitsToUint(v1.x), floatBitsToUint(v1.y), floatBitsToUint(v1.z), color);
floatBitsToUint(v1.x), floatBitsToUint(v1.y), floatBitsToUint(v1.z), v_color);
drw_debug_verts_buf[vertid++] = DRWDebugVert(
floatBitsToUint(v2.x), floatBitsToUint(v2.y), floatBitsToUint(v2.z), color);
floatBitsToUint(v2.x), floatBitsToUint(v2.y), floatBitsToUint(v2.z), v_color);
}
/** \} */
@ -49,7 +49,7 @@ void drw_debug_line(inout uint vertid, vec3 v1, vec3 v2, uint color)
/**
* Draw a line.
*/
void drw_debug_line(vec3 v1, vec3 v2, vec4 color)
void drw_debug_line(vec3 v1, vec3 v2, vec4 v_color)
{
if (!drw_debug_draw_enable) {
return;
@ -57,7 +57,7 @@ void drw_debug_line(vec3 v1, vec3 v2, vec4 color)
const uint v_needed = 2;
uint vertid = drw_debug_start_draw(v_needed);
if (vertid + v_needed < DRW_DEBUG_DRAW_VERT_MAX) {
drw_debug_line(vertid, v1, v2, drw_debug_color_pack(color));
drw_debug_line(vertid, v1, v2, drw_debug_color_pack(v_color));
}
}
void drw_debug_line(vec3 v1, vec3 v2)
@ -68,7 +68,7 @@ void drw_debug_line(vec3 v1, vec3 v2)
/**
* Draw a quad contour.
*/
void drw_debug_quad(vec3 v1, vec3 v2, vec3 v3, vec3 v4, vec4 color)
void drw_debug_quad(vec3 v1, vec3 v2, vec3 v3, vec3 v4, vec4 v_color)
{
if (!drw_debug_draw_enable) {
return;
@ -76,7 +76,7 @@ void drw_debug_quad(vec3 v1, vec3 v2, vec3 v3, vec3 v4, vec4 color)
const uint v_needed = 8;
uint vertid = drw_debug_start_draw(v_needed);
if (vertid + v_needed < DRW_DEBUG_DRAW_VERT_MAX) {
uint pcolor = drw_debug_color_pack(color);
uint pcolor = drw_debug_color_pack(v_color);
drw_debug_line(vertid, v1, v2, pcolor);
drw_debug_line(vertid, v2, v3, pcolor);
drw_debug_line(vertid, v3, v4, pcolor);
@ -91,7 +91,7 @@ void drw_debug_quad(vec3 v1, vec3 v2, vec3 v3, vec3 v4)
/**
* Draw a point as octahedron wireframe.
*/
void drw_debug_point(vec3 p, float radius, vec4 color)
void drw_debug_point(vec3 p, float radius, vec4 v_color)
{
if (!drw_debug_draw_enable) {
return;
@ -107,7 +107,7 @@ void drw_debug_point(vec3 p, float radius, vec4 color)
const uint v_needed = 12 * 2;
uint vertid = drw_debug_start_draw(v_needed);
if (vertid + v_needed < DRW_DEBUG_DRAW_VERT_MAX) {
uint pcolor = drw_debug_color_pack(color);
uint pcolor = drw_debug_color_pack(v_color);
drw_debug_line(vertid, v1, v2, pcolor);
drw_debug_line(vertid, v2, v3, pcolor);
drw_debug_line(vertid, v3, v4, pcolor);
@ -134,7 +134,7 @@ void drw_debug_point(vec3 p)
/**
* Draw a sphere wireframe as 3 axes circle.
*/
void drw_debug_sphere(vec3 p, float radius, vec4 color)
void drw_debug_sphere(vec3 p, float radius, vec4 v_color)
{
if (!drw_debug_draw_enable) {
return;
@ -143,7 +143,7 @@ void drw_debug_sphere(vec3 p, float radius, vec4 color)
const uint v_needed = circle_resolution * 2 * 3;
uint vertid = drw_debug_start_draw(v_needed);
if (vertid + v_needed < DRW_DEBUG_DRAW_VERT_MAX) {
uint pcolor = drw_debug_color_pack(color);
uint pcolor = drw_debug_color_pack(v_color);
for (int axis = 0; axis < 3; axis++) {
for (int edge = 0; edge < circle_resolution; edge++) {
float angle1 = (2.0 * 3.141592) * float(edge + 0) / float(circle_resolution);
@ -167,7 +167,7 @@ void drw_debug_sphere(vec3 p, float radius)
/**
* Draw a matrix transformation as 3 colored axes.
*/
void drw_debug_matrix(mat4 mat, vec4 color)
void drw_debug_matrix(mat4 mat, vec4 v_color)
{
vec4 p[4] = vec4[4](vec4(0, 0, 0, 1), vec4(1, 0, 0, 1), vec4(0, 1, 0, 1), vec4(0, 0, 1, 1));
for (int i = 0; i < 4; i++) {
@ -186,7 +186,7 @@ void drw_debug_matrix(mat4 mat)
/**
* Draw a matrix as a 2 units length bounding box, centered on origin.
*/
void drw_debug_matrix_as_bbox(mat4 mat, vec4 color)
void drw_debug_matrix_as_bbox(mat4 mat, vec4 v_color)
{
vec4 p[8] = vec4[8](vec4(-1, -1, -1, 1),
vec4(1, -1, -1, 1),
@ -200,12 +200,12 @@ void drw_debug_matrix_as_bbox(mat4 mat, vec4 color)
p[i] = mat * p[i];
p[i].xyz /= p[i].w;
}
drw_debug_quad(p[0].xyz, p[1].xyz, p[2].xyz, p[3].xyz, color);
drw_debug_line(p[0].xyz, p[4].xyz, color);
drw_debug_line(p[1].xyz, p[5].xyz, color);
drw_debug_line(p[2].xyz, p[6].xyz, color);
drw_debug_line(p[3].xyz, p[7].xyz, color);
drw_debug_quad(p[4].xyz, p[5].xyz, p[6].xyz, p[7].xyz, color);
drw_debug_quad(p[0].xyz, p[1].xyz, p[2].xyz, p[3].xyz, v_color);
drw_debug_line(p[0].xyz, p[4].xyz, v_color);
drw_debug_line(p[1].xyz, p[5].xyz, v_color);
drw_debug_line(p[2].xyz, p[6].xyz, v_color);
drw_debug_line(p[3].xyz, p[7].xyz, v_color);
drw_debug_quad(p[4].xyz, p[5].xyz, p[6].xyz, p[7].xyz, v_color);
}
void drw_debug_matrix_as_bbox(mat4 mat)
{

View File

@ -8,7 +8,7 @@ void main()
/* Skip the first vertex containing header data. */
DRWDebugVert vert = drw_debug_verts_buf[gl_VertexID + 2];
vec3 pos = uintBitsToFloat(uvec3(vert.pos0, vert.pos1, vert.pos2));
vec4 col = vec4((uvec4(vert.color) >> uvec4(0, 8, 16, 24)) & 0xFFu) / 255.0;
vec4 col = vec4((uvec4(vert.vert_color) >> uvec4(0, 8, 16, 24)) & 0xFFu) / 255.0;
interp.color = col;
gl_Position = persmat * vec4(pos, 1.0);

View File

@ -8,7 +8,7 @@ GPU_SHADER_CREATE_INFO(draw_object_infos)
.define("OBINFO_LIB")
.define("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)")
.define("ObjectInfo", "(drw_infos[resource_id].infos)")
.define("ObjectColor", "(drw_infos[resource_id].color)")
.define("ObjectColor", "(drw_infos[resource_id].ob_color)")
.uniform_buf(1, "ObjectInfos", "drw_infos[DRW_RESOURCE_CHUNK_LEN]", Frequency::BATCH);
GPU_SHADER_CREATE_INFO(draw_volume_infos)
@ -32,7 +32,7 @@ GPU_SHADER_CREATE_INFO(draw_object_infos_new)
.define("OBINFO_LIB")
.define("OrcoTexCoFactors", "(drw_infos[resource_id].orco_mul_bias)")
.define("ObjectInfo", "(drw_infos[resource_id].infos)")
.define("ObjectColor", "(drw_infos[resource_id].color)")
.define("ObjectColor", "(drw_infos[resource_id].ob_color)")
.storage_buf(DRW_OBJ_INFOS_SLOT, Qualifier::READ, "ObjectInfos", "drw_infos[]");
/** \note Requires draw_object_infos_new. */

View File

@ -343,6 +343,12 @@ void gpu_shader_create_info_init()
overlay_motion_path_line = overlay_motion_path_line_no_geom;
overlay_motion_path_line_clipped = overlay_motion_path_line_clipped_no_geom;
/* Overlay prepass wire. */
overlay_outline_prepass_wire = overlay_outline_prepass_wire_no_geom;
/* Edit UV Edges. */
overlay_edit_uv_edges = overlay_edit_uv_edges_no_geom;
/* Downsample Cube/Proe rendering. */
eevee_legacy_effect_downsample_cube = eevee_legacy_effect_downsample_cube_no_geom;
eevee_legacy_probe_filter_glossy = eevee_legacy_probe_filter_glossy_no_geom;

View File

@ -16,7 +16,7 @@ const float diagonal_scale = sqrt(0.5);
const float minmax_bias = 0.7;
const float minmax_scale = sqrt(1.0 / (1.0 + 1.0 / minmax_bias));
bool test(int bit)
bool test(uint bit)
{
return (finalFlags & bit) != 0;
}

View File

@ -1,13 +1,13 @@
/* Values in GPU_shader.h. */
#define GPU_KEYFRAME_SHAPE_DIAMOND (1 << 0)
#define GPU_KEYFRAME_SHAPE_CIRCLE (1 << 1)
#define GPU_KEYFRAME_SHAPE_CLIPPED_VERTICAL (1 << 2)
#define GPU_KEYFRAME_SHAPE_CLIPPED_HORIZONTAL (1 << 3)
#define GPU_KEYFRAME_SHAPE_INNER_DOT (1 << 4)
#define GPU_KEYFRAME_SHAPE_ARROW_END_MAX (1 << 8)
#define GPU_KEYFRAME_SHAPE_ARROW_END_MIN (1 << 9)
#define GPU_KEYFRAME_SHAPE_ARROW_END_MIXED (1 << 10)
#define GPU_KEYFRAME_SHAPE_DIAMOND (1u << 0)
#define GPU_KEYFRAME_SHAPE_CIRCLE (1u << 1)
#define GPU_KEYFRAME_SHAPE_CLIPPED_VERTICAL (1u << 2)
#define GPU_KEYFRAME_SHAPE_CLIPPED_HORIZONTAL (1u << 3)
#define GPU_KEYFRAME_SHAPE_INNER_DOT (1u << 4)
#define GPU_KEYFRAME_SHAPE_ARROW_END_MAX (1u << 8)
#define GPU_KEYFRAME_SHAPE_ARROW_END_MIN (1u << 9)
#define GPU_KEYFRAME_SHAPE_ARROW_END_MIXED (1u << 10)
#define GPU_KEYFRAME_SHAPE_SQUARE \
(GPU_KEYFRAME_SHAPE_CLIPPED_VERTICAL | GPU_KEYFRAME_SHAPE_CLIPPED_HORIZONTAL)
@ -16,9 +16,9 @@ const float circle_scale = sqrt(2.0 / 3.1416);
const float square_scale = sqrt(0.5);
const float diagonal_scale = sqrt(0.5);
bool test(int bit)
bool test(uint bit)
{
return (flags & bit) != 0;
return (flags & bit) != 0u;
}
vec2 line_thresholds(float width)

View File

@ -38,10 +38,10 @@ GPU_SHADER_CREATE_INFO(gpu_shader_2D_nodelink_inst)
.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(7, Type::UVEC4, "colid_doarrow")
.vertex_in(8, Type::VEC4, "start_color")
.vertex_in(9, Type::VEC4, "end_color")
.vertex_in(10, Type::IVEC2, "domuted")
.vertex_in(10, Type::UVEC2, "domuted")
.vertex_in(11, Type::FLOAT, "dim_factor")
.vertex_in(12, Type::FLOAT, "thickness")
.vertex_in(13, Type::FLOAT, "dash_factor")

View File

@ -12,14 +12,14 @@ GPU_SHADER_INTERFACE_INFO(keyframe_shape_iface, "")
.flat(Type::VEC4, "finalOutlineColor")
.flat(Type::VEC4, "radii")
.flat(Type::VEC4, "thresholds")
.flat(Type::INT, "finalFlags");
.flat(Type::UINT, "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_in(4, Type::UINT, "flags")
.vertex_out(keyframe_shape_iface)
.fragment_out(0, Type::VEC4, "fragColor")
.push_constant(Type::MAT4, "ModelViewProjectionMatrix")

View File

@ -40,6 +40,8 @@
#define vec3_1010102_Inorm int
/* Strip GLSL Decorators. */
/* NOTE: For debugging, keep decorators in to ensure we have not missed any
* shader resources which are not guarded behind Macro's. */
#if 0
# define in
# define flat