GPU: Use Same Type in Comparisons. #106789

Merged
Jeroen Bakker merged 4 commits from Jeroen-Bakker/blender:gpu-compare-similar-types into main 2023-04-11 13:46:22 +02:00
4 changed files with 7 additions and 7 deletions
Showing only changes of commit 8ee4ba7b0f - Show all commits

View File

@ -396,7 +396,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle)
.geometry_layout(PrimitiveIn::LINES, PrimitiveOut::TRIANGLE_STRIP, 10)
.geometry_out(overlay_edit_smooth_color_iface)
.push_constant(Type::BOOL, "showCurveHandles")
.push_constant(Type::UINT, "curveHandleDisplay")
.push_constant(Type::INT, "curveHandleDisplay")
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_edit_curve_handle_vert.glsl")
.geometry_source("overlay_edit_curve_handle_geom.glsl")
@ -414,7 +414,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_handle_no_geom)
.vertex_in(1, Type::UCHAR, "data")
.vertex_out(overlay_edit_smooth_color_iface)
.push_constant(Type::BOOL, "showCurveHandles")
.push_constant(Type::UINT, "curveHandleDisplay")
.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")
@ -439,7 +439,7 @@ GPU_SHADER_CREATE_INFO(overlay_edit_curve_point)
.vertex_in(1, Type::UINT, "data")
.vertex_out(overlay_edit_flat_color_iface)
.push_constant(Type::BOOL, "showCurveHandles")
.push_constant(Type::UINT, "curveHandleDisplay")
.push_constant(Type::INT, "curveHandleDisplay")
Jeroen-Bakker marked this conversation as resolved Outdated

This will create errors on some drivers. AMDPRO, for instance, emit an error because we set its value using signed int functions. So I prefer to fix the usage in the shader by casting them to uint when needed.

This will create errors on some drivers. AMDPRO, for instance, emit an error because we set its value using signed int functions. So I prefer to fix the usage in the shader by casting them to `uint` when needed.
.fragment_out(0, Type::VEC4, "fragColor")
.vertex_source("overlay_edit_curve_point_vert.glsl")
.fragment_source("overlay_point_varying_color_frag.glsl")

View File

@ -37,7 +37,7 @@ void main()
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)) {
if (uint(curveHandleDisplay != CURVE_HANDLE_ALL) && (!handle_selected)) {
Jeroen-Bakker marked this conversation as resolved Outdated

I believe it is (uint(curveHandleDisplay) != CURVE_HANDLE_ALL) you want here.

I believe it is `(uint(curveHandleDisplay) != CURVE_HANDLE_ALL)` you want here.
/* Nurbs must show the handles always. */
bool is_u_segment = (((vert[1].flag ^ vert[0].flag) & EVEN_U_BIT) != 0u);
if ((!is_u_segment) && (color_id <= 4u)) {

View File

@ -58,7 +58,7 @@ void main()
bool is_gpencil = ((vert_flag[1] & 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)) {
if (uint(curveHandleDisplay != CURVE_HANDLE_ALL) && (!handle_selected)) {
Jeroen-Bakker marked this conversation as resolved Outdated

Same here.

Same here.
/* Nurbs must show the handles always. */
bool is_u_segment = (((vert_flag[1] ^ vert_flag[0]) & EVEN_U_BIT) != 0u);
if ((!is_u_segment) && (color_id <= 4u)) {

View File

@ -7,7 +7,7 @@ void main()
GPU_INTEL_VERTEX_SHADER_WORKAROUND
/* Reuse the FREESTYLE flag to determine is GPencil. */
bool is_gpencil = ((data & EDGE_FREESTYLE) != 0);
bool is_gpencil = ((data & EDGE_FREESTYLE) != 0u);
Jeroen-Bakker marked this conversation as resolved Outdated

0 -> 0u

`0` -> `0u`
if ((data & VERT_SELECTED) != 0u) {
if ((data & VERT_ACTIVE) != 0u) {
finalColor = colorEditMeshActive;
@ -26,7 +26,7 @@ void main()
view_clipping_distances(world_pos);
bool show_handle = showCurveHandles;
if ((curveHandleDisplay == CURVE_HANDLE_SELECTED) && ((data & VERT_SELECTED_BEZT_HANDLE) == 0u)) {
if (uint(curveHandleDisplay == CURVE_HANDLE_SELECTED) && ((data & VERT_SELECTED_BEZT_HANDLE) == 0u)) {
Jeroen-Bakker marked this conversation as resolved Outdated

Same here

Same here
show_handle = false;
}
Jeroen-Bakker marked this conversation as resolved
Review

0 -> 0u on line 33

`0` -> `0u` on line 33