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 29 additions and 29 deletions

View File

@ -26,7 +26,7 @@ void main()
uint color_id = (vert[1].flag >> COLOR_SHIFT);
/* Don't output any edges if we don't show handles */
if (!showCurveHandles && (color_id < 5)) {
if (!showCurveHandles && (color_id < 5u)) {
return;
}
@ -37,10 +37,10 @@ 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 <= 4)) {
if ((!is_u_segment) && (color_id <= 4u)) {
return;
}
if (is_gpencil) {
@ -49,24 +49,24 @@ void main()
}
vec4 inner_color;
if (color_id == 0) {
if (color_id == 0u) {
inner_color = (edge_selected) ? colorHandleSelFree : colorHandleFree;
}
else if (color_id == 1) {
else if (color_id == 1u) {
inner_color = (edge_selected) ? colorHandleSelAuto : colorHandleAuto;
}
else if (color_id == 2) {
else if (color_id == 2u) {
inner_color = (edge_selected) ? colorHandleSelVect : colorHandleVect;
}
else if (color_id == 3) {
else if (color_id == 3u) {
inner_color = (edge_selected) ? colorHandleSelAlign : colorHandleAlign;
}
else if (color_id == 4) {
else if (color_id == 4u) {
inner_color = (edge_selected) ? colorHandleSelAutoclamp : colorHandleAutoclamp;
}
else {
bool is_selected = (((vert[1].flag & vert[0].flag) & VERT_SELECTED) != 0);
bool is_u_segment = (((vert[1].flag ^ vert[0].flag) & EVEN_U_BIT) != 0);
bool is_selected = (((vert[1].flag & vert[0].flag) & VERT_SELECTED) != 0u);
bool is_u_segment = (((vert[1].flag ^ vert[0].flag) & EVEN_U_BIT) != 0u);
if (is_u_segment) {
inner_color = (is_selected) ? colorNurbSelUline : colorNurbUline;
}
@ -75,7 +75,7 @@ void main()
}
}
vec4 outer_color = (is_active_nurb != 0) ?
vec4 outer_color = (is_active_nurb != 0u) ?
mix(colorActiveSpline,
inner_color,
0.25) /* Minimize active color bleeding on inner_color. */

View File

@ -47,7 +47,7 @@ void main()
uint color_id = (vert_flag[1] >> COLOR_SHIFT);
/* Don't output any edges if we don't show handles */
if (!showCurveHandles && (color_id < 5)) {
if (!showCurveHandles && (color_id < 5u)) {
return;
}
@ -58,10 +58,10 @@ 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 <= 4)) {
if ((!is_u_segment) && (color_id <= 4u)) {
return;
}
if (is_gpencil) {
@ -70,24 +70,24 @@ void main()
}
vec4 inner_color;
if (color_id == 0) {
if (color_id == 0u) {
inner_color = (edge_selected) ? colorHandleSelFree : colorHandleFree;
}
else if (color_id == 1) {
else if (color_id == 1u) {
inner_color = (edge_selected) ? colorHandleSelAuto : colorHandleAuto;
}
else if (color_id == 2) {
else if (color_id == 2u) {
inner_color = (edge_selected) ? colorHandleSelVect : colorHandleVect;
}
else if (color_id == 3) {
else if (color_id == 3u) {
inner_color = (edge_selected) ? colorHandleSelAlign : colorHandleAlign;
}
else if (color_id == 4) {
else if (color_id == 4u) {
inner_color = (edge_selected) ? colorHandleSelAutoclamp : colorHandleAutoclamp;
}
else {
bool is_selected = (((vert_flag[1] & vert_flag[0]) & VERT_SELECTED) != 0);
bool is_u_segment = (((vert_flag[1] ^ vert_flag[0]) & EVEN_U_BIT) != 0);
bool is_selected = (((vert_flag[1] & vert_flag[0]) & VERT_SELECTED) != 0u);
bool is_u_segment = (((vert_flag[1] ^ vert_flag[0]) & EVEN_U_BIT) != 0u);
if (is_u_segment) {
inner_color = (is_selected) ? colorNurbSelUline : colorNurbUline;
}
@ -96,7 +96,7 @@ void main()
}
}
vec4 outer_color = (is_active_nurb != 0) ?
vec4 outer_color = (is_active_nurb != 0u) ?
mix(colorActiveSpline,
inner_color,
0.25) /* Minimize active color bleeding on inner_color. */

View File

@ -7,9 +7,9 @@ void main()
GPU_INTEL_VERTEX_SHADER_WORKAROUND
/* Reuse the FREESTYLE flag to determine is GPencil. */
bool is_gpencil = ((data & EDGE_FREESTYLE) != 0);
if ((data & VERT_SELECTED) != 0) {
if ((data & VERT_ACTIVE) != 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;
}
else {
@ -26,11 +26,11 @@ void main()
view_clipping_distances(world_pos);
bool show_handle = showCurveHandles;
if ((curveHandleDisplay == CURVE_HANDLE_SELECTED) && ((data & VERT_SELECTED_BEZT_HANDLE) == 0)) {
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
if (!show_handle && ((data & BEZIER_HANDLE) != 0)) {
if (!show_handle && ((data & BEZIER_HANDLE) != 0u)) {
/* We set the vertex at the camera origin to generate 0 fragments. */
gl_Position = vec4(0.0, 0.0, -3e36, 0.0);
}

View File

@ -6,10 +6,10 @@ void main()
{
GPU_INTEL_VERTEX_SHADER_WORKAROUND
if ((data & VERT_SELECTED) != 0) {
if ((data & VERT_SELECTED) != 0u) {
finalColor = colorVertexSelect;
}
else if ((data & VERT_ACTIVE) != 0) {
else if ((data & VERT_ACTIVE) != 0u) {
finalColor = colorEditMeshActive;
}
else {