diff options
-rw-r--r-- | intern/gawain/gawain/gwn_batch.h | 7 | ||||
-rw-r--r-- | intern/gawain/src/gwn_batch.c | 16 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache.c | 151 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_curve.c | 61 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_displist.c | 4 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_cache_impl_lattice.c | 6 | ||||
-rw-r--r-- | source/blender/draw/intern/draw_manager.c | 8 | ||||
-rw-r--r-- | source/blender/editors/interface/interface_draw.c | 4 | ||||
-rw-r--r-- | source/blender/editors/manipulator_library/manipulator_draw_utils.c | 4 | ||||
-rw-r--r-- | source/blender/editors/space_view3d/drawobject.c | 21 | ||||
-rw-r--r-- | source/blender/editors/uvedit/uvedit_smart_stitch.c | 6 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_batch.c | 14 | ||||
-rw-r--r-- | source/blender/gpu/intern/gpu_compositing.c | 8 |
13 files changed, 120 insertions, 190 deletions
diff --git a/intern/gawain/gawain/gwn_batch.h b/intern/gawain/gawain/gwn_batch.h index 96d519450b5..1dd4621f1a3 100644 --- a/intern/gawain/gawain/gwn_batch.h +++ b/intern/gawain/gawain/gwn_batch.h @@ -58,7 +58,6 @@ void GWN_batch_init_ex(Gwn_Batch*, Gwn_PrimType, Gwn_VertBuf*, Gwn_IndexBuf*, un GWN_batch_init_ex(batch, prim, verts, elem, 0) void GWN_batch_discard(Gwn_Batch*); // verts & elem are not discarded -void GWN_batch_discard_all(Gwn_Batch*); // including verts & elem int GWN_batch_vertbuf_add_ex(Gwn_Batch*, Gwn_VertBuf*, bool own_vbo); @@ -136,9 +135,3 @@ Gwn_Batch* create_BatchInGeneral(Gwn_PrimType, VertexBufferStuff, ElementListStu batch = NULL; \ } \ } while (0) -#define BATCH_DISCARD_ALL_SAFE(batch) do { \ - if (batch != NULL) { \ - GWN_batch_discard_all(batch); \ - batch = NULL; \ - } \ -} while (0) diff --git a/intern/gawain/src/gwn_batch.c b/intern/gawain/src/gwn_batch.c index 23160668ca8..c95b67e39cf 100644 --- a/intern/gawain/src/gwn_batch.c +++ b/intern/gawain/src/gwn_batch.c @@ -69,22 +69,6 @@ void GWN_batch_discard(Gwn_Batch* batch) free(batch); } -/* TODO, remove */ -void GWN_batch_discard_all(Gwn_Batch* batch) - { - for (int v = 0; v < GWN_BATCH_VBO_MAX_LEN; ++v) - { - if (batch->verts[v] == NULL) - break; - GWN_vertbuf_discard(batch->verts[v]); - } - - if (batch->elem) - GWN_indexbuf_discard(batch->elem); - - GWN_batch_discard(batch); - } - int GWN_batch_vertbuf_add_ex( Gwn_Batch* batch, Gwn_VertBuf* verts, bool own_vbo) diff --git a/source/blender/draw/intern/draw_cache.c b/source/blender/draw/intern/draw_cache.c index 0472feb8352..453fb2cf41a 100644 --- a/source/blender/draw/intern/draw_cache.c +++ b/source/blender/draw/intern/draw_cache.c @@ -40,6 +40,7 @@ #include "draw_cache.h" #include "draw_cache_impl.h" +/* Batch's only (free'd as an array) */ static struct DRWShapeCache { Gwn_Batch *drw_single_vertice; Gwn_Batch *drw_fullscreen_quad; @@ -94,54 +95,12 @@ static struct DRWShapeCache { void DRW_shape_cache_free(void) { - BATCH_DISCARD_ALL_SAFE(SHC.drw_single_vertice); - BATCH_DISCARD_ALL_SAFE(SHC.drw_fullscreen_quad); - BATCH_DISCARD_ALL_SAFE(SHC.drw_plain_axes); - BATCH_DISCARD_ALL_SAFE(SHC.drw_single_arrow); - BATCH_DISCARD_ALL_SAFE(SHC.drw_cube); - BATCH_DISCARD_ALL_SAFE(SHC.drw_circle); - BATCH_DISCARD_ALL_SAFE(SHC.drw_square); - BATCH_DISCARD_ALL_SAFE(SHC.drw_line); - BATCH_DISCARD_ALL_SAFE(SHC.drw_line_endpoints); - BATCH_DISCARD_ALL_SAFE(SHC.drw_empty_sphere); - BATCH_DISCARD_ALL_SAFE(SHC.drw_empty_cone); - BATCH_DISCARD_ALL_SAFE(SHC.drw_arrows); - BATCH_DISCARD_ALL_SAFE(SHC.drw_axis_names); - BATCH_DISCARD_ALL_SAFE(SHC.drw_image_plane); - BATCH_DISCARD_ALL_SAFE(SHC.drw_image_plane_wire); - BATCH_DISCARD_ALL_SAFE(SHC.drw_field_wind); - BATCH_DISCARD_ALL_SAFE(SHC.drw_field_force); - BATCH_DISCARD_ALL_SAFE(SHC.drw_field_vortex); - BATCH_DISCARD_ALL_SAFE(SHC.drw_field_tube_limit); - BATCH_DISCARD_ALL_SAFE(SHC.drw_field_cone_limit); - BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp); - BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_sunrays); - BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_area); - BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_hemi); - BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_spot); - BATCH_DISCARD_ALL_SAFE(SHC.drw_lamp_spot_square); - BATCH_DISCARD_ALL_SAFE(SHC.drw_speaker); - BATCH_DISCARD_ALL_SAFE(SHC.drw_lightprobe_cube); - BATCH_DISCARD_ALL_SAFE(SHC.drw_lightprobe_planar); - BATCH_DISCARD_ALL_SAFE(SHC.drw_lightprobe_grid); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_octahedral); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_octahedral_wire); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_box); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_box_wire); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_wire_wire); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_envelope); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_envelope_distance); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_envelope_wire); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_envelope_head_wire); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_point); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_point_wire); - BATCH_DISCARD_ALL_SAFE(SHC.drw_bone_arrows); - BATCH_DISCARD_ALL_SAFE(SHC.drw_camera); - BATCH_DISCARD_ALL_SAFE(SHC.drw_camera_tria); - BATCH_DISCARD_ALL_SAFE(SHC.drw_camera_focus); - BATCH_DISCARD_ALL_SAFE(SHC.drw_particle_cross); - BATCH_DISCARD_ALL_SAFE(SHC.drw_particle_circle); - BATCH_DISCARD_ALL_SAFE(SHC.drw_particle_axis); + uint i = sizeof(SHC) / sizeof(Gwn_Batch *); + Gwn_Batch **batch = (Gwn_Batch **)&SHC; + while (i--) { + GWN_BATCH_DISCARD_SAFE(*batch); + batch++; + } } @@ -294,7 +253,7 @@ Gwn_Batch *DRW_cache_fullscreen_quad_get(void) GWN_vertbuf_attr_set(vbo, attr_id.uvs, i, uvs[i]); } - SHC.drw_fullscreen_quad = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL); + SHC.drw_fullscreen_quad = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_fullscreen_quad; } @@ -342,7 +301,7 @@ Gwn_Batch *DRW_cache_cube_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, i, verts[indices[i]]); } - SHC.drw_cube = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_cube; } @@ -375,7 +334,7 @@ Gwn_Batch *DRW_cache_circle_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 2 + 1, v); } - SHC.drw_circle = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_circle = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_circle; #undef CIRCLE_RESOL @@ -404,7 +363,7 @@ Gwn_Batch *DRW_cache_square_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 2 + 1, p[(i+1) % 4]); } - SHC.drw_square = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_square; } @@ -429,7 +388,7 @@ Gwn_Batch *DRW_cache_single_line_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); - SHC.drw_line = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_line = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_line; } @@ -454,7 +413,7 @@ Gwn_Batch *DRW_cache_single_line_endpoints_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); GWN_vertbuf_attr_set(vbo, attr_id.pos, 1, v2); - SHC.drw_line_endpoints = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL); + SHC.drw_line_endpoints = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_line_endpoints; } @@ -481,7 +440,7 @@ Gwn_Batch *DRW_cache_screenspace_circle_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, a, v); } - SHC.drw_screenspace_circle = GWN_batch_create(GWN_PRIM_LINE_STRIP, vbo, NULL); + SHC.drw_screenspace_circle = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_screenspace_circle; #undef CIRCLE_RESOL @@ -569,7 +528,7 @@ Gwn_Batch *DRW_cache_plain_axes_get(void) v1[axis] = v2[axis] = 0.0f; } - SHC.drw_plain_axes = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_plain_axes = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_plain_axes; } @@ -609,7 +568,7 @@ Gwn_Batch *DRW_cache_single_arrow_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, sides * 3 + 2, v3); } - SHC.drw_single_arrow = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL); + SHC.drw_single_arrow = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_single_arrow; } @@ -618,7 +577,7 @@ Gwn_Batch *DRW_cache_empty_sphere_get(void) { if (!SHC.drw_empty_sphere) { Gwn_VertBuf *vbo = sphere_wire_vbo(1.0f); - SHC.drw_empty_sphere = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_empty_sphere = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_empty_sphere; } @@ -665,7 +624,7 @@ Gwn_Batch *DRW_cache_empty_cone_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, i * 4 + 3, v); } - SHC.drw_empty_cone = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_empty_cone = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_empty_cone; #undef NSEGMENTS @@ -676,7 +635,7 @@ Gwn_Batch *DRW_cache_arrows_get(void) if (!SHC.drw_arrows) { Gwn_VertBuf *vbo = fill_arrows_vbo(1.0f); - SHC.drw_arrows = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_arrows; } @@ -737,7 +696,7 @@ Gwn_Batch *DRW_cache_axis_names_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, 12, v1); GWN_vertbuf_attr_set(vbo, attr_id.pos, 13, v2); - SHC.drw_axis_names = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_axis_names = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_axis_names; } @@ -758,7 +717,7 @@ Gwn_Batch *DRW_cache_image_plane_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); GWN_vertbuf_attr_set(vbo, attr_id.texCoords, j, quad[j]); } - SHC.drw_image_plane = GWN_batch_create(GWN_PRIM_TRI_FAN, vbo, NULL); + SHC.drw_image_plane = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_image_plane; } @@ -777,7 +736,7 @@ Gwn_Batch *DRW_cache_image_plane_wire_get(void) for (uint j = 0; j < 4; j++) { GWN_vertbuf_attr_set(vbo, attr_id.pos, j, quad[j]); } - SHC.drw_image_plane_wire = GWN_batch_create(GWN_PRIM_LINE_LOOP, vbo, NULL); + SHC.drw_image_plane_wire = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_image_plane_wire; } @@ -814,7 +773,7 @@ Gwn_Batch *DRW_cache_field_wind_get(void) } } - SHC.drw_field_wind = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_field_wind = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_field_wind; #undef CIRCLE_RESOL @@ -851,7 +810,7 @@ Gwn_Batch *DRW_cache_field_force_get(void) } } - SHC.drw_field_force = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_field_force = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_field_force; #undef CIRCLE_RESOL @@ -888,7 +847,7 @@ Gwn_Batch *DRW_cache_field_vortex_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v); } - SHC.drw_field_vortex = GWN_batch_create(GWN_PRIM_LINE_STRIP, vbo, NULL); + SHC.drw_field_vortex = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_field_vortex; #undef SPIRAL_RESOL @@ -937,7 +896,7 @@ Gwn_Batch *DRW_cache_field_tube_limit_get(void) } } - SHC.drw_field_tube_limit = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_field_tube_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_field_tube_limit; #undef CIRCLE_RESOL @@ -986,7 +945,7 @@ Gwn_Batch *DRW_cache_field_cone_limit_get(void) } } - SHC.drw_field_cone_limit = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_field_cone_limit = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_field_cone_limit; #undef CIRCLE_RESOL @@ -1025,7 +984,7 @@ Gwn_Batch *DRW_cache_lamp_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 2 + 1, v); } - SHC.drw_lamp = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_lamp = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_lamp; #undef NSEGMENTS @@ -1057,7 +1016,7 @@ Gwn_Batch *DRW_cache_lamp_sunrays_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, a * 2 + 1, v2); } - SHC.drw_lamp_sunrays = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_lamp_sunrays = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_lamp_sunrays; } @@ -1091,7 +1050,7 @@ Gwn_Batch *DRW_cache_lamp_area_get(void) v1[1] = 0.5f; GWN_vertbuf_attr_set(vbo, attr_id.pos, 7, v1); - SHC.drw_lamp_area = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_lamp_area = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_lamp_area; } @@ -1153,7 +1112,7 @@ Gwn_Batch *DRW_cache_lamp_hemi_get(void) } - SHC.drw_lamp_hemi = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_lamp_hemi = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_lamp_hemi; #undef CIRCLE_RESOL @@ -1223,7 +1182,7 @@ Gwn_Batch *DRW_cache_lamp_spot_get(void) GWN_vertbuf_attr_set(vbo, attr_id.n2, i * 4 + 3, neg[(i) % NSEGMENTS]); } - SHC.drw_lamp_spot = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_lamp_spot = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_lamp_spot; #undef NSEGMENTS @@ -1259,7 +1218,7 @@ Gwn_Batch *DRW_cache_lamp_spot_square_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, p[((i+1) % 4)+1]); } - SHC.drw_lamp_spot_square = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_lamp_spot_square = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_lamp_spot_square; } @@ -1323,7 +1282,7 @@ Gwn_Batch *DRW_cache_speaker_get(void) } } - SHC.drw_speaker = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_speaker = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_speaker; } @@ -1375,7 +1334,7 @@ Gwn_Batch *DRW_cache_lightprobe_cube_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - SHC.drw_lightprobe_cube = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_lightprobe_cube = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_cube; } @@ -1432,7 +1391,7 @@ Gwn_Batch *DRW_cache_lightprobe_grid_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[3]); GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[6]); - SHC.drw_lightprobe_grid = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_lightprobe_grid = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_grid; } @@ -1464,7 +1423,7 @@ Gwn_Batch *DRW_cache_lightprobe_planar_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, v[(i + 1) % 4]); } - SHC.drw_lightprobe_planar = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_lightprobe_planar = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_lightprobe_planar; } @@ -1548,7 +1507,7 @@ Gwn_Batch *DRW_cache_bone_octahedral_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, bone_octahedral_verts[bone_octahedral_solid_tris[i][2]]); } - SHC.drw_bone_octahedral = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL); + SHC.drw_bone_octahedral = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_octahedral; } @@ -1578,7 +1537,7 @@ Gwn_Batch *DRW_cache_bone_octahedral_wire_outline_get(void) add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n1, n2); } - SHC.drw_bone_octahedral_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_bone_octahedral_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_octahedral_wire; } @@ -1674,7 +1633,7 @@ Gwn_Batch *DRW_cache_bone_box_get(void) } } - SHC.drw_bone_box = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL); + SHC.drw_bone_box = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_box; } @@ -1704,7 +1663,7 @@ Gwn_Batch *DRW_cache_bone_box_wire_outline_get(void) add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n1, n2); } - SHC.drw_bone_box_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_bone_box_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_box_wire; } @@ -1732,7 +1691,7 @@ Gwn_Batch *DRW_cache_bone_wire_wire_outline_get(void) const float n[3] = {1.0f, 0.0f, 0.0f}; add_fancy_edge(vbo, attr_id.pos, attr_id.n1, attr_id.n2, &v_idx, co1, co2, n, n); - SHC.drw_bone_wire_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_bone_wire_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_wire_wire; } @@ -1824,7 +1783,7 @@ Gwn_Batch *DRW_cache_bone_envelope_solid_get(void) } } - SHC.drw_bone_envelope = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL); + SHC.drw_bone_envelope = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_envelope; } @@ -1863,7 +1822,7 @@ Gwn_Batch *DRW_cache_bone_envelope_distance_outline_get(void) } } - SHC.drw_bone_envelope_distance = GWN_batch_create(GWN_PRIM_TRI_STRIP, vbo, NULL); + SHC.drw_bone_envelope_distance = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_envelope_distance; #undef CIRCLE_RESOL @@ -1894,7 +1853,7 @@ Gwn_Batch *DRW_cache_bone_envelope_wire_outline_get(void) GWN_vertbuf_attr_set(vbo, pos_id, v_idx++, (const float[4]){-1.0f, 0.0f, 0.0f, 0.0f}); GWN_vertbuf_attr_set(vbo, pos_id, v_idx++, (const float[4]){-1.0f, 0.0f, 1.0f, 0.0f}); - SHC.drw_bone_envelope_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_bone_envelope_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_envelope_wire; } @@ -1928,7 +1887,7 @@ Gwn_Batch *DRW_cache_bone_envelope_head_wire_outline_get(void) GWN_vertbuf_attr_set(vbo, pos_id, v_idx++, (const float[4]){ x, y, 0.0f, 0.0f}); } - SHC.drw_bone_envelope_head_wire = GWN_batch_create(GWN_PRIM_LINE_LOOP, vbo, NULL); + SHC.drw_bone_envelope_head_wire = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_envelope_head_wire; #undef CIRCLE_RESOL @@ -1974,7 +1933,7 @@ Gwn_Batch *DRW_cache_bone_point_get(void) } } - SHC.drw_bone_point = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL); + SHC.drw_bone_point = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_point; } @@ -1983,7 +1942,7 @@ Gwn_Batch *DRW_cache_bone_point_wire_outline_get(void) { if (!SHC.drw_bone_point_wire) { Gwn_VertBuf *vbo = sphere_wire_vbo(0.05f); - SHC.drw_bone_point_wire = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_bone_point_wire = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_point_wire; } @@ -1992,7 +1951,7 @@ Gwn_Batch *DRW_cache_bone_arrows_get(void) { if (!SHC.drw_bone_arrows) { Gwn_VertBuf *vbo = fill_arrows_vbo(0.25f); - SHC.drw_bone_arrows = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_bone_arrows = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_bone_arrows; } @@ -2065,7 +2024,7 @@ Gwn_Batch *DRW_cache_camera_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, &v7); GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, &v5); - SHC.drw_camera = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_camera = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_camera; } @@ -2096,7 +2055,7 @@ Gwn_Batch *DRW_cache_camera_tria_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, &v6); GWN_vertbuf_attr_set(vbo, attr_id.pos, v_idx++, &v7); - SHC.drw_camera_tria = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL); + SHC.drw_camera_tria = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_camera_tria; } @@ -2126,7 +2085,7 @@ Gwn_Batch *DRW_cache_single_vert_get(void) GWN_vertbuf_attr_set(vbo, attr_id.pos, 0, v1); - SHC.drw_single_vertice = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL); + SHC.drw_single_vertice = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_single_vertice; } @@ -2496,7 +2455,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) GWN_vertbuf_attr_set(vbo, pos_id, 5, co); GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis); - SHC.drw_particle_cross = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_particle_cross = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_particle_cross; @@ -2543,7 +2502,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) GWN_vertbuf_attr_set(vbo, pos_id, 5, co); GWN_vertbuf_attr_set(vbo, axis_id, 5, &axis); - SHC.drw_particle_axis = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + SHC.drw_particle_axis = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_particle_axis; @@ -2572,7 +2531,7 @@ Gwn_Batch *DRW_cache_particles_get_prim(int type) GWN_vertbuf_attr_set(vbo, axis_id, a, &axis); } - SHC.drw_particle_circle = GWN_batch_create(GWN_PRIM_LINE_LOOP, vbo, NULL); + SHC.drw_particle_circle = GWN_batch_create_ex(GWN_PRIM_LINE_LOOP, vbo, NULL, GWN_BATCH_OWNS_VBO); } return SHC.drw_particle_circle; diff --git a/source/blender/draw/intern/draw_cache_impl_curve.c b/source/blender/draw/intern/draw_cache_impl_curve.c index 9ff9fab4c64..e6e52fe4579 100644 --- a/source/blender/draw/intern/draw_cache_impl_curve.c +++ b/source/blender/draw/intern/draw_cache_impl_curve.c @@ -422,12 +422,12 @@ void DRW_curve_batch_cache_dirty(Curve *cu, int mode) break; case BKE_CURVE_BATCH_DIRTY_SELECT: /* editnurb */ - BATCH_DISCARD_ALL_SAFE(cache->overlay.verts); - BATCH_DISCARD_ALL_SAFE(cache->overlay.edges); + GWN_BATCH_DISCARD_SAFE(cache->overlay.verts); + GWN_BATCH_DISCARD_SAFE(cache->overlay.edges); /* editfont */ - BATCH_DISCARD_ALL_SAFE(cache->text.select); - BATCH_DISCARD_ALL_SAFE(cache->text.cursor); + GWN_BATCH_DISCARD_SAFE(cache->text.select); + GWN_BATCH_DISCARD_SAFE(cache->text.cursor); break; default: BLI_assert(0); @@ -441,38 +441,26 @@ static void curve_batch_cache_clear(Curve *cu) return; } - BATCH_DISCARD_ALL_SAFE(cache->overlay.verts); - BATCH_DISCARD_ALL_SAFE(cache->overlay.edges); + GWN_BATCH_DISCARD_SAFE(cache->overlay.verts); + GWN_BATCH_DISCARD_SAFE(cache->overlay.edges); - BATCH_DISCARD_ALL_SAFE(cache->surface.batch); + GWN_BATCH_DISCARD_SAFE(cache->surface.batch); - if (cache->wire.batch) { - BATCH_DISCARD_ALL_SAFE(cache->wire.batch); - cache->wire.verts = NULL; - cache->wire.edges = NULL; - cache->wire.elem = NULL; - } - else { - GWN_VERTBUF_DISCARD_SAFE(cache->wire.verts); - GWN_VERTBUF_DISCARD_SAFE(cache->wire.edges); - GWN_INDEXBUF_DISCARD_SAFE(cache->wire.elem); - } + /* don't own vbo & elems */ + GWN_BATCH_DISCARD_SAFE(cache->wire.batch); + GWN_VERTBUF_DISCARD_SAFE(cache->wire.verts); + GWN_VERTBUF_DISCARD_SAFE(cache->wire.edges); + GWN_INDEXBUF_DISCARD_SAFE(cache->wire.elem); - if (cache->normal.batch) { - BATCH_DISCARD_ALL_SAFE(cache->normal.batch); - cache->normal.verts = NULL; - cache->normal.edges = NULL; - cache->normal.elem = NULL; - } - else { - GWN_VERTBUF_DISCARD_SAFE(cache->normal.verts); - GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges); - GWN_INDEXBUF_DISCARD_SAFE(cache->normal.elem); - } + /* don't own vbo & elems */ + GWN_BATCH_DISCARD_SAFE(cache->normal.batch); + GWN_VERTBUF_DISCARD_SAFE(cache->normal.verts); + GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges); + GWN_INDEXBUF_DISCARD_SAFE(cache->normal.elem); /* 3d text */ - BATCH_DISCARD_ALL_SAFE(cache->text.cursor); - BATCH_DISCARD_ALL_SAFE(cache->text.select); + GWN_BATCH_DISCARD_SAFE(cache->text.cursor); + GWN_BATCH_DISCARD_SAFE(cache->text.select); } void DRW_curve_batch_cache_free(Curve *cu) @@ -726,7 +714,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) GWN_vertbuf_data_resize(vbo, vbo_len_used); } - cache->overlay.verts = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL); + cache->overlay.verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); } @@ -798,7 +786,7 @@ static void curve_batch_cache_create_overlay_batches(Curve *cu) GWN_vertbuf_data_resize(vbo, vbo_len_used); } - cache->overlay.edges = GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + cache->overlay.edges = GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } curve_render_data_free(rdata); @@ -892,7 +880,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_select(CurveRenderData *rdata, C GWN_vertbuf_attr_set(vbo, attr_id.pos, vbo_len_used++, box[3]); } BLI_assert(vbo_len_used == vbo_len_capacity); - cache->text.select = GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL); + cache->text.select = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); } return cache->text.select; } @@ -913,7 +901,7 @@ static Gwn_Batch *curve_batch_cache_get_overlay_cursor(CurveRenderData *rdata, C for (int i = 0; i < 4; i++) { GWN_vertbuf_attr_set(vbo, attr_id.pos, i, rdata->text.edit_font->textcurs[i]); } - cache->text.cursor = GWN_batch_create(GWN_PRIM_TRI_FAN, vbo, NULL); + cache->text.cursor = GWN_batch_create_ex(GWN_PRIM_TRI_FAN, vbo, NULL, GWN_BATCH_OWNS_VBO); } return cache->text.cursor; } @@ -950,7 +938,8 @@ Gwn_Batch *DRW_curve_batch_cache_get_normal_edge(Curve *cu, CurveCache *ob_curve if (cache->normal.batch != NULL) { cache->normal_size = normal_size; if (cache->normal_size != normal_size) { - BATCH_DISCARD_ALL_SAFE(cache->normal.batch); + GWN_BATCH_DISCARD_SAFE(cache->normal.batch); + GWN_VERTBUF_DISCARD_SAFE(cache->normal.edges); } } cache->normal_size = normal_size; diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c index fd36b7ad4a3..30eed85f49d 100644 --- a/source/blender/draw/intern/draw_cache_impl_displist.c +++ b/source/blender/draw/intern/draw_cache_impl_displist.c @@ -163,6 +163,8 @@ Gwn_Batch *BLI_displist_batch_calc_surface(ListBase *lb) } } - return GWN_batch_create(GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb)); + return GWN_batch_create_ex( + GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb), + GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_VBO); } } diff --git a/source/blender/draw/intern/draw_cache_impl_lattice.c b/source/blender/draw/intern/draw_cache_impl_lattice.c index 84b061aff9a..20698fe6592 100644 --- a/source/blender/draw/intern/draw_cache_impl_lattice.c +++ b/source/blender/draw/intern/draw_cache_impl_lattice.c @@ -376,7 +376,7 @@ void DRW_lattice_batch_cache_dirty(Lattice *lt, int mode) break; case BKE_LATTICE_BATCH_DIRTY_SELECT: /* TODO Separate Flag vbo */ - BATCH_DISCARD_ALL_SAFE(cache->overlay_verts); + GWN_BATCH_DISCARD_SAFE(cache->overlay_verts); break; default: BLI_assert(0); @@ -392,7 +392,7 @@ static void lattice_batch_cache_clear(Lattice *lt) GWN_BATCH_DISCARD_SAFE(cache->all_verts); GWN_BATCH_DISCARD_SAFE(cache->all_edges); - BATCH_DISCARD_ALL_SAFE(cache->overlay_verts); + GWN_BATCH_DISCARD_SAFE(cache->overlay_verts); GWN_VERTBUF_DISCARD_SAFE(cache->pos); GWN_INDEXBUF_DISCARD_SAFE(cache->edges); @@ -537,7 +537,7 @@ static void lattice_batch_cache_create_overlay_batches(Lattice *lt) GWN_vertbuf_attr_set(vbo, attr_id.data, i, &vflag); } - cache->overlay_verts = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL); + cache->overlay_verts = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); } lattice_render_data_free(rdata); diff --git a/source/blender/draw/intern/draw_manager.c b/source/blender/draw/intern/draw_manager.c index 96f7b2864ed..b6a12cf84ff 100644 --- a/source/blender/draw/intern/draw_manager.c +++ b/source/blender/draw/intern/draw_manager.c @@ -909,14 +909,14 @@ void DRW_shgroup_free(struct DRWShadingGroup *shgroup) BLI_freelistN(&shgroup->interface->attribs); if (shgroup->interface->instance_vbo && - (shgroup->interface->instance_batch == 0)) + (shgroup->interface->instance_batch == 0)) { glDeleteBuffers(1, &shgroup->interface->instance_vbo); } MEM_freeN(shgroup->interface); - BATCH_DISCARD_ALL_SAFE(shgroup->batch_geom); + GWN_BATCH_DISCARD_SAFE(shgroup->batch_geom); } void DRW_shgroup_instance_batch(DRWShadingGroup *shgroup, struct Gwn_Batch *instances) @@ -1257,9 +1257,9 @@ static void shgroup_dynamic_batch(DRWShadingGroup *shgroup) /* TODO make the batch dynamic instead of freeing it every times */ if (shgroup->batch_geom) - GWN_batch_discard_all(shgroup->batch_geom); + GWN_batch_discard(shgroup->batch_geom); - shgroup->batch_geom = GWN_batch_create(type, vbo, NULL); + shgroup->batch_geom = GWN_batch_create_ex(type, vbo, NULL, GWN_BATCH_OWNS_VBO); } static void shgroup_dynamic_instance(DRWShadingGroup *shgroup) diff --git a/source/blender/editors/interface/interface_draw.c b/source/blender/editors/interface/interface_draw.c index 89400bd24a3..d9175c03e43 100644 --- a/source/blender/editors/interface/interface_draw.c +++ b/source/blender/editors/interface/interface_draw.c @@ -771,12 +771,12 @@ static void waveform_draw_one(float *waveform, int nbr, const float col[3]) GWN_vertbuf_attr_fill(vbo, pos_id, waveform); /* TODO store the Gwn_Batch inside the scope */ - Gwn_Batch *batch = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL); + Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); Batch_set_builtin_program(batch, GPU_SHADER_2D_UNIFORM_COLOR); GWN_batch_uniform_4f(batch, "color", col[0], col[1], col[2], 1.0f); GWN_batch_draw(batch); - GWN_batch_discard_all(batch); + GWN_batch_discard(batch); } void ui_draw_but_WAVEFORM(ARegion *ar, uiBut *but, uiWidgetColors *UNUSED(wcol), const rcti *recti) diff --git a/source/blender/editors/manipulator_library/manipulator_draw_utils.c b/source/blender/editors/manipulator_library/manipulator_draw_utils.c index 26f9ebbe54e..0fb36bca183 100644 --- a/source/blender/editors/manipulator_library/manipulator_draw_utils.c +++ b/source/blender/editors/manipulator_library/manipulator_draw_utils.c @@ -95,7 +95,7 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo GWN_vertbuf_attr_fill(vbo, nor_id, info->normals); } - batch = GWN_batch_create(GWN_PRIM_TRIS, vbo, el); + batch = GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, el, GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR); GWN_batch_uniform_4fv(batch, "color", color); @@ -115,7 +115,7 @@ void wm_manipulator_geometryinfo_draw(const ManipulatorGeomInfo *info, const boo #endif - GWN_batch_discard_all(batch); + GWN_batch_discard(batch); } void wm_manipulator_vec_draw( diff --git a/source/blender/editors/space_view3d/drawobject.c b/source/blender/editors/space_view3d/drawobject.c index b0d5406e517..8bddcd43d16 100644 --- a/source/blender/editors/space_view3d/drawobject.c +++ b/source/blender/editors/space_view3d/drawobject.c @@ -5140,13 +5140,13 @@ static void drawDispListVerts(Gwn_PrimType prim_type, const void *data, unsigned GWN_vertbuf_attr_fill(vbo, pos_id, data); - Gwn_Batch *batch = GWN_batch_create(prim_type, vbo, NULL); + Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO); Batch_set_builtin_program(batch, GPU_SHADER_3D_UNIFORM_COLOR); if (wire_col) { GWN_batch_uniform_4f(batch, "color", wire_col[0] / 255.0f, wire_col[1] / 255.0f, wire_col[2] / 255.0f, 1.0f); } GWN_batch_draw(batch); - GWN_batch_discard_all(batch); + GWN_batch_discard(batch); } /* convert dispList with elem indices to batch, only support triangles and quads @@ -5202,7 +5202,8 @@ static void drawDispListElem( } } - Gwn_Batch *batch = GWN_batch_create(GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb)); + Gwn_Batch *batch = GWN_batch_create_ex( + GWN_PRIM_TRIS, vbo, GWN_indexbuf_build(&elb), GWN_BATCH_OWNS_VBO | GWN_BATCH_OWNS_INDEX); Batch_set_builtin_program(batch, GPU_SHADER_SIMPLE_LIGHTING); if (wire_col) { GWN_batch_uniform_4f(batch, "color", wire_col[0] / 255.0f, wire_col[1] / 255.0f, wire_col[2] / 255.0f, 1.0f); @@ -5210,7 +5211,7 @@ static void drawDispListElem( GWN_batch_uniform_4f(batch, "color", 0.8f, 0.8f, 0.8f, 1.0f); GWN_batch_uniform_3f(batch, "light", 0.0f, 0.0f, 1.0f); GWN_batch_draw(batch); - GWN_batch_discard_all(batch); + GWN_batch_discard(batch); } /** @@ -5653,7 +5654,7 @@ static void draw_vertex_array(Gwn_PrimType prim_type, const float *vert, const f if (color) GWN_vertbuf_attr_fill_stride(vbo, col_id, stride, color); } - Gwn_Batch *batch = GWN_batch_create(prim_type, vbo, NULL); + Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO); if (nor && color) { Batch_set_builtin_program(batch, GPU_SHADER_SIMPLE_LIGHTING_SMOOTH_COLOR); GWN_batch_uniform_3f(batch, "light", 0.0f, 0.0f, 1.0f); @@ -5671,7 +5672,7 @@ static void draw_vertex_array(Gwn_PrimType prim_type, const float *vert, const f if (col) GWN_batch_uniform_4fv(batch, "color", col); } GWN_batch_draw(batch); - GWN_batch_discard_all(batch); + GWN_batch_discard(batch); } static void draw_particle_arrays_new(int draw_as, int ob_dt, int select, @@ -6677,10 +6678,10 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) GWN_vertbuf_attr_fill_stride(vbo, col_id, sizeof(ParticleCacheKey), path->col); } - Gwn_Batch *batch = GWN_batch_create(GWN_PRIM_LINE_STRIP, vbo, NULL); + Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_LINE_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); Batch_set_builtin_program(batch, GPU_SHADER_3D_SMOOTH_COLOR); GWN_batch_draw(batch); - GWN_batch_discard_all(batch); + GWN_batch_discard(batch); } if (pathcol) { MEM_freeN(pathcol); pathcol = NULL; } @@ -6748,10 +6749,10 @@ static void draw_ptcache_edit(Scene *scene, View3D *v3d, PTCacheEdit *edit) GWN_vertbuf_attr_fill(vbo, col_id, cd); - Gwn_Batch *batch = GWN_batch_create(GWN_PRIM_POINTS, vbo, NULL); + Gwn_Batch *batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo, NULL, GWN_BATCH_OWNS_VBO); Batch_set_builtin_program(batch, GPU_SHADER_3D_SMOOTH_COLOR); GWN_batch_draw(batch); - GWN_batch_discard_all(batch); + GWN_batch_discard(batch); pd += pd ? 3 * point->totkey : 0; cd += (timed ? 4 : 3) * point->totkey; diff --git a/source/blender/editors/uvedit/uvedit_smart_stitch.c b/source/blender/editors/uvedit/uvedit_smart_stitch.c index 55c439924cd..d75822cabe1 100644 --- a/source/blender/editors/uvedit/uvedit_smart_stitch.c +++ b/source/blender/editors/uvedit/uvedit_smart_stitch.c @@ -1541,13 +1541,15 @@ static void stitch_calculate_edge_normal(BMEditMesh *em, UvEdge *edge, float *no normalize_v2(normal); } +/** + */ static void stitch_draw_vbo(Gwn_VertBuf *vbo, Gwn_PrimType prim_type, const float col[4]) { - Gwn_Batch *batch = GWN_batch_create(prim_type, vbo, NULL); + Gwn_Batch *batch = GWN_batch_create_ex(prim_type, vbo, NULL, GWN_BATCH_OWNS_VBO); Batch_set_builtin_program(batch, GPU_SHADER_2D_UNIFORM_COLOR); GWN_batch_uniform_4fv(batch, "color", col); GWN_batch_draw(batch); - GWN_batch_discard_all(batch); + GWN_batch_discard(batch); } /* TODO make things pretier : store batches inside StitchPreviewer instead of the bare verts pos */ diff --git a/source/blender/gpu/intern/gpu_batch.c b/source/blender/gpu/intern/gpu_batch.c index 92bab13dcb5..cb2b65d1a67 100644 --- a/source/blender/gpu/intern/gpu_batch.c +++ b/source/blender/gpu/intern/gpu_batch.c @@ -93,7 +93,7 @@ static Gwn_Batch *batch_sphere(int lat_res, int lon_res) } } - return GWN_batch_create(GWN_PRIM_TRIS, vbo, NULL); + return GWN_batch_create_ex(GWN_PRIM_TRIS, vbo, NULL, GWN_BATCH_OWNS_VBO); } static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res) @@ -125,7 +125,7 @@ static Gwn_Batch *batch_sphere_wire(int lat_res, int lon_res) } } - return GWN_batch_create(GWN_PRIM_LINES, vbo, NULL); + return GWN_batch_create_ex(GWN_PRIM_LINES, vbo, NULL, GWN_BATCH_OWNS_VBO); } Gwn_Batch *Batch_get_sphere(int lod) @@ -163,9 +163,9 @@ void gpu_batch_init(void) void gpu_batch_exit(void) { - GWN_batch_discard_all(sphere_low); - GWN_batch_discard_all(sphere_med); - GWN_batch_discard_all(sphere_high); - GWN_batch_discard_all(sphere_wire_low); - GWN_batch_discard_all(sphere_wire_med); + GWN_batch_discard(sphere_low); + GWN_batch_discard(sphere_med); + GWN_batch_discard(sphere_high); + GWN_batch_discard(sphere_wire_low); + GWN_batch_discard(sphere_wire_med); } diff --git a/source/blender/gpu/intern/gpu_compositing.c b/source/blender/gpu/intern/gpu_compositing.c index afd28aece12..5bb9fe95099 100644 --- a/source/blender/gpu/intern/gpu_compositing.c +++ b/source/blender/gpu/intern/gpu_compositing.c @@ -285,7 +285,7 @@ GPUFX *GPU_fx_compositor_create(void) GWN_vertbuf_attr_set(vbo, pos, i, fullscreencos[i]); GWN_vertbuf_attr_set(vbo, uvs, i, fullscreenuvs[i]); } - fx->quad_batch = GWN_batch_create(GWN_PRIM_TRI_STRIP, vbo, NULL); + fx->quad_batch = GWN_batch_create_ex(GWN_PRIM_TRI_STRIP, vbo, NULL, GWN_BATCH_OWNS_VBO); /* Point Buffer */ static Gwn_VertFormat format_point = {0}; @@ -297,7 +297,7 @@ GPUFX *GPU_fx_compositor_create(void) Gwn_VertBuf *vbo_point = GWN_vertbuf_create_with_format(&format_point); GWN_vertbuf_data_alloc(vbo_point, 1); GWN_vertbuf_attr_set(vbo_point, dummy_attrib, 0, &dummy); - fx->point_batch = GWN_batch_create(GWN_PRIM_POINTS, vbo_point, NULL); + fx->point_batch = GWN_batch_create_ex(GWN_PRIM_POINTS, vbo_point, NULL, GWN_BATCH_OWNS_VBO); return fx; } @@ -387,8 +387,8 @@ static void cleanup_fx_gl_data(GPUFX *fx, bool do_fbo) void GPU_fx_compositor_destroy(GPUFX *fx) { cleanup_fx_gl_data(fx, true); - GWN_batch_discard_all(fx->quad_batch); - GWN_batch_discard_all(fx->point_batch); + GWN_batch_discard(fx->quad_batch); + GWN_batch_discard(fx->point_batch); MEM_freeN(fx); } |