Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJason Fielder <jason_apple>2022-04-14 13:01:16 +0300
committerClément Foucault <foucault.clem@gmail.com>2022-04-14 13:01:31 +0300
commit8f0e06a0ca1f4b7f8ea00ec5346a5e55a2620707 (patch)
treece1817dcdfeb8df6ecfbd9c5faaad886dd8e20fb /source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
parente28f07b5c899a3036060e9e3f50a3e878663f02a (diff)
Metal: GPU_PRIM_LINE_LOOP alternative implementations.
Prefer using immVertex3f when 3D shaders are used for 2D rendering due to overhead of vertex padding in hardware. CPU overhead is negligible. Authored by Apple: Michael Parkin-White Ref T96261 Reviewed By: fclem Maniphest Tasks: T96261 Differential Revision: https://developer.blender.org/D14494
Diffstat (limited to 'source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c')
-rw-r--r--source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c15
1 files changed, 8 insertions, 7 deletions
diff --git a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
index 447fe1005a1..5fb1173521a 100644
--- a/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
+++ b/source/blender/editors/gizmo_library/gizmo_types/move3d_gizmo.c
@@ -98,7 +98,8 @@ static void move_geom_draw(const wmGizmo *gz,
ED_GIZMO_MOVE_DRAW_FLAG_FILL)));
GPUVertFormat *format = immVertexFormat();
- uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 2, GPU_FETCH_FLOAT);
+ /* Note(Metal): Prefer using 3D coordinates with 3D shader, even if rendering 2D gizmo's. */
+ uint pos = GPU_vertformat_attr_add(format, "pos", GPU_COMP_F32, 3, GPU_FETCH_FLOAT);
immBindBuiltinProgram(filled ? GPU_SHADER_3D_UNIFORM_COLOR :
GPU_SHADER_3D_POLYLINE_UNIFORM_COLOR);
@@ -115,20 +116,20 @@ static void move_geom_draw(const wmGizmo *gz,
if (draw_style == ED_GIZMO_MOVE_STYLE_RING_2D) {
if (filled) {
- imm_draw_circle_fill_2d(pos, 0, 0, radius, DIAL_RESOLUTION);
+ imm_draw_circle_fill_3d(pos, 0.0f, 0.0f, radius, DIAL_RESOLUTION);
}
else {
- imm_draw_circle_wire_2d(pos, 0, 0, radius, DIAL_RESOLUTION);
+ imm_draw_circle_wire_3d(pos, 0.0f, 0.0f, radius, DIAL_RESOLUTION);
}
}
else if (draw_style == ED_GIZMO_MOVE_STYLE_CROSS_2D) {
const float radius_diag = M_SQRT1_2 * radius;
immBegin(GPU_PRIM_LINES, 4);
- immVertex2f(pos, radius_diag, radius_diag);
- immVertex2f(pos, -radius_diag, -radius_diag);
+ immVertex3f(pos, radius_diag, radius_diag, 0.0f);
+ immVertex3f(pos, -radius_diag, -radius_diag, 0.0f);
- immVertex2f(pos, -radius_diag, radius_diag);
- immVertex2f(pos, radius_diag, -radius_diag);
+ immVertex3f(pos, -radius_diag, radius_diag, 0.0f);
+ immVertex3f(pos, radius_diag, -radius_diag, 0.0f);
immEnd();
}
else {