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:
authorClément Foucault <foucault.clem@gmail.com>2020-09-06 17:40:07 +0300
committerClément Foucault <foucault.clem@gmail.com>2020-09-06 23:13:06 +0300
commit7ffff04e4900ca284519900d12bd1490e218c4f4 (patch)
treed148ee3c5c286a45bc33f521c2c606e47dd43968 /source/blender/draw
parent98fc3f263cf18a1222d7ffe7dc0e1c0a1fa47ecd (diff)
GPUVertBuf: Make GPUVertBuf private to the GPU module
This is just a cleanup to isolate the internals of the vertbuf. This adds some getters to avoid refactor of existing code.
Diffstat (limited to 'source/blender/draw')
-rw-r--r--source/blender/draw/engines/eevee/eevee_motion_blur.c13
-rw-r--r--source/blender/draw/engines/overlay/overlay_motion_path.c4
-rw-r--r--source/blender/draw/intern/draw_cache_extract_mesh.c50
-rw-r--r--source/blender/draw/intern/draw_cache_impl_displist.c4
-rw-r--r--source/blender/draw/intern/draw_cache_impl_gpencil.c15
-rw-r--r--source/blender/draw/intern/draw_cache_impl_pointcloud.c2
-rw-r--r--source/blender/draw/intern/draw_cache_inline.h15
-rw-r--r--source/blender/draw/intern/draw_instance_data.c9
-rw-r--r--source/blender/draw/intern/draw_manager_data.c6
-rw-r--r--source/blender/draw/intern/draw_manager_exec.c5
10 files changed, 60 insertions, 63 deletions
diff --git a/source/blender/draw/engines/eevee/eevee_motion_blur.c b/source/blender/draw/engines/eevee/eevee_motion_blur.c
index e10c627494a..c84d1ba33ea 100644
--- a/source/blender/draw/engines/eevee/eevee_motion_blur.c
+++ b/source/blender/draw/engines/eevee/eevee_motion_blur.c
@@ -480,7 +480,7 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata)
for (int i = 0; i < MB_CURR; i++) {
GPUVertBuf *vbo = mb_geom->vbo[i];
if (vbo && batch) {
- if (vbo->vertex_len != batch->verts[0]->vertex_len) {
+ if (GPU_vertbuf_get_vertex_len(vbo) != GPU_vertbuf_get_vertex_len(batch->verts[0])) {
/* Vertex count mismatch, disable deform motion blur. */
mb_geom->use_deform = false;
}
@@ -506,9 +506,9 @@ void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata)
/* Perform a copy to avoid loosing it after RE_engine_frame_set(). */
mb_geom->vbo[mb_step] = vbo = GPU_vertbuf_duplicate(vbo);
/* Find and replace "pos" attrib name. */
- int attrib_id = GPU_vertformat_attr_id_get(&vbo->format, "pos");
- GPU_vertformat_attr_rename(
- &vbo->format, attrib_id, (mb_step == MB_PREV) ? "prv" : "nxt");
+ GPUVertFormat *format = (GPUVertFormat *)GPU_vertbuf_get_format(vbo);
+ int attrib_id = GPU_vertformat_attr_id_get(format, "pos");
+ GPU_vertformat_attr_rename(format, attrib_id, (mb_step == MB_PREV) ? "prv" : "nxt");
}
}
break;
@@ -573,8 +573,9 @@ void EEVEE_motion_blur_swap_data(EEVEE_Data *vedata)
if (mb_geom->vbo[MB_NEXT]) {
GPUVertBuf *vbo = mb_geom->vbo[MB_NEXT];
- int attrib_id = GPU_vertformat_attr_id_get(&vbo->format, "nxt");
- GPU_vertformat_attr_rename(&vbo->format, attrib_id, "prv");
+ GPUVertFormat *format = (GPUVertFormat *)GPU_vertbuf_get_format(vbo);
+ int attrib_id = GPU_vertformat_attr_id_get(format, "nxt");
+ GPU_vertformat_attr_rename(format, attrib_id, "prv");
}
break;
diff --git a/source/blender/draw/engines/overlay/overlay_motion_path.c b/source/blender/draw/engines/overlay/overlay_motion_path.c
index 0e5a52702fe..48b7b53a5ba 100644
--- a/source/blender/draw/engines/overlay/overlay_motion_path.c
+++ b/source/blender/draw/engines/overlay/overlay_motion_path.c
@@ -68,7 +68,9 @@ static GPUVertBuf *mpath_vbo_get(bMotionPath *mpath)
mpath->points_vbo = GPU_vertbuf_create_with_format(&format);
GPU_vertbuf_data_alloc(mpath->points_vbo, mpath->length);
/* meh... a useless memcpy. */
- memcpy(mpath->points_vbo->data, mpath->points, sizeof(bMotionPathVert) * mpath->length);
+ memcpy(GPU_vertbuf_get_data(mpath->points_vbo),
+ mpath->points,
+ sizeof(bMotionPathVert) * mpath->length);
}
return mpath->points_vbo;
}
diff --git a/source/blender/draw/intern/draw_cache_extract_mesh.c b/source/blender/draw/intern/draw_cache_extract_mesh.c
index 528a6eec69e..9f4ae8fbfbf 100644
--- a/source/blender/draw/intern/draw_cache_extract_mesh.c
+++ b/source/blender/draw/intern/draw_cache_extract_mesh.c
@@ -1923,7 +1923,7 @@ static void *extract_pos_nor_init(const MeshRenderData *mr,
/* Pack normals per vert, reduce amount of computation. */
size_t packed_nor_len = sizeof(GPUPackedNormal) * mr->vert_len;
MeshExtract_PosNor_Data *data = MEM_mallocN(sizeof(*data) + packed_nor_len, __func__);
- data->vbo_data = (PosNorLoop *)vbo->data;
+ data->vbo_data = (PosNorLoop *)GPU_vertbuf_get_data(vbo);
/* Quicker than doing it for each loop. */
if (mr->extract_type == MR_EXTRACT_BMESH) {
@@ -2096,7 +2096,7 @@ static void *extract_lnor_hq_init(const MeshRenderData *mr,
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, mr->loop_len);
- return vbo->data;
+ return GPU_vertbuf_get_data(vbo);
}
static void extract_lnor_hq_iter_poly_bm(const MeshRenderData *mr,
@@ -2184,7 +2184,7 @@ static void *extract_lnor_init(const MeshRenderData *mr,
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, mr->loop_len);
- return vbo->data;
+ return GPU_vertbuf_get_data(vbo);
}
static void extract_lnor_iter_poly_bm(const MeshRenderData *mr,
@@ -2319,7 +2319,7 @@ static void *extract_uv_init(const MeshRenderData *mr, struct MeshBatchCache *ca
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, v_len);
- float(*uv_data)[2] = (float(*)[2])vbo->data;
+ float(*uv_data)[2] = (float(*)[2])GPU_vertbuf_get_data(vbo);
for (int i = 0; i < MAX_MTFACE; i++) {
if (uv_layers & (1 << i)) {
if (mr->extract_type == MR_EXTRACT_BMESH) {
@@ -2487,7 +2487,7 @@ static void extract_tan_ex(const MeshRenderData *mr,
GPU_vertbuf_data_alloc(vbo, v_len);
if (do_hq) {
- short(*tan_data)[4] = (short(*)[4])vbo->data;
+ short(*tan_data)[4] = (short(*)[4])GPU_vertbuf_get_data(vbo);
for (int i = 0; i < tan_len; i++) {
const char *name = tangent_names[i];
float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_named(
@@ -2508,7 +2508,7 @@ static void extract_tan_ex(const MeshRenderData *mr,
}
}
else {
- GPUPackedNormal *tan_data = (GPUPackedNormal *)vbo->data;
+ GPUPackedNormal *tan_data = (GPUPackedNormal *)GPU_vertbuf_get_data(vbo);
for (int i = 0; i < tan_len; i++) {
const char *name = tangent_names[i];
float(*layer_data)[4] = (float(*)[4])CustomData_get_layer_named(
@@ -2639,7 +2639,7 @@ static void *extract_vcol_init(const MeshRenderData *mr, struct MeshBatchCache *
ushort r, g, b, a;
} gpuMeshVcol;
- gpuMeshVcol *vcol_data = (gpuMeshVcol *)vbo->data;
+ gpuMeshVcol *vcol_data = (gpuMeshVcol *)GPU_vertbuf_get_data(vbo);
MLoop *loops = CustomData_get_layer(cd_ldata, CD_MLOOP);
for (int i = 0; i < MAX_MCOL; i++) {
@@ -2743,7 +2743,7 @@ static void *extract_orco_init(const MeshRenderData *mr,
CustomData *cd_vdata = &mr->me->vdata;
MeshExtract_Orco_Data *data = MEM_mallocN(sizeof(*data), __func__);
- data->vbo_data = (float(*)[4])vbo->data;
+ data->vbo_data = (float(*)[4])GPU_vertbuf_get_data(vbo);
data->orco = CustomData_get_layer(cd_vdata, CD_ORCO);
/* Make sure `orco` layer was requested only if needed! */
BLI_assert(data->orco);
@@ -2859,7 +2859,7 @@ static void *extract_edge_fac_init(const MeshRenderData *mr,
data->use_edge_render = true;
}
- data->vbo_data = vbo->data;
+ data->vbo_data = GPU_vertbuf_get_data(vbo);
return data;
}
@@ -2969,14 +2969,14 @@ static void extract_edge_fac_finish(const MeshRenderData *mr,
GPU_vertformat_attr_add(&format, "wd", GPU_COMP_F32, 1, GPU_FETCH_FLOAT);
}
/* We keep the data reference in data->vbo_data. */
- vbo->data = NULL;
+ data->vbo_data = GPU_vertbuf_steal_data(vbo);
GPU_vertbuf_clear(vbo);
int buf_len = mr->loop_len + mr->loop_loose_len;
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, buf_len);
- float *fdata = (float *)vbo->data;
+ float *fdata = (float *)GPU_vertbuf_get_data(vbo);
for (int ml_index = 0; ml_index < buf_len; ml_index++, fdata++) {
*fdata = data->vbo_data[ml_index] / 255.0f;
}
@@ -3075,7 +3075,7 @@ static void *extract_weights_init(const MeshRenderData *mr,
GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
MeshExtract_Weight_Data *data = MEM_callocN(sizeof(*data), __func__);
- data->vbo_data = (float *)vbo->data;
+ data->vbo_data = (float *)GPU_vertbuf_get_data(vbo);
data->wstate = &cache->weight_state;
if (data->wstate->defgroup_active == -1) {
@@ -3313,7 +3313,7 @@ static void *extract_edit_data_init(const MeshRenderData *mr,
GPUVertBuf *vbo = buf;
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
- return vbo->data;
+ return GPU_vertbuf_get_data(vbo);
}
static void extract_edit_data_iter_poly_bm(const MeshRenderData *mr,
@@ -3471,7 +3471,7 @@ static void *extract_edituv_data_init(const MeshRenderData *mr,
CustomData *cd_ldata = (mr->extract_type == MR_EXTRACT_BMESH) ? &mr->bm->ldata : &mr->me->ldata;
MeshExtract_EditUVData_Data *data = MEM_callocN(sizeof(*data), __func__);
- data->vbo_data = (EditLoopData *)vbo->data;
+ data->vbo_data = (EditLoopData *)GPU_vertbuf_get_data(vbo);
data->cd_ofs = CustomData_get_offset(cd_ldata, CD_MLOOPUV);
return data;
}
@@ -3635,7 +3635,7 @@ static void mesh_stretch_area_finish(const MeshRenderData *mr,
/* Copy face data for each loop. */
GPUVertBuf *vbo = buf;
- uint16_t *loop_stretch = (uint16_t *)vbo->data;
+ uint16_t *loop_stretch = (uint16_t *)GPU_vertbuf_get_data(vbo);
if (mr->extract_type == MR_EXTRACT_BMESH) {
BMFace *efa;
@@ -3746,7 +3746,7 @@ static void *extract_stretch_angle_init(const MeshRenderData *mr,
GPU_vertbuf_data_alloc(vbo, mr->loop_len);
MeshExtract_StretchAngle_Data *data = MEM_callocN(sizeof(*data), __func__);
- data->vbo_data = (UVStretchAngle *)vbo->data;
+ data->vbo_data = (UVStretchAngle *)GPU_vertbuf_get_data(vbo);
/* Special iterator needed to save about half of the computing cost. */
if (mr->extract_type == MR_EXTRACT_BMESH) {
@@ -4446,7 +4446,7 @@ static void extract_mesh_analysis_finish(const MeshRenderData *mr,
BLI_assert(mr->edit_bmesh);
GPUVertBuf *vbo = buf;
- float *l_weight = (float *)vbo->data;
+ float *l_weight = (float *)GPU_vertbuf_get_data(vbo);
switch (mr->toolsettings->statvis.type) {
case SCE_STATVIS_OVERHANG:
@@ -4493,7 +4493,7 @@ static void *extract_fdots_pos_init(const MeshRenderData *mr,
GPUVertBuf *vbo = buf;
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, mr->poly_len);
- return vbo->data;
+ return GPU_vertbuf_get_data(vbo);
}
static void extract_fdots_pos_iter_poly_bm(const MeshRenderData *mr,
@@ -4592,7 +4592,7 @@ static void extract_fdots_nor_finish(const MeshRenderData *mr,
{
static float invalid_normal[3] = {0.0f, 0.0f, 0.0f};
GPUVertBuf *vbo = buf;
- GPUPackedNormal *nor = (GPUPackedNormal *)vbo->data;
+ GPUPackedNormal *nor = (GPUPackedNormal *)GPU_vertbuf_get_data(vbo);
BMFace *efa;
/* Quicker than doing it for each loop. */
@@ -4669,11 +4669,11 @@ static void *extract_fdots_uv_init(const MeshRenderData *mr,
if (!mr->use_subsurf_fdots) {
/* Clear so we can accumulate on it. */
- memset(vbo->data, 0x0, mr->poly_len * vbo->format.stride);
+ memset(GPU_vertbuf_get_data(vbo), 0x0, mr->poly_len * GPU_vertbuf_get_format(vbo)->stride);
}
MeshExtract_FdotUV_Data *data = MEM_callocN(sizeof(*data), __func__);
- data->vbo_data = (float(*)[2])vbo->data;
+ data->vbo_data = (float(*)[2])GPU_vertbuf_get_data(vbo);
if (mr->extract_type == MR_EXTRACT_BMESH) {
data->cd_ofs = CustomData_get_offset(&mr->bm->ldata, CD_MLOOPUV);
@@ -4763,7 +4763,7 @@ static void *extract_fdots_edituv_data_init(const MeshRenderData *mr,
GPU_vertbuf_data_alloc(vbo, mr->poly_len);
MeshExtract_EditUVFdotData_Data *data = MEM_callocN(sizeof(*data), __func__);
- data->vbo_data = (EditLoopData *)vbo->data;
+ data->vbo_data = (EditLoopData *)GPU_vertbuf_get_data(vbo);
data->cd_ofs = CustomData_get_offset(&mr->bm->ldata, CD_MLOOPUV);
return data;
}
@@ -4842,7 +4842,7 @@ static void *extract_skin_roots_init(const MeshRenderData *mr,
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, mr->bm->totvert);
- SkinRootData *vbo_data = (SkinRootData *)vbo->data;
+ SkinRootData *vbo_data = (SkinRootData *)GPU_vertbuf_get_data(vbo);
int root_len = 0;
int cd_ofs = CustomData_get_offset(&mr->bm->vdata, CD_MVERT_SKIN);
@@ -4889,7 +4889,7 @@ static void *extract_select_idx_init(const MeshRenderData *mr,
GPUVertBuf *vbo = buf;
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, mr->loop_len + mr->loop_loose_len);
- return vbo->data;
+ return GPU_vertbuf_get_data(vbo);
}
/* TODO Use #glVertexID to get loop index and use the data structure on the CPU to retrieve the
@@ -5083,7 +5083,7 @@ static void *extract_select_fdot_idx_init(const MeshRenderData *mr,
GPUVertBuf *vbo = buf;
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, mr->poly_len);
- return vbo->data;
+ return GPU_vertbuf_get_data(vbo);
}
static void extract_fdot_idx_iter_poly_bm(const MeshRenderData *mr,
diff --git a/source/blender/draw/intern/draw_cache_impl_displist.c b/source/blender/draw/intern/draw_cache_impl_displist.c
index fb88945c5aa..2f7ce54aef4 100644
--- a/source/blender/draw/intern/draw_cache_impl_displist.c
+++ b/source/blender/draw/intern/draw_cache_impl_displist.c
@@ -236,8 +236,8 @@ void DRW_vertbuf_create_wiredata(GPUVertBuf *vbo, const int vert_len)
GPU_vertbuf_init_with_format(vbo, &format);
GPU_vertbuf_data_alloc(vbo, vert_len);
- if (vbo->format.stride == 1) {
- memset(vbo->data, 0xFF, (size_t)vert_len);
+ if (GPU_vertbuf_get_format(vbo)->stride == 1) {
+ memset(GPU_vertbuf_get_data(vbo), 0xFF, (size_t)vert_len);
}
else {
GPUVertBufRaw wd_step;
diff --git a/source/blender/draw/intern/draw_cache_impl_gpencil.c b/source/blender/draw/intern/draw_cache_impl_gpencil.c
index d6b0c939114..220c7041c7f 100644
--- a/source/blender/draw/intern/draw_cache_impl_gpencil.c
+++ b/source/blender/draw/intern/draw_cache_impl_gpencil.c
@@ -395,8 +395,8 @@ static void gpencil_batches_ensure(Object *ob, GpencilBatchCache *cache, int cfr
/* Add extra space at the end of the buffer because of quad load. */
GPU_vertbuf_data_alloc(cache->vbo, iter.vert_len + 2);
GPU_vertbuf_data_alloc(cache->vbo_col, iter.vert_len + 2);
- iter.verts = (gpStrokeVert *)cache->vbo->data;
- iter.cols = (gpColorVert *)cache->vbo_col->data;
+ iter.verts = (gpStrokeVert *)GPU_vertbuf_get_data(cache->vbo);
+ iter.cols = (gpColorVert *)GPU_vertbuf_get_data(cache->vbo_col);
/* Create IBO. */
GPU_indexbuf_init(&iter.ibo, GPU_PRIM_TRIS, iter.tri_len, iter.vert_len);
@@ -471,7 +471,8 @@ GPUBatch *DRW_cache_gpencil_face_wireframe_get(Object *ob)
.ibo = {0},
};
- GPU_indexbuf_init_ex(&iter.ibo, GPU_PRIM_LINE_STRIP, vbo->vertex_len, vbo->vertex_len);
+ uint vert_len = GPU_vertbuf_get_vertex_len(vbo);
+ GPU_indexbuf_init_ex(&iter.ibo, GPU_PRIM_LINE_STRIP, vert_len, vert_len);
/* IMPORTANT: Keep in sync with gpencil_edit_batches_ensure() */
bool do_onion = true;
@@ -558,8 +559,8 @@ static void gpencil_sbuffer_stroke_ensure(bGPdata *gpd, bool do_stroke, bool do_
/* Add extra space at the end (and start) of the buffer because of quad load and cyclic. */
GPU_vertbuf_data_alloc(vbo, 1 + vert_len + 1 + 2);
GPU_vertbuf_data_alloc(vbo_col, 1 + vert_len + 1 + 2);
- gpStrokeVert *verts = (gpStrokeVert *)vbo->data;
- gpColorVert *cols = (gpColorVert *)vbo_col->data;
+ gpStrokeVert *verts = (gpStrokeVert *)GPU_vertbuf_get_data(vbo);
+ gpColorVert *cols = (gpColorVert *)GPU_vertbuf_get_data(vbo_col);
/* Fill buffers with data. */
gpencil_buffer_add_stroke(verts, cols, gps);
@@ -711,7 +712,7 @@ static void gpencil_edit_batches_ensure(Object *ob, GpencilBatchCache *cache, in
/* Vertex counting has already been done for cache->vbo. */
BLI_assert(cache->vbo);
- int vert_len = cache->vbo->vertex_len;
+ int vert_len = GPU_vertbuf_get_vertex_len(cache->vbo);
gpEditIterData iter;
iter.vgindex = ob->actdef - 1;
@@ -724,7 +725,7 @@ static void gpencil_edit_batches_ensure(Object *ob, GpencilBatchCache *cache, in
cache->edit_vbo = GPU_vertbuf_create_with_format(format);
/* Add extra space at the end of the buffer because of quad load. */
GPU_vertbuf_data_alloc(cache->edit_vbo, vert_len);
- iter.verts = (gpEditVert *)cache->edit_vbo->data;
+ iter.verts = (gpEditVert *)GPU_vertbuf_get_data(cache->edit_vbo);
/* Fill buffers with data. */
BKE_gpencil_visible_stroke_iter(
diff --git a/source/blender/draw/intern/draw_cache_impl_pointcloud.c b/source/blender/draw/intern/draw_cache_impl_pointcloud.c
index 06cedb9f72c..5c25ccec314 100644
--- a/source/blender/draw/intern/draw_cache_impl_pointcloud.c
+++ b/source/blender/draw/intern/draw_cache_impl_pointcloud.c
@@ -176,7 +176,7 @@ static void pointcloud_batch_cache_ensure_pos(Object *ob, PointCloudBatchCache *
GPU_vertbuf_data_alloc(cache->pos, pointcloud->totpoint);
if (has_radius) {
- float(*vbo_data)[4] = (float(*)[4])cache->pos->data;
+ float(*vbo_data)[4] = (float(*)[4])GPU_vertbuf_get_data(cache->pos);
for (int i = 0; i < pointcloud->totpoint; i++) {
copy_v3_v3(vbo_data[i], pointcloud->co[i]);
/* TODO(fclem) remove multiplication here. Here only for keeping the size correct for now. */
diff --git a/source/blender/draw/intern/draw_cache_inline.h b/source/blender/draw/intern/draw_cache_inline.h
index 720cc31b0be..120e547bbe2 100644
--- a/source/blender/draw/intern/draw_cache_inline.h
+++ b/source/blender/draw/intern/draw_cache_inline.h
@@ -89,21 +89,12 @@ BLI_INLINE void DRW_vbo_request(GPUBatch *batch, GPUVertBuf **vbo)
*vbo = GPU_vertbuf_create(GPU_USAGE_STATIC);
}
if (batch != NULL) {
- /* HACK set first vbo if not init. */
- if (batch->verts[0] == NULL) {
- GPU_batch_vertbuf_add(batch, *vbo);
- }
- else {
- /* HACK: bypass assert */
- int vbo_vert_len = (*vbo)->vertex_len;
- (*vbo)->vertex_len = batch->verts[0]->vertex_len;
- GPU_batch_vertbuf_add(batch, *vbo);
- (*vbo)->vertex_len = vbo_vert_len;
- }
+ /* HACK we set vbos that may not yet be valid. */
+ GPU_batch_vertbuf_add(batch, *vbo);
}
}
BLI_INLINE bool DRW_vbo_requested(GPUVertBuf *vbo)
{
- return (vbo != NULL && vbo->format.attr_len == 0);
+ return (vbo != NULL && (GPU_vertbuf_get_status(vbo) & GPU_VERTBUF_INIT) == 0);
}
diff --git a/source/blender/draw/intern/draw_instance_data.c b/source/blender/draw/intern/draw_instance_data.c
index 9d0727555b6..7a6f357cb9c 100644
--- a/source/blender/draw/intern/draw_instance_data.c
+++ b/source/blender/draw/intern/draw_instance_data.c
@@ -150,7 +150,8 @@ GPUBatch *DRW_temp_batch_instance_request(DRWInstanceDataList *idatalist,
}
GPUBatch *batch = handle->batch;
- bool instancer_compat = buf ? ((batch->inst[0] == buf) && (buf->vbo_id != 0)) :
+ bool instancer_compat = buf ? ((batch->inst[0] == buf) &&
+ (GPU_vertbuf_get_status(buf) & GPU_VERTBUF_DATA_UPLOADED)) :
((batch->inst[0] == instancer->verts[0]) &&
(batch->inst[1] == instancer->verts[1]));
bool is_compatible = (batch->prim_type == geom->prim_type) && instancer_compat &&
@@ -184,8 +185,8 @@ GPUBatch *DRW_temp_batch_request(DRWInstanceDataList *idatalist,
}
GPUBatch *batch = *batch_ptr;
- bool is_compatible = (batch->verts[0] == buf) && (buf->vbo_id != 0) &&
- (batch->prim_type == prim_type);
+ bool is_compatible = (batch->verts[0] == buf) && (batch->prim_type == prim_type) &&
+ (GPU_vertbuf_get_status(buf) & GPU_VERTBUF_DATA_UPLOADED);
if (!is_compatible) {
GPU_batch_clear(batch);
GPU_batch_init(batch, prim_type, buf, NULL);
@@ -220,7 +221,7 @@ void DRW_instance_buffer_finish(DRWInstanceDataList *idatalist)
if (handle->vert_len != NULL) {
uint vert_len = *(handle->vert_len);
uint target_buf_size = ((vert_len / DRW_BUFFER_VERTS_CHUNK) + 1) * DRW_BUFFER_VERTS_CHUNK;
- if (target_buf_size < handle->buf->vertex_alloc) {
+ if (target_buf_size < GPU_vertbuf_get_vertex_alloc(handle->buf)) {
GPU_vertbuf_data_resize(handle->buf, target_buf_size);
}
GPU_vertbuf_data_len_set(handle->buf, vert_len);
diff --git a/source/blender/draw/intern/draw_manager_data.c b/source/blender/draw/intern/draw_manager_data.c
index 09448f8783b..d92b2fb00d4 100644
--- a/source/blender/draw/intern/draw_manager_data.c
+++ b/source/blender/draw/intern/draw_manager_data.c
@@ -1115,7 +1115,7 @@ DRWCallBuffer *DRW_shgroup_call_buffer_instance(DRWShadingGroup *shgroup,
void DRW_buffer_add_entry_struct(DRWCallBuffer *callbuf, const void *data)
{
GPUVertBuf *buf = callbuf->buf;
- const bool resize = (callbuf->count == buf->vertex_alloc);
+ const bool resize = (callbuf->count == GPU_vertbuf_get_vertex_alloc(buf));
if (UNLIKELY(resize)) {
GPU_vertbuf_data_resize(buf, callbuf->count + DRW_BUFFER_VERTS_CHUNK);
@@ -1136,9 +1136,9 @@ void DRW_buffer_add_entry_struct(DRWCallBuffer *callbuf, const void *data)
void DRW_buffer_add_entry_array(DRWCallBuffer *callbuf, const void *attr[], uint attr_len)
{
GPUVertBuf *buf = callbuf->buf;
- const bool resize = (callbuf->count == buf->vertex_alloc);
+ const bool resize = (callbuf->count == GPU_vertbuf_get_vertex_alloc(buf));
- BLI_assert(attr_len == buf->format.attr_len);
+ BLI_assert(attr_len == GPU_vertbuf_get_format(buf)->attr_len);
UNUSED_VARS_NDEBUG(attr_len);
if (UNLIKELY(resize)) {
diff --git a/source/blender/draw/intern/draw_manager_exec.c b/source/blender/draw/intern/draw_manager_exec.c
index 1d15548e1ed..58464c0a15a 100644
--- a/source/blender/draw/intern/draw_manager_exec.c
+++ b/source/blender/draw/intern/draw_manager_exec.c
@@ -646,9 +646,10 @@ BLI_INLINE void draw_select_buffer(DRWShadingGroup *shgroup,
const bool is_instancing = (batch->inst[0] != NULL);
int start = 0;
int count = 1;
- int tot = is_instancing ? batch->inst[0]->vertex_len : batch->verts[0]->vertex_len;
+ int tot = is_instancing ? GPU_vertbuf_get_vertex_len(batch->inst[0]) :
+ GPU_vertbuf_get_vertex_len(batch->verts[0]);
/* Hack : get "vbo" data without actually drawing. */
- int *select_id = (void *)state->select_buf->data;
+ int *select_id = (void *)GPU_vertbuf_get_data(state->select_buf);
/* Batching */
if (!is_instancing) {