diff options
author | Joseph Eagar <joeedh@gmail.com> | 2022-09-29 00:51:23 +0300 |
---|---|---|
committer | Joseph Eagar <joeedh@gmail.com> | 2022-09-29 00:51:23 +0300 |
commit | 65900d88a8317c207885ae4a3993272112114f36 (patch) | |
tree | f5ec12e068ab8f2ee36af384060e59de72ecc08f /source/blender/draw/DRW_pbvh.h | |
parent | a790873d2a811e0c244266b090d92470cf378ef2 (diff) |
Sculpt: Rewrite PBVH draw
Rewrite PBVH draw to allocate attributes into individual VBOs.
The old system tried to create a single VBO that could feed
every open viewport. This required uploading every color and
UV attribute to the viewport whether needed or not, often exceeding
the VBO limit.
This new system creates one VBO per attribute. Each attribute layout is
given its own GPU batch which is cached inside the owning PBVH node.
Notes:
* This is a full C++ rewrite. The old code is still there; ripping it out
can happen later.
* PBVH nodes now have a collection of batches, PBVHBatches, that keeps
track of all the batches inside the node.
* Batches are built exclusively from a list of attributes.
* Each attribute has its own VBO.
* Overlays, workbench and EEVEE can all have different attribute
layouts, each of which will get its own batch.
Reviewed by: Clement Foucault
Differential Revision: https://developer.blender.org/D15428
Ref D15428
Diffstat (limited to 'source/blender/draw/DRW_pbvh.h')
-rw-r--r-- | source/blender/draw/DRW_pbvh.h | 98 |
1 files changed, 98 insertions, 0 deletions
diff --git a/source/blender/draw/DRW_pbvh.h b/source/blender/draw/DRW_pbvh.h new file mode 100644 index 00000000000..ffd4b92d87b --- /dev/null +++ b/source/blender/draw/DRW_pbvh.h @@ -0,0 +1,98 @@ +/* SPDX-License-Identifier: GPL-2.0-or-later + * Copyright 2022 Blender Foundation. */ + +/** \file + * \ingroup draw + */ + +#pragma once + +/* Needed for BKE_ccg.h. */ +#include "BLI_assert.h" +#include "BLI_bitmap.h" + +#include "BKE_ccg.h" + +#ifdef __cplusplus +extern "C" { +#endif + +struct GPUViewport; +struct PBVHAttrReq; +struct GPUBatch; +struct PBVHNode; +struct GSet; +struct DMFlagMat; +struct Object; +struct Mesh; +struct MLoopTri; +struct CustomData; +struct MVert; +struct MEdge; +struct MLoop; +struct MPoly; +struct SubdivCCG; +struct BMesh; + +typedef struct PBVHBatches PBVHBatches; + +typedef struct PBVH_GPU_Args { + int pbvh_type; + + struct BMesh *bm; + const struct Mesh *me; + const struct MVert *mvert; + const struct MLoop *mloop; + const struct MPoly *mpoly; + int mesh_verts_num, mesh_faces_num, mesh_grids_num; + struct CustomData *vdata, *ldata, *pdata; + const float (*vert_normals)[3]; + + int face_sets_color_seed, face_sets_color_default; + int *face_sets; /* for PBVH_FACES and PBVH_GRIDS */ + + struct SubdivCCG *subdiv_ccg; + const struct DMFlagMat *grid_flag_mats; + const int *grid_indices; + CCGKey ccg_key; + CCGElem **grids; + void **gridfaces; + BLI_bitmap **grid_hidden; + + int *prim_indices; + int totprim; + + bool *hide_poly; + + int node_verts_num; + + const struct MLoopTri *mlooptri; + struct PBVHNode *node; + + /* BMesh. */ + struct GSet *bm_unique_vert, *bm_other_verts, *bm_faces; + int cd_mask_layer; +} PBVH_GPU_Args; + +typedef struct PBVHGPUFormat PBVHGPUFormat; + +void DRW_pbvh_node_update(PBVHBatches *batches, PBVH_GPU_Args *args); +void DRW_pbvh_update_pre(PBVHBatches *batches, PBVH_GPU_Args *args); + +void DRW_pbvh_node_gpu_flush(PBVHBatches *batches); +struct PBVHBatches *DRW_pbvh_node_create(PBVH_GPU_Args *args); +void DRW_pbvh_node_free(PBVHBatches *batches); +struct GPUBatch *DRW_pbvh_tris_get(PBVHBatches *batches, + struct PBVHAttrReq *attrs, + int attrs_num, + PBVH_GPU_Args *args, + int *r_prim_count); +struct GPUBatch *DRW_pbvh_lines_get(struct PBVHBatches *batches, + struct PBVHAttrReq *attrs, + int attrs_num, + PBVH_GPU_Args *args, + int *r_prim_count); + +#ifdef __cplusplus +} +#endif |