Cleanup: Move remaining draw geometry extraction code to C++ namespace

Overall the transition to C++ in the draw module is awkwardly half
complete, but moving more code to a C++ namespace makes cleaning up
this code in other ways much easier, and the next C++ cleanup steps
are clear anyway.
This commit is contained in:
Hans Goudey 2024-01-05 12:20:30 -05:00
parent 5b55c1dc10
commit ecc3656f72
84 changed files with 443 additions and 342 deletions

@ -172,11 +172,16 @@ void DRW_xr_drawing_end(void);
/* For garbage collection */
void DRW_cache_free_old_batches(struct Main *bmain);
namespace blender::draw {
void DRW_cache_free_old_subdiv(void);
/* For the OpenGL evaluators and garbage collected subdivision data. */
void DRW_subdiv_free(void);
} // namespace blender::draw
/* Never use this. Only for closing blender. */
void DRW_gpu_context_enable_ex(bool restore);
void DRW_gpu_context_disable_ex(bool restore);

@ -154,6 +154,7 @@ static void basic_cache_populate_particles(void *vedata, Object *ob)
static void basic_cache_populate(void *vedata, Object *ob)
{
using namespace blender::draw;
BASIC_StorageList *stl = ((BASIC_Data *)vedata)->stl;
/* TODO(fclem): fix selection of smoke domains. */

@ -250,6 +250,7 @@ void EEVEE_cryptomatte_object_curves_cache_populate(EEVEE_Data *vedata,
EEVEE_ViewLayerData *sldata,
Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_CURVES);
Material *material = BKE_object_material_get_eval(ob, CURVES_MATERIAL_NR);
DRWShadingGroup *grp = eevee_cryptomatte_shading_group_create(

@ -926,6 +926,7 @@ static void eevee_lightbake_delete_resources(EEVEE_LightBake *lbake)
/* Cache as in draw cache not light cache. */
static void eevee_lightbake_cache_create(EEVEE_Data *vedata, EEVEE_LightBake *lbake)
{
using namespace blender::draw;
EEVEE_TextureList *txl = vedata->txl;
EEVEE_StorageList *stl = vedata->stl;
EEVEE_FramebufferList *fbl = vedata->fbl;

@ -971,6 +971,7 @@ void EEVEE_object_curves_cache_populate(EEVEE_Data *vedata,
Object *ob,
bool *cast_shadow)
{
using namespace blender::draw;
EeveeMaterialCache matcache = eevee_material_cache_get(
vedata, sldata, ob, CURVES_MATERIAL_NR - 1, true);

@ -278,6 +278,7 @@ void EEVEE_motion_blur_curves_cache_populate(EEVEE_ViewLayerData * /*sldata*/,
EEVEE_Data *vedata,
Object *ob)
{
using namespace blender::draw;
EEVEE_PassList *psl = vedata->psl;
EEVEE_StorageList *stl = vedata->stl;
EEVEE_EffectsInfo *effects = stl->effects;
@ -433,6 +434,7 @@ static void motion_blur_remove_vbo_reference_from_batch(GPUBatch *batch,
void EEVEE_motion_blur_cache_finish(EEVEE_Data *vedata)
{
using namespace blender::draw;
EEVEE_StorageList *stl = vedata->stl;
EEVEE_EffectsInfo *effects = stl->effects;
GHashIterator ghi;

@ -538,6 +538,7 @@ static void eevee_render_draw_background(EEVEE_Data *vedata)
void EEVEE_render_draw(EEVEE_Data *vedata, RenderEngine *engine, RenderLayer *rl, const rcti *rect)
{
using namespace blender::draw;
const char *viewname = RE_GetActiveRenderView(engine->re);
EEVEE_PassList *psl = vedata->psl;
EEVEE_StorageList *stl = vedata->stl;

@ -173,6 +173,7 @@ void GPENCIL_engine_init(void *ved)
void GPENCIL_cache_init(void *ved)
{
using namespace blender::draw;
GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
GPENCIL_PassList *psl = vedata->psl;
GPENCIL_TextureList *txl = vedata->txl;
@ -465,6 +466,7 @@ static void gpencil_stroke_cache_populate(bGPDlayer *gpl,
bGPDstroke *gps,
void *thunk)
{
using namespace blender::draw;
gpIterPopulateData *iter = (gpIterPopulateData *)thunk;
bGPdata *gpd = static_cast<bGPdata *>(iter->ob->data);
@ -750,6 +752,7 @@ void GPENCIL_cache_finish(void *ved)
static void GPENCIL_draw_scene_depth_only(void *ved)
{
using namespace blender::draw;
GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
GPENCIL_PrivateData *pd = vedata->stl->pd;
DefaultFramebufferList *dfbl = DRW_viewport_framebuffer_list_get();
@ -917,6 +920,7 @@ static void GPENCIL_fast_draw_end(GPENCIL_Data *vedata)
void GPENCIL_draw_scene(void *ved)
{
using namespace blender::draw;
GPENCIL_Data *vedata = (GPENCIL_Data *)ved;
GPENCIL_PrivateData *pd = vedata->stl->pd;
GPENCIL_FramebufferList *fbl = vedata->fbl;

@ -849,6 +849,7 @@ static void drw_shgroup_bone_custom_solid_mesh(const ArmatureDrawContext *ctx,
const float outline_color[4],
Object *custom)
{
using namespace blender::draw;
/* TODO(fclem): arg... less than ideal but we never iter on this object
* to assure batch cache is valid. */
DRW_mesh_batch_cache_validate(custom, mesh);
@ -893,6 +894,7 @@ static void drw_shgroup_bone_custom_mesh_wire(const ArmatureDrawContext *ctx,
const float color[4],
Object *custom)
{
using namespace blender::draw;
/* TODO(fclem): arg... less than ideal but we never iter on this object
* to assure batch cache is valid. */
DRW_mesh_batch_cache_validate(custom, mesh);
@ -917,6 +919,7 @@ static void drw_shgroup_custom_bone_curve(const ArmatureDrawContext *ctx,
const float outline_color[4],
Object *custom)
{
using namespace blender::draw;
/* TODO(fclem): arg... less than ideal but we never iter on this object
* to assure batch cache is valid. */
DRW_curve_batch_cache_validate(curve);

@ -67,6 +67,7 @@ void OVERLAY_edit_curves_cache_init(OVERLAY_Data *vedata)
static void overlay_edit_curves_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob, bool in_front)
{
using namespace blender::draw;
Curves *curves = static_cast<Curves *>(ob->data);
if (pd->edit_curves.do_points) {

@ -42,6 +42,7 @@ void OVERLAY_edit_mesh_init(OVERLAY_Data *vedata)
void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
{
using namespace blender::draw;
OVERLAY_TextureList *txl = vedata->txl;
OVERLAY_PassList *psl = vedata->psl;
OVERLAY_PrivateData *pd = vedata->stl->pd;
@ -226,6 +227,7 @@ void OVERLAY_edit_mesh_cache_init(OVERLAY_Data *vedata)
static void overlay_edit_mesh_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob, bool in_front)
{
using namespace blender::draw;
GPUBatch *geom_tris, *geom_verts, *geom_edges, *geom_fcenter, *skin_roots, *circle;
DRWShadingGroup *vert_shgrp, *edge_shgrp, *fdot_shgrp, *face_shgrp, *skin_roots_shgrp;
@ -273,6 +275,7 @@ static void overlay_edit_mesh_add_ob_to_pass(OVERLAY_PrivateData *pd, Object *ob
void OVERLAY_edit_mesh_cache_populate(OVERLAY_Data *vedata, Object *ob)
{
using namespace blender::draw;
OVERLAY_PrivateData *pd = vedata->stl->pd;
GPUBatch *geom = nullptr;

@ -181,13 +181,14 @@ void OVERLAY_edit_uv_init(OVERLAY_Data *vedata)
void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
{
using namespace blender::draw;
OVERLAY_StorageList *stl = vedata->stl;
OVERLAY_PassList *psl = vedata->psl;
OVERLAY_PrivateData *pd = stl->pd;
const DRWContextState *draw_ctx = DRW_context_state_get();
SpaceImage *sima = (SpaceImage *)draw_ctx->space_data;
Image *image = sima->image;
::Image *image = sima->image;
const Scene *scene = draw_ctx->scene;
ToolSettings *ts = scene->toolsettings;
@ -350,7 +351,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
if (pd->edit_uv.do_stencil_overlay) {
const Brush *brush = BKE_paint_brush(&ts->imapaint.paint);
Image *stencil_image = brush->clone.image;
::Image *stencil_image = brush->clone.image;
ImBuf *stencil_ibuf = BKE_image_acquire_ibuf(
stencil_image, nullptr, &pd->edit_uv.stencil_lock);
@ -435,6 +436,7 @@ void OVERLAY_edit_uv_cache_init(OVERLAY_Data *vedata)
static void overlay_edit_uv_cache_populate(OVERLAY_Data *vedata, Object *ob)
{
using namespace blender::draw;
if (!(DRW_object_visibility_in_active_context(ob) & OB_VISIBLE_SELF)) {
return;
}

@ -324,6 +324,7 @@ void OVERLAY_gpencil_legacy_cache_init(OVERLAY_Data *vedata)
static void OVERLAY_edit_gpencil_cache_populate(OVERLAY_Data *vedata, Object *ob)
{
using namespace blender::draw;
OVERLAY_PrivateData *pd = vedata->stl->pd;
bGPdata *gpd = (bGPdata *)ob->data;
const DRWContextState *draw_ctx = DRW_context_state_get();

@ -50,6 +50,7 @@ void OVERLAY_edit_grease_pencil_cache_init(OVERLAY_Data *vedata)
void OVERLAY_edit_grease_pencil_cache_populate(OVERLAY_Data *vedata, Object *ob)
{
using namespace blender::draw;
OVERLAY_PrivateData *pd = vedata->stl->pd;
const DRWContextState *draw_ctx = DRW_context_state_get();

@ -187,6 +187,7 @@ static void gpencil_layer_cache_populate(bGPDlayer *gpl,
bGPDstroke * /*gps*/,
void *thunk)
{
using namespace blender::draw;
iterData *iter = (iterData *)thunk;
bGPdata *gpd = (bGPdata *)iter->ob->data;
@ -216,6 +217,7 @@ static void gpencil_stroke_cache_populate(bGPDlayer * /*gpl*/,
bGPDstroke *gps,
void *thunk)
{
using namespace blender::draw;
iterData *iter = (iterData *)thunk;
MaterialGPencilStyle *gp_style = BKE_gpencil_material_settings(iter->ob, gps->mat_nr + 1);
@ -273,6 +275,7 @@ static void OVERLAY_outline_gpencil(OVERLAY_PrivateData *pd, Object *ob)
static void OVERLAY_outline_volume(OVERLAY_PrivateData *pd, Object *ob)
{
using namespace blender::draw;
GPUBatch *geom = DRW_cache_volume_selection_surface_get(ob);
if (geom == nullptr) {
return;
@ -284,12 +287,14 @@ static void OVERLAY_outline_volume(OVERLAY_PrivateData *pd, Object *ob)
static void OVERLAY_outline_curves(OVERLAY_PrivateData *pd, Object *ob)
{
using namespace blender::draw;
DRWShadingGroup *shgroup = pd->outlines_curves_grp;
DRW_shgroup_curves_create_sub(ob, shgroup, nullptr);
}
static void OVERLAY_outline_pointcloud(OVERLAY_PrivateData *pd, Object *ob)
{
using namespace blender::draw;
if (pd->wireframe_mode) {
/* Looks bad in this case. Could be relaxed if we draw a
* wireframe of some sort in the future. */

@ -33,6 +33,7 @@ void OVERLAY_sculpt_cache_init(OVERLAY_Data *vedata)
void OVERLAY_sculpt_cache_populate(OVERLAY_Data *vedata, Object *ob)
{
using namespace blender::draw;
OVERLAY_PrivateData *pd = vedata->stl->pd;
const DRWContextState *draw_ctx = DRW_context_state_get();
GPUBatch *sculpt_overlays;

@ -60,6 +60,7 @@ static bool everything_selected(const Curves &curves_id)
static void populate_selection_overlay(OVERLAY_Data *vedata, Object *object)
{
using namespace blender::draw;
OVERLAY_PrivateData *pd = vedata->stl->pd;
Curves *curves = static_cast<Curves *>(object->data);
@ -89,6 +90,7 @@ static void populate_selection_overlay(OVERLAY_Data *vedata, Object *object)
static void populate_edit_overlay(OVERLAY_Data *vedata, Object *object)
{
using namespace blender::draw;
OVERLAY_PrivateData *pd = vedata->stl->pd;
Curves *curves = static_cast<Curves *>(object->data);

@ -56,6 +56,7 @@ static void populate_cache_for_instance(Object &object,
{
using namespace blender;
using namespace blender::bke;
using namespace blender::draw;
const GeometrySet &base_geometry = *dupli_object.preview_base_geometry;
const InstancesComponent &instances = *base_geometry.get_component<InstancesComponent>();
@ -108,6 +109,7 @@ static void populate_cache_for_geometry(Object &object,
{
using namespace blender;
using namespace blender::bke;
using namespace blender::draw;
switch (object.type) {
case OB_MESH: {

@ -34,6 +34,7 @@ void OVERLAY_volume_cache_init(OVERLAY_Data *vedata)
void OVERLAY_volume_cache_populate(OVERLAY_Data *vedata, Object *ob)
{
using namespace blender::draw;
OVERLAY_PrivateData *pd = vedata->stl->pd;
const bool is_select = DRW_state_is_select();

@ -77,6 +77,7 @@ static void draw_select_id_edit_mesh(SELECTID_StorageList *stl,
uint *r_edge_offset,
uint *r_face_offset)
{
using namespace blender::draw;
Mesh *mesh = static_cast<Mesh *>(ob->data);
BMEditMesh *em = mesh->edit_mesh;
@ -142,6 +143,7 @@ static void draw_select_id_mesh(SELECTID_StorageList *stl,
uint *r_edge_offset,
uint *r_face_offset)
{
using namespace blender::draw;
Mesh *mesh = static_cast<Mesh *>(ob->data);
GPUBatch *geom_faces = DRW_mesh_batch_cache_get_triangles_with_select_id(mesh);

@ -192,6 +192,7 @@ static void select_cache_init(void *vedata)
static void select_cache_populate(void *vedata, Object *ob)
{
using namespace blender::draw;
SELECTID_StorageList *stl = ((SELECTID_Data *)vedata)->stl;
SELECTID_ObjectData *sel_data = (SELECTID_ObjectData *)DRW_drawdata_get(
&ob->id, &draw_engine_select_type);

@ -722,6 +722,7 @@ static void workbench_render_to_image(void *vedata,
RenderLayer *layer,
const rcti *rect)
{
using namespace blender::draw;
if (!workbench_render_framebuffers_init()) {
RE_engine_report(engine, RPT_ERROR, "Failed to allocate GPU buffers");
return;

@ -71,6 +71,10 @@ struct ParticleSystem;
struct RenderEngineType;
struct bContext;
struct rcti;
namespace blender::draw {
struct DRW_Attributes;
struct DRW_MeshCDMask;
} // namespace blender::draw
typedef struct DRWCallBuffer DRWCallBuffer;
typedef struct DRWInterface DRWInterface;
@ -1005,13 +1009,10 @@ typedef struct DRWContextState {
const DRWContextState *DRW_context_state_get(void);
struct DRW_Attributes;
struct DRW_MeshCDMask;
void DRW_mesh_batch_cache_get_attributes(struct Object *object,
struct Mesh *mesh,
struct DRW_Attributes **r_attrs,
struct DRW_MeshCDMask **r_cd_needed);
blender::draw::DRW_Attributes **r_attrs,
blender::draw::DRW_MeshCDMask **r_cd_needed);
void DRW_sculpt_debug_cb(
PBVHNode *node, void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag);

@ -9,6 +9,8 @@
#include "draw_attributes.hh"
namespace blender::draw {
/* Return true if the given DRW_AttributeRequest is already in the requests. */
static bool drw_attributes_has_request(const DRW_Attributes *requests,
const DRW_AttributeRequest &req)
@ -115,3 +117,5 @@ bool drw_custom_data_match_attribute(const CustomData *custom_data,
return false;
}
} // namespace blender::draw

@ -22,6 +22,8 @@ namespace blender::bke {
enum class AttrDomain : int8_t;
}
namespace blender::draw {
struct DRW_AttributeRequest {
eCustomDataType cd_type;
int layer_index;
@ -70,3 +72,5 @@ bool drw_custom_data_match_attribute(const CustomData *custom_data,
const char *name,
int *r_layer_index,
eCustomDataType *r_type);
} // namespace blender::draw

@ -799,6 +799,8 @@ GPUBatch *DRW_cache_normal_arrow_get()
return SHC.drw_normal_arrow;
}
namespace blender::draw {
void DRW_vertbuf_create_wiredata(GPUVertBuf *vbo, const int vert_len)
{
static GPUVertFormat format = {0};
@ -832,6 +834,8 @@ void DRW_vertbuf_create_wiredata(GPUVertBuf *vbo, const int vert_len)
}
}
} // namespace blender::draw
/** \} */
/* -------------------------------------------------------------------- */
@ -889,6 +893,7 @@ GPUBatch *DRW_cache_object_edge_detection_get(Object *ob, bool *r_is_manifold)
GPUBatch *DRW_cache_object_face_wireframe_get(Object *ob)
{
using namespace blender::draw;
switch (ob->type) {
case OB_MESH:
return DRW_cache_mesh_face_wireframe_get(ob);
@ -925,6 +930,7 @@ GPUBatch *DRW_cache_object_surface_get(Object *ob)
GPUVertBuf *DRW_cache_object_pos_vertbuf_get(Object *ob)
{
using namespace blender::draw;
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(ob);
short type = (mesh != nullptr) ? short(OB_MESH) : ob->type;
@ -939,6 +945,7 @@ GPUVertBuf *DRW_cache_object_pos_vertbuf_get(Object *ob)
int DRW_cache_object_material_count_get(const Object *ob)
{
using namespace blender::draw;
short type = ob->type;
Mesh *mesh = BKE_object_get_evaluated_mesh_no_subsurf(ob);
@ -2877,36 +2884,42 @@ GPUBatch *DRW_cache_camera_distances_get()
GPUBatch *DRW_cache_mesh_all_verts_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_all_verts(static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_all_edges_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_all_edges(static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_loose_edges_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_loose_edges(static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_edge_detection_get(Object *ob, bool *r_is_manifold)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_edge_detection(static_cast<Mesh *>(ob->data), r_is_manifold);
}
GPUBatch *DRW_cache_mesh_surface_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface(static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_surface_edges_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_edges(ob, static_cast<Mesh *>(ob->data));
}
@ -2915,6 +2928,7 @@ GPUBatch **DRW_cache_mesh_surface_shaded_get(Object *ob,
GPUMaterial **gpumat_array,
uint gpumat_array_len)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_shaded(
ob, static_cast<Mesh *>(ob->data), gpumat_array, gpumat_array_len);
@ -2922,48 +2936,56 @@ GPUBatch **DRW_cache_mesh_surface_shaded_get(Object *ob,
GPUBatch **DRW_cache_mesh_surface_texpaint_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_texpaint(ob, static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_surface_texpaint_single_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_texpaint_single(ob, static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_surface_vertpaint_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_vertpaint(ob, static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_surface_sculptcolors_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_sculpt(ob, static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_surface_weights_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_weights(static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_face_wireframe_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_wireframes_face(static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_surface_mesh_analysis_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_edit_mesh_analysis(static_cast<Mesh *>(ob->data));
}
GPUBatch *DRW_cache_mesh_surface_viewer_attribute_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_MESH);
return DRW_mesh_batch_cache_get_surface_viewer_attribute(static_cast<Mesh *>(ob->data));
}
@ -2976,6 +2998,7 @@ GPUBatch *DRW_cache_mesh_surface_viewer_attribute_get(Object *ob)
GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_CURVES_LEGACY);
Curve *cu = static_cast<Curve *>(ob->data);
return DRW_curve_batch_cache_get_wire_edge(cu);
@ -2983,6 +3006,7 @@ GPUBatch *DRW_cache_curve_edge_wire_get(Object *ob)
GPUBatch *DRW_cache_curve_edge_wire_viewer_attribute_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_CURVES_LEGACY);
Curve *cu = static_cast<Curve *>(ob->data);
return DRW_curve_batch_cache_get_wire_edge_viewer_attribute(cu);
@ -2990,6 +3014,7 @@ GPUBatch *DRW_cache_curve_edge_wire_viewer_attribute_get(Object *ob)
GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_CURVES_LEGACY);
Curve *cu = static_cast<Curve *>(ob->data);
return DRW_curve_batch_cache_get_normal_edge(cu);
@ -2997,6 +3022,7 @@ GPUBatch *DRW_cache_curve_edge_normal_get(Object *ob)
GPUBatch *DRW_cache_curve_edge_overlay_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF));
Curve *cu = static_cast<Curve *>(ob->data);
@ -3005,6 +3031,7 @@ GPUBatch *DRW_cache_curve_edge_overlay_get(Object *ob)
GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ELEM(ob->type, OB_CURVES_LEGACY, OB_SURF));
Curve *cu = static_cast<Curve *>(ob->data);
@ -3019,6 +3046,7 @@ GPUBatch *DRW_cache_curve_vert_overlay_get(Object *ob)
GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_FONT);
Curve *cu = static_cast<Curve *>(ob->data);
return DRW_curve_batch_cache_get_wire_edge(cu);
@ -3032,6 +3060,7 @@ GPUBatch *DRW_cache_text_edge_wire_get(Object *ob)
GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_SURF);
Curve *cu = static_cast<Curve *>(ob->data);
return DRW_curve_batch_cache_get_wire_edge(cu);
@ -3045,6 +3074,7 @@ GPUBatch *DRW_cache_surf_edge_wire_get(Object *ob)
GPUBatch *DRW_cache_lattice_verts_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_LATTICE);
Lattice *lt = static_cast<Lattice *>(ob->data);
@ -3053,6 +3083,7 @@ GPUBatch *DRW_cache_lattice_verts_get(Object *ob)
GPUBatch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_LATTICE);
Lattice *lt = static_cast<Lattice *>(ob->data);
@ -3067,6 +3098,7 @@ GPUBatch *DRW_cache_lattice_wire_get(Object *ob, bool use_weight)
GPUBatch *DRW_cache_lattice_vert_overlay_get(Object *ob)
{
using namespace blender::draw;
BLI_assert(ob->type == OB_LATTICE);
Lattice *lt = static_cast<Lattice *>(ob->data);
@ -3085,6 +3117,8 @@ GPUBatch *DRW_cache_lattice_vert_overlay_get(Object *ob)
/** \name Volume
* \{ */
namespace blender::draw {
GPUBatch *DRW_cache_volume_face_wireframe_get(Object *ob)
{
BLI_assert(ob->type == OB_VOLUME);
@ -3097,6 +3131,8 @@ GPUBatch *DRW_cache_volume_selection_surface_get(Object *ob)
return DRW_volume_batch_cache_get_selection_surface(static_cast<Volume *>(ob->data));
}
} // namespace blender::draw
/** \} */
/* -------------------------------------------------------------------- */
@ -3105,11 +3141,13 @@ GPUBatch *DRW_cache_volume_selection_surface_get(Object *ob)
GPUBatch *DRW_cache_particles_get_hair(Object *object, ParticleSystem *psys, ModifierData *md)
{
using namespace blender::draw;
return DRW_particles_batch_cache_get_hair(object, psys, md);
}
GPUBatch *DRW_cache_particles_get_dots(Object *object, ParticleSystem *psys)
{
using namespace blender::draw;
return DRW_particles_batch_cache_get_dots(object, psys);
}
@ -3118,6 +3156,7 @@ GPUBatch *DRW_cache_particles_get_edit_strands(Object *object,
PTCacheEdit *edit,
bool use_weight)
{
using namespace blender::draw;
return DRW_particles_batch_cache_get_edit_strands(object, psys, edit, use_weight);
}
@ -3125,6 +3164,7 @@ GPUBatch *DRW_cache_particles_get_edit_inner_points(Object *object,
ParticleSystem *psys,
PTCacheEdit *edit)
{
using namespace blender::draw;
return DRW_particles_batch_cache_get_edit_inner_points(object, psys, edit);
}
@ -3132,6 +3172,7 @@ GPUBatch *DRW_cache_particles_get_edit_tip_points(Object *object,
ParticleSystem *psys,
PTCacheEdit *edit)
{
using namespace blender::draw;
return DRW_particles_batch_cache_get_edit_tip_points(object, psys, edit);
}
@ -3311,6 +3352,7 @@ GPUBatch *DRW_cache_cursor_get(bool crosshair_lines)
void drw_batch_cache_validate(Object *ob)
{
using namespace blender::draw;
switch (ob->type) {
case OB_MESH:
DRW_mesh_batch_cache_validate(ob, (Mesh *)ob->data);
@ -3341,6 +3383,7 @@ void drw_batch_cache_validate(Object *ob)
void drw_batch_cache_generate_requested(Object *ob)
{
using namespace blender::draw;
const DRWContextState *draw_ctx = DRW_context_state_get();
const Scene *scene = draw_ctx->scene;
const enum eContextObjectMode mode = CTX_data_mode_enum_ex(
@ -3377,6 +3420,7 @@ void drw_batch_cache_generate_requested(Object *ob)
void drw_batch_cache_generate_requested_evaluated_mesh_or_curve(Object *ob)
{
using namespace blender::draw;
/* NOTE: Logic here is duplicated from #drw_batch_cache_generate_requested. */
const DRWContextState *draw_ctx = DRW_context_state_get();
@ -3410,6 +3454,7 @@ void drw_batch_cache_generate_requested_delayed(Object *ob)
BLI_gset_add(DST.delayed_extraction, ob);
}
namespace blender::draw {
void DRW_batch_cache_free_old(Object *ob, int ctime)
{
switch (ob->type) {
@ -3426,6 +3471,7 @@ void DRW_batch_cache_free_old(Object *ob, int ctime)
break;
}
}
} // namespace blender::draw
/** \} */

@ -247,8 +247,10 @@ typedef struct DRWVolumeGrid {
float bounds_to_texture[4][4];
} DRWVolumeGrid;
namespace blender::draw {
DRWVolumeGrid *DRW_volume_batch_cache_get_grid(struct Volume *volume,
const blender::bke::VolumeGridData *grid);
const bke::VolumeGridData *grid);
struct GPUBatch *DRW_cache_volume_face_wireframe_get(struct Object *ob);
struct GPUBatch *DRW_cache_volume_selection_surface_get(struct Object *ob);
@ -286,3 +288,4 @@ struct GPUVertBuf *DRW_cache_grease_pencil_position_buffer_get(const struct Scen
struct Object *ob);
struct GPUVertBuf *DRW_cache_grease_pencil_color_buffer_get(const struct Scene *scene,
struct Object *ob);
} // namespace blender::draw

@ -14,12 +14,15 @@
#include "draw_attributes.hh"
struct DRWSubdivCache;
struct GPUBatch;
struct GPUIndexBuf;
struct MeshRenderData;
struct TaskGraph;
namespace blender::draw {
struct MeshRenderData;
struct DRWSubdivCache;
/* Vertex Group Selection and display options */
struct DRW_MeshWeightState {
int defgroup_active;
@ -206,16 +209,16 @@ BLI_STATIC_ASSERT(MBC_BATCH_LEN < 32, "Number of batches exceeded the limit of b
struct MeshExtractLooseGeom {
/** Indices of all vertices not used by edges in the #Mesh or #BMesh. */
blender::Array<int> verts;
Array<int> verts;
/** Indices of all edges not used by faces in the #Mesh or #BMesh. */
blender::Array<int> edges;
Array<int> edges;
};
struct SortedFaceData {
/** The first triangle index for each polygon, sorted into slices by material. */
blender::Array<int> tri_first_index;
Array<int> tri_first_index;
/** The number of visible triangles assigned to each material. */
blender::Array<int> mat_tri_len;
Array<int> mat_tri_len;
/* The total number of visible triangles (a sum of the values in #mat_tri_len). */
int visible_tri_len;
};
@ -293,8 +296,6 @@ struct MeshBatchCache {
(MBC_EDITUV_FACES_STRETCH_AREA | MBC_EDITUV_FACES_STRETCH_ANGLE | MBC_EDITUV_FACES | \
MBC_EDITUV_EDGES | MBC_EDITUV_VERTS | MBC_EDITUV_FACEDOTS | MBC_WIRE_LOOPS_UVS)
namespace blender::draw {
void mesh_buffer_cache_create_requested(TaskGraph *task_graph,
MeshBatchCache &cache,
MeshBufferCache &mbc,

@ -38,6 +38,8 @@
# include "PIL_time_utildefines.h"
#endif
namespace blender::draw {
int mesh_render_mat_len_get(const Object *object, const Mesh *mesh)
{
if (mesh->edit_mesh != nullptr) {
@ -49,8 +51,6 @@ int mesh_render_mat_len_get(const Object *object, const Mesh *mesh)
return std::max<int>(1, mesh->totcol);
}
namespace blender::draw {
/* ---------------------------------------------------------------------- */
/** \name Mesh Elements Extract Struct
* \{ */

@ -35,7 +35,9 @@
/** \name Update Loose Geometry
* \{ */
static void extract_set_bits(const blender::BitSpan bits, blender::MutableSpan<int> indices)
namespace blender::draw {
static void extract_set_bits(const BitSpan bits, MutableSpan<int> indices)
{
int count = 0;
for (const int64_t i : bits.index_range()) {
@ -49,7 +51,6 @@ static void extract_set_bits(const blender::BitSpan bits, blender::MutableSpan<i
static void mesh_render_data_loose_geom_mesh(const MeshRenderData &mr, MeshBufferCache &cache)
{
using namespace blender;
const Mesh &mesh = *mr.mesh;
const bool no_loose_vert_hint = mesh.runtime->loose_verts_cache.is_cached() &&
mesh.runtime->loose_verts_cache.data().count == 0;
@ -77,7 +78,6 @@ static void mesh_render_data_loose_verts_bm(const MeshRenderData &mr,
MeshBufferCache &cache,
BMesh &bm)
{
using namespace blender;
int i;
BMIter iter;
BMVert *vert;
@ -101,7 +101,6 @@ static void mesh_render_data_loose_edges_bm(const MeshRenderData &mr,
MeshBufferCache &cache,
BMesh &bm)
{
using namespace blender;
int i;
BMIter iter;
BMEdge *edge;
@ -170,8 +169,6 @@ void mesh_render_data_update_loose_geom(MeshRenderData &mr,
* Contains face indices sorted based on their material.
* \{ */
namespace blender::draw {
static void accumululate_material_counts_bm(
const BMesh &bm, threading::EnumerableThreadSpecific<Array<int>> &all_tri_counts)
{
@ -320,14 +317,12 @@ static void mesh_render_data_faces_sorted_ensure(MeshRenderData &mr, MeshBufferC
mesh_render_data_faces_sorted_build(mr, cache);
}
} // namespace blender::draw
void mesh_render_data_update_faces_sorted(MeshRenderData &mr,
MeshBufferCache &cache,
const eMRDataType data_flag)
{
if (data_flag & MR_DATA_POLYS_SORTED) {
blender::draw::mesh_render_data_faces_sorted_ensure(mr, cache);
mesh_render_data_faces_sorted_ensure(mr, cache);
mr.face_sorted = &cache.face_sorted;
}
}
@ -450,8 +445,6 @@ static bool bm_face_is_sharp(const BMFace *const &face)
*/
static bool bm_loop_normals_required(BMesh *bm)
{
using namespace blender;
using namespace blender::bke;
if (bm->totface == 0) {
return false;
}
@ -494,7 +487,7 @@ void mesh_render_data_update_normals(MeshRenderData &mr, const eMRDataType data_
mr.face_normals = mr.mesh->face_normals();
}
if (((data_flag & MR_DATA_LOOP_NOR) && !mr.use_simplify_normals &&
mr.normals_domain == blender::bke::MeshNormalDomain::Corner) ||
mr.normals_domain == bke::MeshNormalDomain::Corner) ||
(data_flag & MR_DATA_TAN_LOOP_NOR))
{
mr.loop_normals = mr.mesh->corner_normals();
@ -556,7 +549,6 @@ MeshRenderData *mesh_render_data_create(Object *object,
const bool do_uvedit,
const ToolSettings *ts)
{
using namespace blender;
MeshRenderData *mr = MEM_new<MeshRenderData>(__func__);
mr->toolsettings = ts;
mr->mat_len = mesh_render_mat_len_get(object, mesh);
@ -577,7 +569,7 @@ MeshRenderData *mesh_render_data_create(Object *object,
mr->hide_unmapped_edges = !do_final || editmesh_eval_final == editmesh_eval_cage;
if (mr->edit_data) {
blender::bke::EditMeshData *emd = mr->edit_data;
bke::EditMeshData *emd = mr->edit_data;
if (!emd->vertexCos.is_empty()) {
BKE_editmesh_cache_ensure_vert_normals(*mr->edit_bmesh, *emd);
BKE_editmesh_cache_ensure_face_normals(*mr->edit_bmesh, *emd);
@ -718,3 +710,5 @@ void mesh_render_data_free(MeshRenderData *mr)
}
/** \} */
} // namespace blender::draw

@ -27,6 +27,8 @@ struct GreasePencil;
#include "BKE_mesh.h"
namespace blender::draw {
/* -------------------------------------------------------------------- */
/** \name Expose via BKE callbacks
* \{ */
@ -323,3 +325,5 @@ GPUBatch *DRW_particles_batch_cache_get_edit_tip_points(Object *object,
PTCacheEdit *edit);
/** \} */
} // namespace blender::draw

@ -41,12 +41,7 @@
#include "draw_cache_impl.hh" /* own include */
using blender::Array;
using blender::ColorGeometry4f;
using blender::float3;
using blender::IndexRange;
using blender::OffsetIndices;
using blender::Span;
namespace blender::draw {
/* See: edit_curve_point_vert.glsl for duplicate includes. */
#define SELECT 1
@ -102,19 +97,19 @@ static void curve_render_overlay_verts_edges_len_get(ListBase *lb,
}
}
static void curve_eval_render_wire_verts_edges_len_get(const blender::bke::CurvesGeometry &curves,
static void curve_eval_render_wire_verts_edges_len_get(const bke::CurvesGeometry &curves,
int *r_curve_len,
int *r_vert_len,
int *r_edge_len)
{
const OffsetIndices points_by_curve = curves.evaluated_points_by_curve();
const blender::VArray<bool> cyclic = curves.cyclic();
const VArray<bool> cyclic = curves.cyclic();
*r_curve_len = curves.curves_num();
*r_vert_len = points_by_curve.total_size();
*r_edge_len = 0;
for (const int i : curves.curves_range()) {
*r_edge_len += blender::bke::curves::segments_num(points_by_curve[i].size(), cyclic[i]);
*r_edge_len += bke::curves::segments_num(points_by_curve[i].size(), cyclic[i]);
}
}
@ -476,14 +471,13 @@ static void curve_create_curves_pos(CurveRenderData *rdata, GPUVertBuf *vbo_curv
GPU_vertbuf_init_with_format(vbo_curves_pos, &format);
GPU_vertbuf_data_alloc(vbo_curves_pos, vert_len);
const blender::bke::CurvesGeometry &curves = rdata->curve_eval->geometry.wrap();
const bke::CurvesGeometry &curves = rdata->curve_eval->geometry.wrap();
const Span<float3> positions = curves.evaluated_positions();
GPU_vertbuf_attr_fill(vbo_curves_pos, attr_id.pos, positions.data());
}
static void curve_create_attribute(CurveRenderData *rdata, GPUVertBuf *vbo_attr)
{
using namespace blender;
if (rdata->curve_eval == nullptr) {
return;
}
@ -507,7 +501,6 @@ static void curve_create_attribute(CurveRenderData *rdata, GPUVertBuf *vbo_attr)
static void curve_create_curves_lines(CurveRenderData *rdata, GPUIndexBuf *ibo_curve_lines)
{
using namespace blender;
if (rdata->curve_eval == nullptr) {
return;
}
@ -925,3 +918,5 @@ void DRW_curve_batch_cache_create_requested(Object *ob, const Scene *scene)
}
/** \} */
} // namespace blender::draw

@ -44,8 +44,6 @@
#include "draw_curves_private.hh" /* own include */
#include "draw_shader.hh"
using blender::IndexRange;
namespace blender::draw {
/* ---------------------------------------------------------------------- */
@ -369,7 +367,7 @@ static void curves_batch_cache_fill_strands_data(const bke::CurvesGeometry &curv
GPUVertBufRaw &data_step,
GPUVertBufRaw &seg_step)
{
const blender::OffsetIndices points_by_curve = curves.points_by_curve();
const OffsetIndices points_by_curve = curves.points_by_curve();
for (const int i : IndexRange(curves.curves_num())) {
const IndexRange points = points_by_curve[i];
@ -591,9 +589,9 @@ static void request_attribute(Curves &curves, const char *name)
DRW_Attributes attributes{};
blender::bke::CurvesGeometry &curves_geometry = curves.geometry.wrap();
std::optional<blender::bke::AttributeMetaData> meta_data =
curves_geometry.attributes().lookup_meta_data(name);
bke::CurvesGeometry &curves_geometry = curves.geometry.wrap();
std::optional<bke::AttributeMetaData> meta_data = curves_geometry.attributes().lookup_meta_data(
name);
if (!meta_data) {
return;
}
@ -608,8 +606,6 @@ static void request_attribute(Curves &curves, const char *name)
drw_attributes_merge(&final_cache.attr_used, &attributes, cache.render_mutex);
}
} // namespace blender::draw
void drw_curves_get_attribute_sampler_name(const char *layer_name, char r_sampler_name[32])
{
char attr_safe_name[GPU_MAX_SAFE_ATTR_NAME];
@ -624,7 +620,6 @@ bool curves_ensure_procedural_data(Curves *curves_id,
const int subdiv,
const int thickness_res)
{
using namespace blender;
bke::CurvesGeometry &curves = curves_id->geometry.wrap();
bool need_ft_update = false;
@ -663,7 +658,6 @@ bool curves_ensure_procedural_data(Curves *curves_id,
void DRW_curves_batch_cache_dirty_tag(Curves *curves, int mode)
{
using namespace blender::draw;
CurvesBatchCache *cache = static_cast<CurvesBatchCache *>(curves->batch_cache);
if (cache == nullptr) {
return;
@ -679,7 +673,6 @@ void DRW_curves_batch_cache_dirty_tag(Curves *curves, int mode)
void DRW_curves_batch_cache_validate(Curves *curves)
{
using namespace blender::draw;
if (!curves_batch_cache_valid(*curves)) {
curves_batch_cache_clear(*curves);
curves_batch_cache_init(*curves);
@ -688,7 +681,6 @@ void DRW_curves_batch_cache_validate(Curves *curves)
void DRW_curves_batch_cache_free(Curves *curves)
{
using namespace blender::draw;
curves_batch_cache_clear(*curves);
MEM_delete(static_cast<CurvesBatchCache *>(curves->batch_cache));
curves->batch_cache = nullptr;
@ -696,7 +688,6 @@ void DRW_curves_batch_cache_free(Curves *curves)
void DRW_curves_batch_cache_free_old(Curves *curves, int ctime)
{
using namespace blender::draw;
CurvesBatchCache *cache = static_cast<CurvesBatchCache *>(curves->batch_cache);
if (cache == nullptr) {
return;
@ -730,14 +721,12 @@ int DRW_curves_material_count_get(const Curves *curves)
GPUBatch *DRW_curves_batch_cache_get_edit_points(Curves *curves)
{
using namespace blender::draw;
CurvesBatchCache &cache = curves_batch_cache_get(*curves);
return DRW_batch_request(&cache.edit_points);
}
GPUBatch *DRW_curves_batch_cache_get_edit_lines(Curves *curves)
{
using namespace blender::draw;
CurvesBatchCache &cache = curves_batch_cache_get(*curves);
return DRW_batch_request(&cache.edit_lines);
}
@ -746,8 +735,6 @@ GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves,
const char *name,
bool *r_is_point_domain)
{
using namespace blender;
using namespace blender::draw;
CurvesBatchCache &cache = curves_batch_cache_get(*curves);
const DRWContextState *draw_ctx = DRW_context_state_get();
const Scene *scene = draw_ctx->scene;
@ -782,7 +769,6 @@ GPUVertBuf **DRW_curves_texture_for_evaluated_attribute(Curves *curves,
void DRW_curves_batch_cache_create_requested(Object *ob)
{
using namespace blender;
Curves *curves_id = static_cast<Curves *>(ob->data);
Object *ob_orig = DEG_get_original_object(ob);
if (ob_orig == nullptr) {
@ -815,3 +801,5 @@ void DRW_curves_batch_cache_create_requested(Object *ob)
curves_batch_cache_ensure_edit_lines(curves_orig, cache);
}
}
} // namespace blender::draw

@ -36,10 +36,6 @@
#define BEZIER_HANDLE (1 << 3)
#define COLOR_SHIFT 5
/* -------------------------------------------------------------------- */
/** \name Internal Types
* \{ */
struct GpencilBatchCache {
/** Instancing Data */
GPUVertBuf *vbo;
@ -68,6 +64,12 @@ struct GpencilBatchCache {
int cache_frame;
};
namespace blender::draw {
/* -------------------------------------------------------------------- */
/** \name Internal Types
* \{ */
/** \} */
/* -------------------------------------------------------------------- */
@ -996,3 +998,5 @@ int DRW_gpencil_material_count_get(const bGPdata *gpd)
}
/** \} */
} // namespace blender::draw

@ -609,11 +609,8 @@ static void grease_pencil_geom_batch_ensure(Object &object,
/** \} */
} // namespace blender::draw
void DRW_grease_pencil_batch_cache_dirty_tag(GreasePencil *grease_pencil, int mode)
{
using namespace blender::draw;
BLI_assert(grease_pencil->runtime != nullptr);
GreasePencilBatchCache *cache = static_cast<GreasePencilBatchCache *>(
grease_pencil->runtime->batch_cache);
@ -631,7 +628,6 @@ void DRW_grease_pencil_batch_cache_dirty_tag(GreasePencil *grease_pencil, int mo
void DRW_grease_pencil_batch_cache_validate(GreasePencil *grease_pencil)
{
using namespace blender::draw;
BLI_assert(grease_pencil->runtime != nullptr);
if (!grease_pencil_batch_cache_valid(*grease_pencil)) {
grease_pencil_batch_cache_clear(*grease_pencil);
@ -641,7 +637,6 @@ void DRW_grease_pencil_batch_cache_validate(GreasePencil *grease_pencil)
void DRW_grease_pencil_batch_cache_free(GreasePencil *grease_pencil)
{
using namespace blender::draw;
grease_pencil_batch_cache_clear(*grease_pencil);
MEM_delete(static_cast<GreasePencilBatchCache *>(grease_pencil->runtime->batch_cache));
grease_pencil->runtime->batch_cache = nullptr;
@ -649,7 +644,6 @@ void DRW_grease_pencil_batch_cache_free(GreasePencil *grease_pencil)
GPUBatch *DRW_cache_grease_pencil_get(const Scene *scene, Object *ob)
{
using namespace blender::draw;
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
grease_pencil_geom_batch_ensure(*ob, grease_pencil, *scene);
@ -659,7 +653,6 @@ GPUBatch *DRW_cache_grease_pencil_get(const Scene *scene, Object *ob)
GPUBatch *DRW_cache_grease_pencil_edit_points_get(const Scene *scene, Object *ob)
{
using namespace blender::draw;
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
grease_pencil_edit_batch_ensure(*ob, grease_pencil, *scene);
@ -669,7 +662,6 @@ GPUBatch *DRW_cache_grease_pencil_edit_points_get(const Scene *scene, Object *ob
GPUBatch *DRW_cache_grease_pencil_edit_lines_get(const Scene *scene, Object *ob)
{
using namespace blender::draw;
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
grease_pencil_edit_batch_ensure(*ob, grease_pencil, *scene);
@ -679,7 +671,6 @@ GPUBatch *DRW_cache_grease_pencil_edit_lines_get(const Scene *scene, Object *ob)
GPUVertBuf *DRW_cache_grease_pencil_position_buffer_get(const Scene *scene, Object *ob)
{
using namespace blender::draw;
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
grease_pencil_geom_batch_ensure(*ob, grease_pencil, *scene);
@ -689,10 +680,11 @@ GPUVertBuf *DRW_cache_grease_pencil_position_buffer_get(const Scene *scene, Obje
GPUVertBuf *DRW_cache_grease_pencil_color_buffer_get(const Scene *scene, Object *ob)
{
using namespace blender::draw;
GreasePencil &grease_pencil = *static_cast<GreasePencil *>(ob->data);
GreasePencilBatchCache *cache = grease_pencil_batch_cache_get(grease_pencil);
grease_pencil_geom_batch_ensure(*ob, grease_pencil, *scene);
return cache->vbo_col;
}
} // namespace blender::draw

@ -27,6 +27,8 @@
#define SELECT 1
namespace blender::draw {
static void lattice_batch_cache_clear(Lattice *lt);
/* ---------------------------------------------------------------------- */
@ -502,3 +504,5 @@ GPUBatch *DRW_lattice_batch_cache_get_edit_verts(Lattice *lt)
return cache->overlay_verts;
}
} // namespace blender::draw

@ -66,10 +66,7 @@
#include "mesh_extractors/extract_mesh.hh"
using blender::IndexRange;
using blender::Map;
using blender::Span;
using blender::StringRefNull;
namespace blender::draw {
/* ---------------------------------------------------------------------- */
/** \name Dependencies between buffer and batch
@ -276,7 +273,6 @@ static DRW_MeshCDMask mesh_cd_calc_used_gpu_layers(const Object *object,
int gpumat_array_len,
DRW_Attributes *attributes)
{
using namespace blender;
const Mesh *me_final = editmesh_final_or_this(object, mesh);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
const CustomData *cd_pdata = mesh_cd_pdata_get_from_mesh(me_final);
@ -867,7 +863,6 @@ static void request_active_and_default_color_attributes(const Object &object,
const Mesh &mesh,
DRW_Attributes &attributes)
{
using namespace blender;
const Mesh *me_final = editmesh_final_or_this(&object, &mesh);
const CustomData *cd_vdata = mesh_cd_vdata_get_from_mesh(me_final);
const CustomData *cd_ldata = mesh_cd_ldata_get_from_mesh(me_final);
@ -1342,7 +1337,6 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
const bool is_paint_mode,
const bool use_hide)
{
using namespace blender;
BLI_assert(task_graph);
const ToolSettings *ts = nullptr;
if (scene) {
@ -1866,7 +1860,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
#endif
if (do_uvcage) {
blender::draw::mesh_buffer_cache_create_requested(task_graph,
mesh_buffer_cache_create_requested(task_graph,
cache,
cache.uv_cage,
ob,
@ -1883,7 +1877,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
}
if (do_cage) {
blender::draw::mesh_buffer_cache_create_requested(task_graph,
mesh_buffer_cache_create_requested(task_graph,
cache,
cache.cage,
ob,
@ -1920,7 +1914,7 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
mesh_batch_cache_free_subdiv_cache(cache);
}
blender::draw::mesh_buffer_cache_create_requested(task_graph,
mesh_buffer_cache_create_requested(task_graph,
cache,
cache.final,
ob,
@ -1949,3 +1943,5 @@ void DRW_mesh_batch_cache_create_requested(TaskGraph *task_graph,
}
/** \} */
} // namespace blender::draw

@ -43,6 +43,8 @@
#include "draw_cache_impl.hh" /* own include */
#include "draw_hair_private.h"
namespace blender::draw {
static void particle_batch_cache_clear(ParticleSystem *psys);
/* ---------------------------------------------------------------------- */
@ -1763,3 +1765,5 @@ bool particles_ensure_procedural_data(Object *object,
return need_ft_update;
}
} // namespace blender::draw

@ -33,7 +33,7 @@
#include "draw_cache_inline.hh"
#include "draw_pointcloud_private.hh" /* own include */
using namespace blender;
namespace blender::draw {
/* -------------------------------------------------------------------- */
/** \name GPUBatch cache management
@ -248,8 +248,6 @@ static void pointcloud_extract_indices(const PointCloud &pointcloud, PointCloudB
static void pointcloud_extract_position_and_radius(const PointCloud &pointcloud,
PointCloudBatchCache &cache)
{
using namespace blender;
const bke::AttributeAccessor attributes = pointcloud.attributes();
const Span<float3> positions = pointcloud.positions();
const VArray<float> radii = *attributes.lookup<float>("radius");
@ -293,8 +291,6 @@ static void pointcloud_extract_attribute(const PointCloud &pointcloud,
const DRW_AttributeRequest &request,
int index)
{
using namespace blender;
GPUVertBuf *&attr_buf = cache.eval_cache.attributes_buf[index];
const bke::AttributeAccessor attributes = pointcloud.attributes();
@ -337,7 +333,6 @@ GPUBatch **pointcloud_surface_shaded_get(PointCloud *pointcloud,
GPUMaterial **gpu_materials,
int mat_len)
{
using namespace blender;
PointCloudBatchCache *cache = pointcloud_batch_cache_get(*pointcloud);
DRW_Attributes attrs_needed;
drw_attributes_clear(&attrs_needed);
@ -398,7 +393,6 @@ GPUVertBuf *DRW_pointcloud_position_and_radius_buffer_get(Object *ob)
GPUVertBuf **DRW_pointcloud_evaluated_attribute(PointCloud *pointcloud, const char *name)
{
using namespace blender;
PointCloudBatchCache &cache = *pointcloud_batch_cache_get(*pointcloud);
int layer_index;
@ -465,3 +459,5 @@ void DRW_pointcloud_batch_cache_create_requested(Object *ob)
}
/** \} */
} // namespace blender::draw

@ -48,8 +48,6 @@
#include "draw_cache_inline.hh"
#include "mesh_extractors/extract_mesh.hh"
using blender::Span;
extern "C" char datatoc_common_subdiv_custom_data_interp_comp_glsl[];
extern "C" char datatoc_common_subdiv_ibo_lines_comp_glsl[];
extern "C" char datatoc_common_subdiv_ibo_tris_comp_glsl[];
@ -63,6 +61,8 @@ extern "C" char datatoc_common_subdiv_vbo_sculpt_data_comp_glsl[];
extern "C" char datatoc_common_subdiv_vbo_edituv_strech_angle_comp_glsl[];
extern "C" char datatoc_common_subdiv_vbo_edituv_strech_area_comp_glsl[];
namespace blender::draw {
enum {
SHADER_BUFFER_LINES,
SHADER_BUFFER_LINES_LOOSE,
@ -753,10 +753,10 @@ static void draw_subdiv_cache_extra_coarse_face_data_mesh(const MeshRenderData &
Mesh *mesh,
uint32_t *flags_data)
{
const blender::OffsetIndices faces = mesh->faces();
const OffsetIndices faces = mesh->faces();
for (const int i : faces.index_range()) {
uint32_t flag = 0;
if (!(mr.normals_domain == blender::bke::MeshNormalDomain::Face ||
if (!(mr.normals_domain == bke::MeshNormalDomain::Face ||
(!mr.sharp_faces.is_empty() && mr.sharp_faces[i])))
{
flag |= SUBDIV_COARSE_FACE_FLAG_SMOOTH;
@ -781,13 +781,13 @@ static void draw_subdiv_cache_extra_coarse_face_data_mapped(Mesh *mesh,
return;
}
const blender::OffsetIndices faces = mesh->faces();
const OffsetIndices faces = mesh->faces();
for (const int i : faces.index_range()) {
BMFace *f = bm_original_face_get(mr, i);
/* Selection and hiding from bmesh. */
uint32_t flag = (f) ? compute_coarse_face_flag_bm(f, mr.efa_act) : 0;
/* Smooth from mesh. */
if (!(mr.normals_domain == blender::bke::MeshNormalDomain::Face ||
if (!(mr.normals_domain == bke::MeshNormalDomain::Face ||
(!mr.sharp_faces.is_empty() && mr.sharp_faces[i])))
{
flag |= SUBDIV_COARSE_FACE_FLAG_SMOOTH;
@ -1139,12 +1139,12 @@ static void build_vertex_face_adjacency_maps(DRWSubdivCache &cache)
cache.subdiv_vertex_face_adjacency_offsets = gpu_vertbuf_create_from_format(
get_origindex_format(), cache.num_subdiv_verts + 1);
blender::MutableSpan<int> vertex_offsets(
MutableSpan<int> vertex_offsets(
static_cast<int *>(GPU_vertbuf_get_data(cache.subdiv_vertex_face_adjacency_offsets)),
cache.num_subdiv_verts + 1);
vertex_offsets.fill(0);
blender::offset_indices::build_reverse_offsets(
offset_indices::build_reverse_offsets(
{cache.subdiv_loop_subdiv_vert_index, cache.num_subdiv_loops}, vertex_offsets);
cache.subdiv_vertex_face_adjacency = gpu_vertbuf_create_from_format(get_origindex_format(),
@ -1204,7 +1204,7 @@ static bool draw_subdiv_build_cache(DRWSubdivCache &cache,
}
/* Only build face related data if we have polygons. */
const blender::OffsetIndices faces = mesh_eval->faces();
const OffsetIndices faces = mesh_eval->faces();
if (cache.num_subdiv_loops != 0) {
/* Build buffers for the PatchMap. */
draw_patch_map_build(&cache.gpu_patch_map, subdiv);
@ -1245,7 +1245,7 @@ static bool draw_subdiv_build_cache(DRWSubdivCache &cache,
/* To avoid floating point precision issues when evaluating patches at patch boundaries,
* ensure that all loops sharing a vertex use the same patch coordinate. This could cause
* the mesh to not be watertight, leading to shadowing artifacts (see #97877). */
blender::Vector<int> first_loop_index(cache.num_subdiv_verts, -1);
Vector<int> first_loop_index(cache.num_subdiv_verts, -1);
/* Save coordinates for corners, as attributes may vary for each loop connected to the same
* vertex. */
@ -2023,7 +2023,6 @@ static void draw_subdiv_cache_ensure_mat_offsets(DRWSubdivCache &cache,
Mesh *mesh_eval,
uint mat_len)
{
using namespace blender;
draw_subdiv_cache_free_material_data(cache);
const int number_of_quads = cache.num_subdiv_loops / 4;
@ -2036,8 +2035,8 @@ static void draw_subdiv_cache_ensure_mat_offsets(DRWSubdivCache &cache,
return;
}
const blender::bke::AttributeAccessor attributes = mesh_eval->attributes();
const blender::VArraySpan<int> material_indices = *attributes.lookup_or_default<int>(
const bke::AttributeAccessor attributes = mesh_eval->attributes();
const VArraySpan<int> material_indices = *attributes.lookup_or_default<int>(
"material_index", bke::AttrDomain::Face, 0);
/* Count number of subdivided polygons for each material. */
@ -2160,7 +2159,7 @@ static bool draw_subdiv_create_requested_buffers(Object *ob,
draw_cache.use_custom_loop_normals = (runtime_data->use_loop_normals) &&
mesh_eval->normals_domain() ==
blender::bke::MeshNormalDomain::Corner;
bke::MeshNormalDomain::Corner;
if (DRW_ibo_requested(mbc.buff.ibo.tris)) {
draw_subdiv_cache_ensure_mat_offsets(draw_cache, mesh_eval, batch_cache.mat_len);
@ -2178,7 +2177,7 @@ static bool draw_subdiv_create_requested_buffers(Object *ob,
draw_subdiv_cache_update_extra_coarse_face_data(draw_cache, mesh_eval, *mr);
blender::draw::mesh_buffer_cache_create_requested_subdiv(batch_cache, mbc, draw_cache, *mr);
mesh_buffer_cache_create_requested_subdiv(batch_cache, mbc, draw_cache, *mr);
mesh_render_data_free(mr);
@ -2229,14 +2228,14 @@ void DRW_subdivide_loose_geom(DRWSubdivCache *subdiv_cache, MeshBufferCache *cac
const Span<float3> coarse_positions = coarse_mesh->vert_positions();
const Span<int2> coarse_edges = coarse_mesh->edges();
blender::Array<int> vert_to_edge_offsets;
blender::Array<int> vert_to_edge_indices;
const blender::GroupedSpan<int> vert_to_edge_map = blender::bke::mesh::build_vert_to_edge_map(
Array<int> vert_to_edge_offsets;
Array<int> vert_to_edge_indices;
const GroupedSpan<int> vert_to_edge_map = bke::mesh::build_vert_to_edge_map(
coarse_edges, coarse_mesh->verts_num, vert_to_edge_offsets, vert_to_edge_indices);
for (int i = 0; i < coarse_loose_edge_len; i++) {
const int coarse_edge_index = cache->loose_geom.edges[i];
const blender::int2 &coarse_edge = coarse_edges[cache->loose_geom.edges[i]];
const int2 &coarse_edge = coarse_edges[cache->loose_geom.edges[i]];
/* Perform interpolation of each vertex. */
for (int i = 0; i < resolution - 1; i++, subd_edge_offset++) {
@ -2291,12 +2290,12 @@ void DRW_subdivide_loose_geom(DRWSubdivCache *subdiv_cache, MeshBufferCache *cac
subdiv_cache->loose_geom.loop_len = num_subdivided_edge * 2 + coarse_loose_vert_len;
}
blender::Span<DRWSubdivLooseEdge> draw_subdiv_cache_get_loose_edges(const DRWSubdivCache &cache)
Span<DRWSubdivLooseEdge> draw_subdiv_cache_get_loose_edges(const DRWSubdivCache &cache)
{
return {cache.loose_geom.edges, int64_t(cache.loose_geom.edge_len)};
}
blender::Span<DRWSubdivLooseVertex> draw_subdiv_cache_get_loose_verts(const DRWSubdivCache &cache)
Span<DRWSubdivLooseVertex> draw_subdiv_cache_get_loose_verts(const DRWSubdivCache &cache)
{
return {cache.loose_geom.verts + cache.loose_geom.edge_len * 2,
int64_t(cache.loose_geom.vert_len)};
@ -2394,3 +2393,5 @@ void DRW_cache_free_old_subdiv()
BLI_mutex_unlock(&gpu_subdiv_queue_mutex);
}
} // namespace blender::draw

@ -36,6 +36,8 @@
#include "draw_cache.hh" /* own include */
#include "draw_cache_impl.hh" /* own include */
namespace blender::draw {
static void volume_batch_cache_clear(Volume *volume);
/* ---------------------------------------------------------------------- */
@ -211,7 +213,7 @@ GPUBatch *DRW_volume_batch_cache_get_wireframes_face(Volume *volume)
VolumeBatchCache *cache = volume_batch_cache_get(volume);
if (cache->face_wire.batch == nullptr) {
const blender::bke::VolumeGridData *volume_grid = BKE_volume_grid_active_get_for_read(volume);
const bke::VolumeGridData *volume_grid = BKE_volume_grid_active_get_for_read(volume);
if (volume_grid == nullptr) {
return nullptr;
}
@ -260,7 +262,7 @@ GPUBatch *DRW_volume_batch_cache_get_selection_surface(Volume *volume)
{
VolumeBatchCache *cache = volume_batch_cache_get(volume);
if (cache->selection_surface == nullptr) {
const blender::bke::VolumeGridData *volume_grid = BKE_volume_grid_active_get_for_read(volume);
const bke::VolumeGridData *volume_grid = BKE_volume_grid_active_get_for_read(volume);
if (volume_grid == nullptr) {
return nullptr;
}
@ -271,10 +273,10 @@ GPUBatch *DRW_volume_batch_cache_get_selection_surface(Volume *volume)
}
static DRWVolumeGrid *volume_grid_cache_get(const Volume *volume,
const blender::bke::VolumeGridData *grid,
const bke::VolumeGridData *grid,
VolumeBatchCache *cache)
{
const std::string name = blender::bke::volume_grid::get_name(*grid);
const std::string name = bke::volume_grid::get_name(*grid);
/* Return cached grid. */
LISTBASE_FOREACH (DRWVolumeGrid *, cache_grid, &cache->grids) {
@ -293,13 +295,12 @@ static DRWVolumeGrid *volume_grid_cache_get(const Volume *volume,
BKE_volume_load(volume, G.main);
/* Test if we support textures with the number of channels. */
size_t channels = blender::bke::volume_grid::get_channels_num(
blender::bke::volume_grid::get_type(*grid));
size_t channels = bke::volume_grid::get_channels_num(bke::volume_grid::get_type(*grid));
if (!ELEM(channels, 1, 3)) {
return cache_grid;
}
const bool was_loaded = blender::bke::volume_grid::is_loaded(*grid);
const bool was_loaded = bke::volume_grid::is_loaded(*grid);
DenseFloatVolumeGrid dense_grid;
if (BKE_volume_grid_dense_floats(volume, grid, &dense_grid)) {
@ -329,14 +330,14 @@ static DRWVolumeGrid *volume_grid_cache_get(const Volume *volume,
/* Free grid from memory if it wasn't previously loaded. */
if (!was_loaded) {
blender::bke::volume_grid::unload_tree_if_possible(*grid);
bke::volume_grid::unload_tree_if_possible(*grid);
}
return cache_grid;
}
DRWVolumeGrid *DRW_volume_batch_cache_get_grid(Volume *volume,
const blender::bke::VolumeGridData *volume_grid)
const bke::VolumeGridData *volume_grid)
{
VolumeBatchCache *cache = volume_batch_cache_get(volume);
DRWVolumeGrid *grid = volume_grid_cache_get(volume, volume_grid, cache);
@ -347,3 +348,5 @@ int DRW_volume_material_count_get(const Volume *volume)
{
return max_ii(1, volume->totcol);
}
} // namespace blender::draw

@ -10,11 +10,6 @@
#include "draw_common_shader_shared.h"
#ifdef __cplusplus
extern "C" {
#endif
struct CurvesUniformBufPool;
struct DRWShadingGroup;
struct FluidModifierData;
struct GPUMaterial;
@ -25,6 +20,9 @@ struct RegionView3D;
struct ViewLayer;
struct Scene;
struct DRWData;
namespace blender::draw {
struct CurvesUniformBufPool;
}
/* Keep in sync with globalsBlock in shaders */
BLI_STATIC_ASSERT_ALIGN(GlobalsUboStorage, 16)
@ -75,6 +73,8 @@ void DRW_hair_free(void);
/* draw_curves.cc */
namespace blender::draw {
/**
* \note Only valid after #DRW_curves_update().
*/
@ -85,7 +85,7 @@ struct DRWShadingGroup *DRW_shgroup_curves_create_sub(struct Object *object,
struct GPUMaterial *gpu_material);
void DRW_curves_init(struct DRWData *drw_data);
void DRW_curves_ubos_pool_free(struct CurvesUniformBufPool *pool);
void DRW_curves_ubos_pool_free(CurvesUniformBufPool *pool);
void DRW_curves_update(void);
void DRW_curves_free(void);
@ -97,6 +97,8 @@ struct DRWShadingGroup *DRW_shgroup_pointcloud_create_sub(struct Object *object,
void DRW_pointcloud_init(void);
void DRW_pointcloud_free(void);
} // namespace blender::draw
/* draw_volume.cc */
/**
@ -144,7 +146,3 @@ struct DRW_Global {
struct GPUUniformBuf *clipping_ubo;
};
extern struct DRW_Global G_draw;
#ifdef __cplusplus
}
#endif

@ -28,11 +28,14 @@
#include "DRW_render.hh"
#include "draw_cache_impl.hh"
#include "draw_common.hh"
#include "draw_curves_private.hh"
#include "draw_hair_private.h"
#include "draw_manager.h"
#include "draw_shader.hh"
namespace blender::draw {
BLI_INLINE eParticleRefineShaderType drw_curves_shader_type_get()
{
/* NOTE: Curve refine is faster using transform feedback via vertex processing pipeline with
@ -63,10 +66,10 @@ static int g_tf_target_height;
static GPUVertBuf *g_dummy_vbo = nullptr;
static DRWPass *g_tf_pass; /* XXX can be a problem with multiple DRWManager in the future */
using CurvesInfosBuf = blender::draw::UniformBuffer<CurvesInfos>;
using CurvesInfosBuf = UniformBuffer<CurvesInfos>;
struct CurvesUniformBufPool {
blender::Vector<std::unique_ptr<CurvesInfosBuf>> ubos;
Vector<std::unique_ptr<CurvesInfosBuf>> ubos;
int used = 0;
void reset()
@ -309,7 +312,6 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object,
DRWShadingGroup *shgrp_parent,
GPUMaterial *gpu_material)
{
using namespace blender;
const DRWContextState *draw_ctx = DRW_context_state_get();
const Scene *scene = draw_ctx->scene;
CurvesUniformBufPool *pool = DST.vmempool->curves_ubos;
@ -339,11 +341,11 @@ DRWShadingGroup *DRW_shgroup_curves_create_sub(Object *object,
/* Use the radius of the root and tip of the first curve for now. This is a workaround that we
* use for now because we can't use a per-point radius yet. */
const blender::bke::CurvesGeometry &curves = curves_id.geometry.wrap();
const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
if (curves.curves_num() >= 1) {
blender::VArray<float> radii = *curves.attributes().lookup_or_default(
VArray<float> radii = *curves.attributes().lookup_or_default(
"radius", bke::AttrDomain::Point, 0.005f);
const blender::IndexRange first_curve_points = curves.points_by_curve()[0];
const IndexRange first_curve_points = curves.points_by_curve()[0];
const float first_radius = radii[first_curve_points.first()];
const float last_radius = radii[first_curve_points.last()];
const float middle_radius = radii[first_curve_points.size() / 2];
@ -559,9 +561,6 @@ void DRW_curves_free()
}
/* New Draw Manager. */
#include "draw_common.hh"
namespace blender::draw {
static PassSimple *g_pass = nullptr;
@ -685,11 +684,11 @@ GPUBatch *curves_sub_pass_setup_implementation(PassT &sub_ps,
/* Use the radius of the root and tip of the first curve for now. This is a workaround that we
* use for now because we can't use a per-point radius yet. */
const blender::bke::CurvesGeometry &curves = curves_id.geometry.wrap();
const bke::CurvesGeometry &curves = curves_id.geometry.wrap();
if (curves.curves_num() >= 1) {
blender::VArray<float> radii = *curves.attributes().lookup_or_default(
VArray<float> radii = *curves.attributes().lookup_or_default(
"radius", bke::AttrDomain::Point, 0.005f);
const blender::IndexRange first_curve_points = curves.points_by_curve()[0];
const IndexRange first_curve_points = curves.points_by_curve()[0];
const float first_radius = radii[first_curve_points.first()];
const float last_radius = radii[first_curve_points.last()];
const float middle_radius = radii[first_curve_points.size() / 2];

@ -17,6 +17,8 @@ struct GPUVertBuf;
struct GPUBatch;
struct GPUMaterial;
namespace blender::draw {
#define MAX_THICKRES 2 /* see eHairType */
#define MAX_HAIR_SUBDIV 4 /* see hair_subdiv rna */
@ -91,3 +93,5 @@ bool curves_ensure_procedural_data(Curves *curves,
int thickness_res);
void drw_curves_get_attribute_sampler_name(const char *layer_name, char r_sampler_name[32]);
}

@ -178,6 +178,7 @@ static ParticleHairCache *drw_hair_particle_cache_get(Object *object,
int subdiv,
int thickness_res)
{
using namespace blender::draw;
ParticleHairCache *cache;
bool update = particles_ensure_procedural_data(
object, psys, md, &cache, gpu_material, subdiv, thickness_res);
@ -459,6 +460,7 @@ static ParticleHairCache *hair_particle_cache_get(Object *object,
int subdiv,
int thickness_res)
{
using namespace blender::draw;
ParticleHairCache *cache;
bool update = particles_ensure_procedural_data(
object, psys, md, &cache, gpu_material, subdiv, thickness_res);

@ -8,10 +8,6 @@
#pragma once
#ifdef __cplusplus
extern "C" {
#endif
#define MAX_LAYER_NAME_CT 4 /* `u0123456789, u, au, a0123456789`. */
#define MAX_LAYER_NAME_LEN (GPU_MAX_SAFE_ATTR_NAME + 2)
#define MAX_THICKRES 2 /* see eHairType */
@ -71,6 +67,8 @@ typedef struct ParticleHairCache {
int point_len;
} ParticleHairCache;
namespace blender::draw {
/**
* Ensure all textures and buffers needed for GPU accelerated drawing.
*/
@ -82,6 +80,4 @@ bool particles_ensure_procedural_data(struct Object *object,
int subdiv,
int thickness_res);
#ifdef __cplusplus
}
#endif
} // namespace blender::draw

@ -30,12 +30,11 @@
#include "draw_instance_data.h"
#include "draw_shader_shared.h"
#ifdef __cplusplus
extern "C" {
#endif
struct DupliObject;
struct Object;
namespace blender::draw {
struct CurvesUniformBufPool;
}
/** Use draw manager to call GPU_select, see: #DRW_draw_select_loop */
#define USE_GPU_SELECT
@ -569,7 +568,7 @@ typedef struct DRWData {
/** Per stereo view data. Contains engine data and default frame-buffers. */
struct DRWViewData *view_data[2];
/** Per draw-call curves object data. */
struct CurvesUniformBufPool *curves_ubos;
blender::draw::CurvesUniformBufPool *curves_ubos;
} DRWData;
/** \} */
@ -734,21 +733,23 @@ bool drw_engine_data_engines_data_validate(GPUViewport *viewport, void **engine_
void drw_engine_data_cache_release(GPUViewport *viewport);
void drw_engine_data_free(GPUViewport *viewport);
struct GPUMaterial;
namespace blender::draw {
struct DRW_Attributes;
struct DRW_MeshCDMask;
struct GPUMaterial;
void DRW_mesh_get_attributes(const struct Object *object,
const struct Mesh *mesh,
const struct GPUMaterial *const *gpumat_array,
int gpumat_array_len,
struct DRW_Attributes *r_attrs,
struct DRW_MeshCDMask *r_cd_needed);
DRW_Attributes *r_attrs,
DRW_MeshCDMask *r_cd_needed);
} // namespace blender::draw
void DRW_manager_begin_sync(void);
void DRW_manager_end_sync(void);
/** \} */
#ifdef __cplusplus
}
#endif

@ -975,6 +975,7 @@ static void drw_drawdata_unlink_dupli(ID *id)
void DRW_cache_free_old_batches(Main *bmain)
{
using namespace blender::draw;
Scene *scene;
static int lasttime = 0;
int ctime = int(PIL_check_seconds_timer());
@ -1650,6 +1651,7 @@ void DRW_draw_render_loop_ex(Depsgraph *depsgraph,
GPUViewport *viewport,
const bContext *evil_C)
{
using namespace blender::draw;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
@ -1970,6 +1972,7 @@ void DRW_render_gpencil(RenderEngine *engine, Depsgraph *depsgraph)
void DRW_render_to_image(RenderEngine *engine, Depsgraph *depsgraph)
{
using namespace blender::draw;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
RenderEngineType *engine_type = engine->type;
@ -2064,6 +2067,7 @@ void DRW_render_object_iter(
Depsgraph *depsgraph,
void (*callback)(void *vedata, Object *ob, RenderEngine *engine, Depsgraph *depsgraph))
{
using namespace blender::draw;
const DRWContextState *draw_ctx = DRW_context_state_get();
DRW_pointcloud_init();
DRW_curves_init(DST.vmempool);
@ -2103,6 +2107,7 @@ void DRW_render_object_iter(
void DRW_custom_pipeline_begin(DrawEngineType *draw_engine_type, Depsgraph *depsgraph)
{
using namespace blender::draw;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
@ -2168,6 +2173,7 @@ void DRW_custom_pipeline(DrawEngineType *draw_engine_type,
void DRW_cache_restart()
{
using namespace blender::draw;
DRW_smoke_exit(DST.vmempool);
drw_manager_init(&DST, DST.viewport, blender::int2{int(DST.size[0]), int(DST.size[1])});
@ -2395,6 +2401,7 @@ void DRW_draw_select_loop(Depsgraph *depsgraph,
DRW_ObjectFilterFn object_filter_fn,
void *object_filter_user_data)
{
using namespace blender::draw;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
@ -2639,6 +2646,7 @@ void DRW_draw_depth_loop(Depsgraph *depsgraph,
const bool use_basic,
const bool use_overlay)
{
using namespace blender::draw;
Scene *scene = DEG_get_evaluated_scene(depsgraph);
RenderEngineType *engine_type = ED_view3d_engine_type(scene, v3d->shading.type);
ViewLayer *view_layer = DEG_get_evaluated_view_layer(depsgraph);
@ -2850,6 +2858,7 @@ void DRW_draw_select_id(Depsgraph *depsgraph, ARegion *region, View3D *v3d)
void DRW_draw_depth_object(
Scene *scene, ARegion *region, View3D *v3d, GPUViewport *viewport, Object *object)
{
using namespace blender::draw;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
GPU_matrix_projection_set(rv3d->winmat);
@ -3041,6 +3050,7 @@ void DRW_engine_register(DrawEngineType *draw_engine_type)
void DRW_engines_register()
{
using namespace blender::draw;
RE_engines_register(&DRW_engine_viewport_eevee_type);
/* Always register EEVEE Next so it can be used in background mode with `--factory-startup`.
* (Needed for tests). */
@ -3120,6 +3130,7 @@ static void drw_registered_engines_free()
void DRW_engines_free()
{
using namespace blender::draw;
drw_registered_engines_free();
if (DST.system_gpu_context == nullptr) {

@ -25,8 +25,13 @@
#include "draw_attributes.hh"
#include "draw_cache_impl.hh"
#include "draw_common.h"
#include "draw_common.hh"
#include "draw_manager.h"
#include "draw_pointcloud_private.hh"
/* For drw_curves_get_attribute_sampler_name. */
#include "draw_curves_private.hh"
namespace blender::draw {
static GPUVertBuf *g_dummy_vbo = nullptr;
@ -97,11 +102,6 @@ void DRW_pointcloud_free()
GPU_VERTBUF_DISCARD_SAFE(g_dummy_vbo);
}
#include "draw_common.hh"
/* For drw_curves_get_attribute_sampler_name. */
#include "draw_curves_private.hh"
namespace blender::draw {
template<typename PassT>
GPUBatch *point_cloud_sub_pass_setup_implementation(PassT &sub_ps,
Object *object,

@ -13,8 +13,12 @@ struct GPUBatch;
struct GPUVertBuf;
struct GPUMaterial;
namespace blender::draw {
GPUVertBuf *pointcloud_position_and_radius_get(PointCloud *pointcloud);
GPUBatch **pointcloud_surface_shaded_get(PointCloud *pointcloud,
GPUMaterial **gpu_materials,
int mat_len);
GPUBatch *pointcloud_surface_get(PointCloud *pointcloud);
}

@ -74,7 +74,8 @@ GPUShader *DRW_shader_hair_refine_get(ParticleRefineShader refinement,
return e_data.hair_refine_sh[refinement];
}
GPUShader *DRW_shader_curves_refine_get(CurvesEvalShader type, eParticleRefineShaderType sh_type)
GPUShader *DRW_shader_curves_refine_get(blender::draw::CurvesEvalShader type,
eParticleRefineShaderType sh_type)
{
/* TODO: Implement curves evaluation types (Bezier and Catmull Rom). */
if (e_data.hair_refine_sh[type] == nullptr) {

@ -24,7 +24,8 @@ enum eParticleRefineShaderType {
GPUShader *DRW_shader_hair_refine_get(ParticleRefineShader refinement,
eParticleRefineShaderType sh_type);
GPUShader *DRW_shader_curves_refine_get(CurvesEvalShader type, eParticleRefineShaderType sh_type);
GPUShader *DRW_shader_curves_refine_get(blender::draw::CurvesEvalShader type,
eParticleRefineShaderType sh_type);
GPUShader *DRW_shader_debug_print_display_get();
GPUShader *DRW_shader_debug_draw_display_get();

@ -13,13 +13,16 @@ struct GPUUniformBuf;
struct GPUVertBuf;
struct GPUVertFormat;
struct Mesh;
struct MeshBatchCache;
struct MeshBufferCache;
struct MeshRenderData;
struct Object;
struct Subdiv;
struct ToolSettings;
namespace blender::draw {
struct MeshBatchCache;
struct MeshBufferCache;
struct MeshRenderData;
/* -------------------------------------------------------------------- */
/** \name DRWPatchMap
*
@ -294,8 +297,10 @@ void draw_subdiv_build_edituv_stretch_angle_buffer(const DRWSubdivCache &cache,
GPUVertFormat *draw_subdiv_get_pos_nor_format();
/* Helper to access the loose edges. */
blender::Span<DRWSubdivLooseEdge> draw_subdiv_cache_get_loose_edges(const DRWSubdivCache &cache);
Span<DRWSubdivLooseEdge> draw_subdiv_cache_get_loose_edges(const DRWSubdivCache &cache);
/* Helper to access only the loose vertices, i.e. not the ones attached to loose edges. To access
* loose vertices of loose edges #draw_subdiv_cache_get_loose_edges should be used. */
blender::Span<DRWSubdivLooseVertex> draw_subdiv_cache_get_loose_verts(const DRWSubdivCache &cache);
Span<DRWSubdivLooseVertex> draw_subdiv_cache_get_loose_verts(const DRWSubdivCache &cache);
} // namespace blender::draw

@ -19,6 +19,8 @@
#include "draw_cache_impl.hh"
namespace blender::draw {
void *mesh_extract_buffer_get(const MeshExtract *extractor, MeshBufferList *mbuflist)
{
/* NOTE: POINTER_OFFSET on windows platforms casts internally to `void *`, but on GCC/CLANG to
@ -155,3 +157,5 @@ void mesh_render_data_loop_edge_flag(const MeshRenderData &mr,
}
/** \} */
} // namespace blender::draw

@ -31,6 +31,8 @@ struct BMEditMesh;
struct BMFace;
struct BMLoop;
namespace blender::draw {
#define MIN_RANGE_LEN 1024
/* ---------------------------------------------------------------------- */
@ -65,15 +67,15 @@ struct MeshRenderData {
/** Edit Mesh */
BMEditMesh *edit_bmesh;
BMesh *bm;
blender::bke::EditMeshData *edit_data;
bke::EditMeshData *edit_data;
/* For deformed edit-mesh data. */
/* Use for #ME_WRAPPER_TYPE_BMESH. */
blender::Span<blender::float3> bm_vert_coords;
blender::Span<blender::float3> bm_vert_normals;
blender::Span<blender::float3> bm_face_normals;
blender::Span<blender::float3> bm_face_centers;
blender::Array<blender::float3> bm_loop_normals;
Span<float3> bm_vert_coords;
Span<float3> bm_vert_normals;
Span<float3> bm_face_normals;
Span<float3> bm_face_centers;
Array<float3> bm_loop_normals;
const int *v_origindex, *e_origindex, *p_origindex;
int edge_crease_ofs;
@ -83,35 +85,35 @@ struct MeshRenderData {
int freestyle_face_ofs;
/** Mesh */
Mesh *mesh;
blender::Span<blender::float3> vert_positions;
blender::Span<blender::int2> edges;
blender::OffsetIndices<int> faces;
blender::Span<int> corner_verts;
blender::Span<int> corner_edges;
Span<float3> vert_positions;
Span<int2> edges;
OffsetIndices<int> faces;
Span<int> corner_verts;
Span<int> corner_edges;
BMVert *eve_act;
BMEdge *eed_act;
BMFace *efa_act;
BMFace *efa_act_uv;
/* The triangulation of #Mesh faces, owned by the mesh. */
blender::Span<blender::int3> corner_tris;
blender::Span<int> corner_tri_faces;
blender::VArraySpan<int> material_indices;
Span<int3> corner_tris;
Span<int> corner_tri_faces;
VArraySpan<int> material_indices;
blender::bke::MeshNormalDomain normals_domain;
blender::Span<blender::float3> vert_normals;
blender::Span<blender::float3> face_normals;
blender::Span<blender::float3> loop_normals;
bke::MeshNormalDomain normals_domain;
Span<float3> vert_normals;
Span<float3> face_normals;
Span<float3> loop_normals;
blender::VArraySpan<bool> hide_vert;
blender::VArraySpan<bool> hide_edge;
blender::VArraySpan<bool> hide_poly;
blender::VArraySpan<bool> select_vert;
blender::VArraySpan<bool> select_edge;
blender::VArraySpan<bool> select_poly;
blender::VArraySpan<bool> sharp_faces;
VArraySpan<bool> hide_vert;
VArraySpan<bool> hide_edge;
VArraySpan<bool> hide_poly;
VArraySpan<bool> select_vert;
VArraySpan<bool> select_edge;
VArraySpan<bool> select_poly;
VArraySpan<bool> sharp_faces;
blender::Span<int> loose_verts;
blender::Span<int> loose_edges;
Span<int> loose_verts;
Span<int> loose_edges;
const SortedFaceData *face_sorted;
const char *active_color_name;
@ -179,7 +181,7 @@ BLI_INLINE const float *bm_face_no_get(const MeshRenderData &mr, const BMFace *e
using ExtractTriBMeshFn = void(const MeshRenderData &mr, BMLoop **elt, int elt_index, void *data);
using ExtractTriMeshFn = void(const MeshRenderData &mr,
const blender::int3 &tri,
const int3 &tri,
int elt_index,
void *data);
using ExtractFaceBMeshFn = void(const MeshRenderData &mr,
@ -191,10 +193,7 @@ using ExtractLEdgeBMeshFn = void(const MeshRenderData &mr,
const BMEdge *eed,
int loose_edge_i,
void *data);
using ExtractLEdgeMeshFn = void(const MeshRenderData &mr,
blender::int2 edge,
int loose_edge_i,
void *data);
using ExtractLEdgeMeshFn = void(const MeshRenderData &mr, int2 edge, int loose_edge_i, void *data);
using ExtractLVertBMeshFn = void(const MeshRenderData &mr,
const BMVert *eve,
int loose_vert_i,
@ -372,3 +371,5 @@ extern const MeshExtract extract_vert_idx;
extern const MeshExtract extract_fdot_idx;
extern const MeshExtract extract_attr[GPU_MAX_ATTR];
extern const MeshExtract extract_attr_viewer;
} // namespace blender::draw

@ -591,9 +591,9 @@ constexpr MeshExtract create_extractor_edituv_fdots()
/** \} */
} // namespace blender::draw
const MeshExtract extract_edituv_tris = create_extractor_edituv_tris();
const MeshExtract extract_edituv_lines = create_extractor_edituv_lines();
const MeshExtract extract_edituv_points = create_extractor_edituv_points();
const MeshExtract extract_edituv_fdots = create_extractor_edituv_fdots();
const MeshExtract extract_edituv_tris = blender::draw::create_extractor_edituv_tris();
const MeshExtract extract_edituv_lines = blender::draw::create_extractor_edituv_lines();
const MeshExtract extract_edituv_points = blender::draw::create_extractor_edituv_points();
const MeshExtract extract_edituv_fdots = blender::draw::create_extractor_edituv_fdots();
} // namespace blender::draw

@ -93,6 +93,6 @@ constexpr MeshExtract create_extractor_fdots()
/** \} */
} // namespace blender::draw
const MeshExtract extract_fdots = create_extractor_fdots();
const MeshExtract extract_fdots = blender::draw::create_extractor_fdots();
} // namespace blender::draw

@ -398,9 +398,8 @@ constexpr MeshExtract create_extractor_lines_loose_only()
/** \} */
} // namespace blender::draw
const MeshExtract extract_lines = create_extractor_lines();
const MeshExtract extract_lines_with_lines_loose = create_extractor_lines_with_lines_loose();
const MeshExtract extract_lines_loose_only = create_extractor_lines_loose_only();
const MeshExtract extract_lines = blender::draw::create_extractor_lines();
const MeshExtract extract_lines_with_lines_loose =
blender::draw::create_extractor_lines_with_lines_loose();
const MeshExtract extract_lines_loose_only = blender::draw::create_extractor_lines_loose_only();
} // namespace blender::draw

@ -266,6 +266,6 @@ constexpr MeshExtract create_extractor_lines_adjacency()
/** \} */
} // namespace blender::draw
const MeshExtract extract_lines_adjacency = create_extractor_lines_adjacency();
const MeshExtract extract_lines_adjacency = blender::draw::create_extractor_lines_adjacency();
} // namespace blender::draw

@ -178,6 +178,6 @@ constexpr MeshExtract create_extractor_lines_paint_mask()
/** \} */
} // namespace blender::draw
const MeshExtract extract_lines_paint_mask = create_extractor_lines_paint_mask();
const MeshExtract extract_lines_paint_mask = blender::draw::create_extractor_lines_paint_mask();
} // namespace blender::draw

@ -220,8 +220,7 @@ static void extract_points_loose_geom_subdiv(const DRWSubdivCache &subdiv_cache,
uint offset = subdiv_cache.num_subdiv_loops;
if (mr.extract_type != MR_EXTRACT_BMESH) {
blender::Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(
subdiv_cache);
Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
for (const DRWSubdivLooseEdge &loose_edge : loose_edges) {
const DRWSubdivLooseVertex &v1 = loose_geom.verts[loose_edge.loose_subdiv_v1_index];
@ -235,8 +234,7 @@ static void extract_points_loose_geom_subdiv(const DRWSubdivCache &subdiv_cache,
offset += 2;
}
blender::Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts(
subdiv_cache);
Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts(subdiv_cache);
for (const DRWSubdivLooseVertex &loose_vert : loose_verts) {
vert_set_mesh(elb, mr, loose_vert.coarse_vertex_index, offset);
@ -244,8 +242,7 @@ static void extract_points_loose_geom_subdiv(const DRWSubdivCache &subdiv_cache,
}
}
else {
blender::Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(
subdiv_cache);
Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
for (const DRWSubdivLooseEdge &loose_edge : loose_edges) {
const DRWSubdivLooseVertex &v1 = loose_geom.verts[loose_edge.loose_subdiv_v1_index];
@ -263,8 +260,7 @@ static void extract_points_loose_geom_subdiv(const DRWSubdivCache &subdiv_cache,
offset += 2;
}
blender::Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts(
subdiv_cache);
Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts(subdiv_cache);
for (const DRWSubdivLooseVertex &loose_vert : loose_verts) {
BMVert *eve = mr.v_origindex ? bm_original_vert_get(mr, loose_vert.coarse_vertex_index) :
@ -312,6 +308,6 @@ constexpr MeshExtract create_extractor_points()
/** \} */
} // namespace blender::draw
const MeshExtract extract_points = create_extractor_points();
const MeshExtract extract_points = blender::draw::create_extractor_points();
} // namespace blender::draw

@ -246,7 +246,7 @@ constexpr MeshExtract create_extractor_tris_single_mat()
/** \} */
} // namespace blender::draw
const MeshExtract extract_tris = create_extractor_tris();
const MeshExtract extract_tris_single_mat = create_extractor_tris_single_mat();
const MeshExtract extract_tris = blender::draw::create_extractor_tris();
const MeshExtract extract_tris_single_mat = blender::draw::create_extractor_tris_single_mat();
} // namespace blender::draw

@ -188,7 +188,7 @@ static const CustomData *get_custom_data_for_domain(const BMesh &bm, bke::AttrDo
}
}
static void extract_attr(const MeshRenderData &mr,
static void extract_attribute(const MeshRenderData &mr,
const DRW_AttributeRequest &request,
GPUVertBuf &vbo)
{
@ -251,7 +251,7 @@ static void extract_attr_init(
const DRW_AttributeRequest &request = cache.attr_used.requests[index];
GPUVertBuf *vbo = static_cast<GPUVertBuf *>(buf);
init_vbo_for_attribute(mr, vbo, request, false, uint32_t(mr.loop_len));
extract_attr(mr, request, *vbo);
extract_attribute(mr, request, *vbo);
}
static void extract_attr_init_subdiv(const DRWSubdivCache &subdiv_cache,
@ -272,7 +272,7 @@ static void extract_attr_init_subdiv(const DRWSubdivCache &subdiv_cache,
GPU_vertbuf_init_with_format_ex(src_data, &coarse_format, GPU_USAGE_STATIC);
GPU_vertbuf_data_alloc(src_data, uint32_t(coarse_mesh->corners_num));
extract_attr(mr, request, *src_data);
extract_attribute(mr, request, *src_data);
GPUVertBuf *dst_buffer = static_cast<GPUVertBuf *>(buffer);
init_vbo_for_attribute(mr, dst_buffer, request, true, subdiv_cache.num_subdiv_loops);
@ -375,11 +375,8 @@ constexpr MeshExtract create_extractor_attr_viewer()
/** \} */
} // namespace blender::draw
#define CREATE_EXTRACTOR_ATTR(index) \
blender::draw::create_extractor_attr<index>(blender::draw::extract_attr_init##index, \
blender::draw::extract_attr_init_subdiv##index)
create_extractor_attr<index>(extract_attr_init##index, extract_attr_init_subdiv##index)
const MeshExtract extract_attr[GPU_MAX_ATTR] = {
CREATE_EXTRACTOR_ATTR(0),
@ -399,4 +396,6 @@ const MeshExtract extract_attr[GPU_MAX_ATTR] = {
CREATE_EXTRACTOR_ATTR(14),
};
const MeshExtract extract_attr_viewer = blender::draw::create_extractor_attr_viewer();
const MeshExtract extract_attr_viewer = create_extractor_attr_viewer();
} // namespace blender::draw

@ -350,6 +350,6 @@ constexpr MeshExtract create_extractor_edge_fac()
/** \} */
} // namespace blender::draw
const MeshExtract extract_edge_fac = create_extractor_edge_fac();
const MeshExtract extract_edge_fac = blender::draw::create_extractor_edge_fac();
} // namespace blender::draw

@ -313,7 +313,7 @@ static void extract_edit_data_loose_geom_subdiv(const DRWSubdivCache &subdiv_cac
return;
}
blender::Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
EditLoopData *vbo_data = *(EditLoopData **)_data;
int loose_edge_i = 0;
@ -363,6 +363,6 @@ constexpr MeshExtract create_extractor_edit_data()
/** \} */
} // namespace blender::draw
const MeshExtract extract_edit_data = create_extractor_edit_data();
const MeshExtract extract_edit_data = blender::draw::create_extractor_edit_data();
} // namespace blender::draw

@ -193,6 +193,6 @@ constexpr MeshExtract create_extractor_edituv_data()
/** \} */
} // namespace blender::draw
const MeshExtract extract_edituv_data = create_extractor_edituv_data();
const MeshExtract extract_edituv_data = blender::draw::create_extractor_edituv_data();
} // namespace blender::draw

@ -303,7 +303,6 @@ constexpr MeshExtract create_extractor_edituv_edituv_stretch_angle()
/** \} */
} // namespace blender::draw
const MeshExtract extract_edituv_stretch_angle = create_extractor_edituv_edituv_stretch_angle();
const MeshExtract extract_edituv_stretch_angle =
blender::draw::create_extractor_edituv_edituv_stretch_angle();
} // namespace blender::draw

@ -175,7 +175,6 @@ constexpr MeshExtract create_extractor_edituv_stretch_area()
/** \} */
} // namespace blender::draw
const MeshExtract extract_edituv_stretch_area = create_extractor_edituv_stretch_area();
const MeshExtract extract_edituv_stretch_area =
blender::draw::create_extractor_edituv_stretch_area();
} // namespace blender::draw

@ -79,6 +79,6 @@ constexpr MeshExtract create_extractor_fdots_edituv_data()
/** \} */
} // namespace blender::draw
const MeshExtract extract_fdots_edituv_data = create_extractor_fdots_edituv_data();
const MeshExtract extract_fdots_edituv_data = blender::draw::create_extractor_fdots_edituv_data();
} // namespace blender::draw

@ -175,7 +175,7 @@ constexpr MeshExtract create_extractor_fdots_nor_hq()
/** \} */
} // namespace blender::draw
const MeshExtract extract_fdots_nor = create_extractor_fdots_nor();
const MeshExtract extract_fdots_nor_hq = create_extractor_fdots_nor_hq();
const MeshExtract extract_fdots_nor = blender::draw::create_extractor_fdots_nor();
const MeshExtract extract_fdots_nor_hq = blender::draw::create_extractor_fdots_nor_hq();
} // namespace blender::draw

@ -133,6 +133,6 @@ constexpr MeshExtract create_extractor_fdots_pos()
/** \} */
} // namespace blender::draw
const MeshExtract extract_fdots_pos = create_extractor_fdots_pos();
const MeshExtract extract_fdots_pos = blender::draw::create_extractor_fdots_pos();
} // namespace blender::draw

@ -105,6 +105,6 @@ constexpr MeshExtract create_extractor_fdots_uv()
/** \} */
} // namespace blender::draw
const MeshExtract extract_fdots_uv = create_extractor_fdots_uv();
const MeshExtract extract_fdots_uv = blender::draw::create_extractor_fdots_uv();
} // namespace blender::draw

@ -231,7 +231,7 @@ constexpr MeshExtract create_extractor_lnor_hq()
/** \} */
} // namespace blender::draw
const MeshExtract extract_lnor = create_extractor_lnor();
const MeshExtract extract_lnor_hq = create_extractor_lnor_hq();
const MeshExtract extract_lnor = blender::draw::create_extractor_lnor();
const MeshExtract extract_lnor_hq = blender::draw::create_extractor_lnor_hq();
} // namespace blender::draw

@ -635,6 +635,6 @@ constexpr MeshExtract create_extractor_mesh_analysis()
/** \} */
} // namespace blender::draw
const MeshExtract extract_mesh_analysis = create_extractor_mesh_analysis();
const MeshExtract extract_mesh_analysis = blender::draw::create_extractor_mesh_analysis();
} // namespace blender::draw

@ -88,6 +88,6 @@ constexpr MeshExtract create_extractor_orco()
/** \} */
} // namespace blender::draw
const MeshExtract extract_orco = create_extractor_orco();
const MeshExtract extract_orco = blender::draw::create_extractor_orco();
} // namespace blender::draw

@ -330,7 +330,7 @@ static void extract_pos_nor_loose_geom_subdiv(const DRWSubdivCache &subdiv_cache
/* Make sure buffer is active for sending loose data. */
GPU_vertbuf_use(vbo);
blender::Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
SubdivPosNorLoop edge_data[2];
memset(edge_data, 0, sizeof(SubdivPosNorLoop) * 2);
@ -349,8 +349,7 @@ static void extract_pos_nor_loose_geom_subdiv(const DRWSubdivCache &subdiv_cache
SubdivPosNorLoop vert_data;
memset(&vert_data, 0, sizeof(SubdivPosNorLoop));
blender::Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts(
subdiv_cache);
Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts(subdiv_cache);
for (const DRWSubdivLooseVertex &loose_vert : loose_verts) {
copy_v3_v3(vert_data.pos, loose_vert.co);
@ -575,7 +574,7 @@ constexpr MeshExtract create_extractor_pos_nor_hq()
/** \} */
} // namespace blender::draw
const MeshExtract extract_pos_nor = create_extractor_pos_nor();
const MeshExtract extract_pos_nor_hq = create_extractor_pos_nor_hq();
const MeshExtract extract_pos_nor = blender::draw::create_extractor_pos_nor();
const MeshExtract extract_pos_nor_hq = blender::draw::create_extractor_pos_nor_hq();
} // namespace blender::draw

@ -211,6 +211,6 @@ constexpr MeshExtract create_extractor_sculpt_data()
/** \} */
} // namespace blender::draw
const MeshExtract extract_sculpt_data = create_extractor_sculpt_data();
const MeshExtract extract_sculpt_data = blender::draw::create_extractor_sculpt_data();
} // namespace blender::draw

@ -215,7 +215,7 @@ static void extract_vert_idx_loose_geom_subdiv(const DRWSubdivCache &subdiv_cach
int32_t *vert_idx_data = (int32_t *)GPU_vertbuf_get_data(vbo);
uint offset = subdiv_cache.num_subdiv_loops;
blender::Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
for (const DRWSubdivLooseEdge &loose_edge : loose_edges) {
const DRWSubdivLooseVertex &v1 = loose_geom.verts[loose_edge.loose_subdiv_v1_index];
@ -234,8 +234,7 @@ static void extract_vert_idx_loose_geom_subdiv(const DRWSubdivCache &subdiv_cach
offset += 2;
}
blender::Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts(
subdiv_cache);
Span<DRWSubdivLooseVertex> loose_verts = draw_subdiv_cache_get_loose_verts(subdiv_cache);
for (const DRWSubdivLooseVertex &loose_vert : loose_verts) {
vert_idx_data[offset] = mr.v_origindex ? mr.v_origindex[loose_vert.coarse_vertex_index] :
@ -273,7 +272,7 @@ static void extract_edge_idx_loose_geom_subdiv(const DRWSubdivCache &subdiv_cach
int32_t *vert_idx_data = (int32_t *)GPU_vertbuf_get_data(vbo);
uint offset = subdiv_cache.num_subdiv_loops;
blender::Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
Span<DRWSubdivLooseEdge> loose_edges = draw_subdiv_cache_get_loose_edges(subdiv_cache);
for (const DRWSubdivLooseEdge &loose_edge : loose_edges) {
const int coarse_edge_index = mr.e_origindex ? mr.e_origindex[loose_edge.coarse_edge_index] :
loose_edge.coarse_edge_index;
@ -399,9 +398,9 @@ constexpr MeshExtract create_extractor_fdot_idx()
/** \} */
} // namespace blender::draw
const MeshExtract extract_face_idx = create_extractor_face_idx();
const MeshExtract extract_edge_idx = create_extractor_edge_idx();
const MeshExtract extract_vert_idx = create_extractor_vert_idx();
const MeshExtract extract_fdot_idx = create_extractor_fdot_idx();
const MeshExtract extract_face_idx = blender::draw::create_extractor_face_idx();
const MeshExtract extract_edge_idx = blender::draw::create_extractor_edge_idx();
const MeshExtract extract_vert_idx = blender::draw::create_extractor_vert_idx();
const MeshExtract extract_fdot_idx = blender::draw::create_extractor_fdot_idx();
} // namespace blender::draw

@ -73,6 +73,6 @@ constexpr MeshExtract create_extractor_skin_roots()
/** \} */
} // namespace blender::draw
const MeshExtract extract_skin_roots = create_extractor_skin_roots();
const MeshExtract extract_skin_roots = blender::draw::create_extractor_skin_roots();
} // namespace blender::draw

@ -373,7 +373,7 @@ constexpr MeshExtract create_extractor_tan_hq()
/** \} */
} // namespace blender::draw
const MeshExtract extract_tan = create_extractor_tan();
const MeshExtract extract_tan_hq = create_extractor_tan_hq();
const MeshExtract extract_tan = blender::draw::create_extractor_tan();
const MeshExtract extract_tan_hq = blender::draw::create_extractor_tan_hq();
} // namespace blender::draw

@ -179,6 +179,6 @@ constexpr MeshExtract create_extractor_uv()
/** \} */
} // namespace blender::draw
const MeshExtract extract_uv = create_extractor_uv();
const MeshExtract extract_uv = blender::draw::create_extractor_uv();
} // namespace blender::draw

@ -207,6 +207,6 @@ constexpr MeshExtract create_extractor_weights()
/** \} */
} // namespace blender::draw
const MeshExtract extract_weights = create_extractor_weights();
const MeshExtract extract_weights = blender::draw::create_extractor_weights();
} // namespace blender::draw

@ -1623,6 +1623,7 @@ static void view3d_update_viewer_path(const bContext *C)
void view3d_main_region_draw(const bContext *C, ARegion *region)
{
using namespace blender::draw;
Main *bmain = CTX_data_main(C);
View3D *v3d = CTX_wm_view3d(C);
@ -1688,6 +1689,7 @@ void ED_view3d_draw_offscreen(Depsgraph *depsgraph,
GPUOffScreen *ofs,
GPUViewport *viewport)
{
using namespace blender::draw;
RegionView3D *rv3d = static_cast<RegionView3D *>(region->regiondata);
RenderEngineType *engine_type = ED_view3d_engine_type(scene, drawtype);

@ -607,7 +607,7 @@ void WM_exit_ex(bContext *C, const bool do_python_exit, const bool do_user_exit_
/* Free the GPU subdivision data after the database to ensure that subdivision structs used by
* the modifiers were garbage collected. */
if (gpu_is_init) {
DRW_subdiv_free();
blender::draw::DRW_subdiv_free();
}
ANIM_fcurves_copybuf_free();