This repository has been archived on 2023-10-09. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
blender-archive/source/blender/draw/intern/draw_attributes.h
Joseph Eagar 65900d88a8 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
2022-09-28 14:51:23 -07:00

80 lines
2.2 KiB
C++

/* SPDX-License-Identifier: GPL-2.0-or-later
* Copyright 2022 Blender Foundation. All rights reserved. */
/** \file
* \ingroup draw
*
* \brief Utilities for rendering attributes.
*/
#pragma once
#include "DNA_customdata_types.h"
#include "DNA_meshdata_types.h"
#include "BKE_attribute.h"
#include "BLI_sys_types.h"
#include "BLI_threads.h"
#include "BLI_utildefines.h"
#include "GPU_shader.h"
#include "GPU_vertex_format.h"
#ifdef __cplusplus
extern "C" {
#endif
typedef struct DRW_AttributeRequest {
eCustomDataType cd_type;
int layer_index;
eAttrDomain domain;
char attribute_name[64];
} DRW_AttributeRequest;
typedef struct DRW_Attributes {
DRW_AttributeRequest requests[GPU_MAX_ATTR];
int num_requests;
} DRW_Attributes;
typedef struct DRW_MeshCDMask {
uint32_t uv : 8;
uint32_t tan : 8;
uint32_t orco : 1;
uint32_t tan_orco : 1;
uint32_t sculpt_overlays : 1;
/**
* Edit uv layer is from the base edit mesh as modifiers could remove it. (see T68857)
*/
uint32_t edit_uv : 1;
} DRW_MeshCDMask;
/* Keep `DRW_MeshCDMask` struct within a `uint32_t`.
* bit-wise and atomic operations are used to compare and update the struct.
* See `mesh_cd_layers_type_*` functions. */
BLI_STATIC_ASSERT(sizeof(DRW_MeshCDMask) <= sizeof(uint32_t), "DRW_MeshCDMask exceeds 32 bits")
void drw_attributes_clear(DRW_Attributes *attributes);
void drw_attributes_merge(DRW_Attributes *dst,
const DRW_Attributes *src,
ThreadMutex *render_mutex);
/* Return true if all requests in b are in a. */
bool drw_attributes_overlap(const DRW_Attributes *a, const DRW_Attributes *b);
DRW_AttributeRequest *drw_attributes_add_request(DRW_Attributes *attrs,
const char *name,
eCustomDataType data_type,
int layer_index,
eAttrDomain domain);
bool drw_custom_data_match_attribute(const CustomData *custom_data,
const char *name,
int *r_layer_index,
eCustomDataType *r_type);
#ifdef __cplusplus
}
#endif