41#ifdef DRW_DEBUG_CULLING
59#define DISABLE_DEBUG_SHADER_PRINT_BARRIER
73#define KEY(a) ((size_t((a).draw.batch) >> 6) % ARRAY_SIZE(idx))
76 for (
int i = 0; i < array_len; i++) {
78 if (++idx[
KEY(
array[i])] == array_len) {
87 for (
int src = array_len - 1; src >= 0; src--) {
92 memcpy(
array, array_tmp,
sizeof(*
array) * array_len);
99 int ubo_len = 1 + chunk_id - ((elem_id == 0) ? 1 : 0);
100 size_t list_size =
sizeof(GPUUniformBuf *) * ubo_len;
112 for (
int i = ubo_len; i < vmempool->
ubo_len; i++) {
117 if (ubo_len != vmempool->
ubo_len) {
120 vmempool->
obinfos_ubo =
static_cast<GPUUniformBuf **
>(
126 for (
int i = 0; i < ubo_len; i++) {
148 bool sortable =
true;
201 memcpy(uni->
ivalue, value,
sizeof(
int) * length);
205 memcpy(uni->
fvalue, value,
sizeof(
float) * length);
208 uni->
block = (GPUUniformBuf *)value;
211 uni->
block_ref = (GPUUniformBuf **)value;
215 uni->
texture = (GPUTexture *)value;
227 uni->
pvalue = (
const float *)value;
255 const GPUTexture *
tex,
306#ifdef DRW_UNUSED_RESOURCE_TRACKING
307 printf(
"%s:%d: Unable to locate binding of shader uniform buffer object: %s.\n",
328#ifdef DRW_UNUSED_RESOURCE_TRACKING
329 printf(
"%s:%d: Unable to locate binding of shader uniform buffer object: %s.\n",
351#ifdef DRW_UNUSED_RESOURCE_TRACKING
352 printf(
"%s:%d: Unable to locate binding of shader storage buffer object: %s.\n",
374#ifdef DRW_UNUSED_RESOURCE_TRACKING
375 printf(
"%s:%d: Unable to locate binding of shader storage buffer object: %s.\n",
520 const float (*value)[4])
524 if (location == -1) {
534 for (
int i = 0; i < 4; i++) {
550 if (location == -1) {
551#ifdef DRW_UNUSED_RESOURCE_TRACKING
552 printf(
"%s:%d: Unable to locate binding of shader storage buffer object: %s.\n",
557 BLI_assert_msg(0,
"Unable to locate binding of shader storage buffer objects.");
576 if (location == -1) {
577#ifdef DRW_UNUSED_RESOURCE_TRACKING
578 printf(
"%s:%d: Unable to locate binding of shader storage buffer object: %s.\n",
583 BLI_assert_msg(0,
"Unable to locate binding of shader storage buffer objects.");
601 if (location == -1) {
618 if (location == -1) {
637 const ID *ob_data = (ob) ?
static_cast<const ID *
>(ob->
data) :
nullptr;
639 float texspace_location[3], texspace_size[3];
641 float *texspace_location =
nullptr;
642 float *texspace_size =
nullptr;
643 if (ob_data !=
nullptr) {
644 switch (
GS(ob_data->
name)) {
646 const Volume &volume = *
reinterpret_cast<const Volume *
>(ob_data);
649 texspace_location = static_buf.texspace_location;
650 texspace_size = static_buf.texspace_size;
653 texspace_size[0] = std::max(texspace_size[0], 0.001f);
654 texspace_size[1] = std::max(texspace_size[1], 0.001f);
655 texspace_size[2] = std::max(texspace_size[2], 0.001f);
661 (
Mesh *)ob_data,
nullptr, &texspace_location, &texspace_size);
681 if ((texspace_location !=
nullptr) && (texspace_size !=
nullptr)) {
684 sub_v3_v3v3(r_orcofacs[0], texspace_location, texspace_size);
696 const float (*obmat)[4])
742 std::optional<Bounds<float3>>
bounds;
797 return handle & ~(1u << 31);
801 const float (*obmat)[4],
805 if (obmat ==
nullptr) {
842 command_type_bits[index / 16] |=
uint64_t(type) << ((index % 16) * 4);
847 return eDRWCommandType((command_type_bits[index / 16] >> ((index % 16) * 4)) & 0xF);
854 if (chunk ==
nullptr) {
877 blender::gpu::Batch *
batch,
886 blender::gpu::Batch *
batch,
900 blender::gpu::Batch *
batch,
914 blender::gpu::Batch *
batch,
961 blender::gpu::Batch *
batch,
973 blender::gpu::Batch *
batch,
975 GPUStorageBuf *indirect_buf)
989 BLI_assert(buf ==
nullptr || select_id == -1);
1008 cmd->
ref = reference;
1044 const float (*obmat)[4],
1045 blender::gpu::Batch *geom,
1046 bool bypass_culling,
1054 shgroup, ob ? ob->object_to_world().ptr() : obmat, ob);
1058 if (user_data || bypass_culling) {
1065 if (bypass_culling) {
1080 shgroup, ob ? ob->object_to_world().ptr() :
nullptr, ob);
1092 shgroup, ob ? ob->object_to_world().ptr() :
nullptr, ob);
1101 BLI_assert(groups_x_len > 0 && groups_y_len > 0 && groups_z_len > 0);
1121 blender::gpu::Batch *geom,
1131 shgroup, ob ? ob->object_to_world().ptr() :
nullptr, ob);
1160 GPUStorageBuf *indirect_buf)
1162 blender::gpu::Batch *geom =
nullptr;
1163 switch (primitive_type) {
1178 "Unsupported primitive type in DRW_shgroup_call_procedural_indirect. Add new "
1186 shgroup, ob ? ob->object_to_world().ptr() :
nullptr, ob);
1192 blender::gpu::Batch *geom,
1200 shgroup, ob ? ob->object_to_world().ptr() :
nullptr, ob);
1206 blender::gpu::Batch *geom,
1207 blender::gpu::Batch *inst_attributes)
1215 shgroup, ob ? ob->object_to_world().ptr() :
nullptr, ob);
1221#define SCULPT_DEBUG_BUFFERS (G.debug_value == 889)
1236#define SCULPT_DEBUG_COLOR(id) (sculpt_debug_colors[id % 9])
1238 {1.0f, 0.2f, 0.2f, 1.0f},
1239 {0.2f, 1.0f, 0.2f, 1.0f},
1240 {0.2f, 0.2f, 1.0f, 1.0f},
1241 {1.0f, 1.0f, 0.2f, 1.0f},
1242 {0.2f, 1.0f, 1.0f, 1.0f},
1243 {1.0f, 0.2f, 1.0f, 1.0f},
1244 {1.0f, 0.7f, 0.2f, 1.0f},
1245 {0.2f, 1.0f, 0.7f, 1.0f},
1246 {0.7f, 0.2f, 1.0f, 1.0f},
1259 const int material_index = material_indices.
is_empty() ? 0 : material_indices[i];
1278 const float bmin[3],
1279 const float bmax[3],
1282 int *debug_node_nr = (
int *)user_data;
1296 int color = (*debug_node_nr)++;
1314 for (
int i = 0; i < 6; i++) {
1335 Paint *paint =
nullptr;
1336 if (drwctx->
evil_C !=
nullptr) {
1341 float update_planes[6][4];
1342 float draw_planes[6][4];
1347 update_frustum.
planes = update_planes;
1349 bke::pbvh::get_frustum_planes(*pbvh, &update_frustum);
1352 update_frustum.
planes = update_planes;
1354 bke::pbvh::set_frustum_planes(*pbvh, &update_frustum);
1359 update_frustum.
planes = update_planes;
1364 draw_frustum.
planes = draw_planes;
1377 update_only_visible =
true;
1380 bke::pbvh::update_normals_from_eval(*
const_cast<Object *
>(scd->
ob), *pbvh);
1384 IndexMaskMemory memory;
1385 const IndexMask visible_nodes = bke::pbvh::search_nodes(
1391 const IndexMask nodes_to_update = update_only_visible ? visible_nodes :
1392 bke::pbvh::all_leaf_nodes(*pbvh, memory);
1415 int debug_node_nr = 0;
1438 scd.shading_groups = &shgroup;
1439 scd.num_shading_groups = 1;
1440 scd.use_wire = use_wire;
1441 scd.use_mats =
false;
1442 scd.use_mask = use_mask;
1444 Vector<pbvh::AttributeRequest, 16> attrs;
1446 attrs.append(pbvh::CustomRequest::Position);
1447 attrs.append(pbvh::CustomRequest::Normal);
1449 attrs.append(pbvh::CustomRequest::Mask);
1452 attrs.append(pbvh::CustomRequest::FaceSet);
1459 if (
const char *name = mesh->active_color_attribute) {
1460 if (
const std::optional<bke::AttributeMetaData> meta_data = attributes.lookup_meta_data(
1489 const Mesh *mesh =
static_cast<const Mesh *
>(ob->
data);
1492 DRW_mesh_get_attributes(*ob, *mesh, gpumats, num_shgroups, &draw_attrs, &cd_needed);
1495 memset(&draw_attrs, 0,
sizeof(draw_attrs));
1496 memset(&cd_needed, 0,
sizeof(cd_needed));
1501 attrs.
append(pbvh::CustomRequest::Position);
1502 attrs.
append(pbvh::CustomRequest::Normal);
1510 for (
uint i = 0; i < 32; i++) {
1511 if (cd_needed.
uv & (1 << i)) {
1513 CustomDataLayer *layer = layer_i != -1 ? mesh->corner_data.layers + layer_i :
nullptr;
1522 scd.shading_groups = shgroups;
1523 scd.num_shading_groups = num_shgroups;
1524 scd.use_wire =
false;
1525 scd.use_mats =
true;
1526 scd.use_mask =
false;
1527 scd.attrs = std::move(attrs);
1567 blender::gpu::Batch *geom)
1629 for (
int i = 0; i < attr_len; i++) {
1663 if (view_ubo_location == -1) {
1666 if (model_ubo_location == -1) {
1669 if (info_ubo_location == -1) {
1673 if (chunkid_location != -1) {
1683 if (resourceid_location != -1) {
1685 resourceid_location,
1693 if (baseinst_location != -1) {
1703 if (model_ubo_location != -1) {
1726 if (modelinverse != -1) {
1737 if (info_ubo_location != -1) {
1753 if (view_ubo_location != -1) {
1763 if (clipping_ubo_location != -1) {
1765 clipping_ubo_location,
1794 shgroup->
shader = shader;
1828 *gputex_ref = gputex;
1839 const bool use_tile_mapping =
tex->tiled_mapping_name[0];
1842 tex->
ima, iuser, use_tile_mapping);
1850 else if (
tex->colorband) {
1854 else if (
tex->sky) {
1861 if (ubo !=
nullptr) {
1866 if (uattrs !=
nullptr) {
1885 for (
int i = 0; i < arraysize; i++) {
1969 for (; chunk; chunk = chunk->
next) {
1984 *shgroup_new = *shgroup;
1987 shgroup_new->
cmd.
last =
nullptr;
2010 const float (*projmat)[4],
2013 float left, right, bottom,
top, near, far;
2014 bool is_persp = projmat[3][3] == 0.0f;
2019 for (
int i = 0; i < 8; i++) {
2026 r_bbox->
vec[0][2] = r_bbox->
vec[3][2] = r_bbox->
vec[7][2] = r_bbox->
vec[4][2] = -near;
2027 r_bbox->
vec[0][0] = r_bbox->
vec[3][0] =
left;
2028 r_bbox->
vec[4][0] = r_bbox->
vec[7][0] = right;
2029 r_bbox->
vec[0][1] = r_bbox->
vec[4][1] = bottom;
2030 r_bbox->
vec[7][1] = r_bbox->
vec[3][1] =
top;
2034 float sca_far = far / near;
2041 r_bbox->
vec[1][2] = r_bbox->
vec[2][2] = r_bbox->
vec[6][2] = r_bbox->
vec[5][2] = -far;
2042 r_bbox->
vec[1][0] = r_bbox->
vec[2][0] =
left;
2043 r_bbox->
vec[6][0] = r_bbox->
vec[5][0] = right;
2044 r_bbox->
vec[1][1] = r_bbox->
vec[5][1] = bottom;
2045 r_bbox->
vec[2][1] = r_bbox->
vec[6][1] =
top;
2048 for (
int i = 0; i < 8; i++) {
2064 for (
int p = 0; p < 6; p++) {
2065 frustum_planes[p][3] /=
normalize_v3(frustum_planes[p]);
2070 const float (*viewinv)[4],
2071 const float (*projmat)[4],
2072 const float (*projinv)[4],
2076 if (projmat[3][3] != 0.0f) {
2079 const float *nearpoint = bbox->
vec[0];
2080 const float *farpoint = bbox->
vec[6];
2086 else if (projmat[2][0] == 0.0f && projmat[2][1] == 0.0f) {
2093 float mid_min[3], mid_max[3];
2104 float fac = (4 * h_sq + b_sq - a_sq) / (8 * h_sq);
2108 CLAMP(fac, 0.0f, 1.0f);
2124 float farpoint[3] = {0.0f};
2126 float farcenter[3] = {0.0f};
2135 float corner[3] = {1.0f, 1.0f, 1.0f};
2136 for (
int i = 0; i < 4; i++) {
2147 float tmp = corner[0];
2148 corner[0] = -corner[1];
2167 n = f * s /
e -
len_v2(nearpoint);
2170 z = (F -
N) / (2.0f * (
e - s + c * (f - n)));
2172 bsphere->
center[0] = farcenter[0] *
z /
e;
2173 bsphere->
center[1] = farcenter[1] *
z /
e;
2185 const float viewmat[4][4],
2186 const float winmat[4][4])
2196 mul_m4_m4m4(view->persmat.ptr(), winmat, viewmat);
2197 invert_m4_m4(view->persinv.ptr(), view->persmat.ptr());
2201 const float winmat[4][4],
2202 const float (*culling_viewmat)[4],
2203 const float (*culling_winmat)[4],
2213 view->culling_mask = 0u;
2215 view->clip_planes_len = 0;
2216 view->visibility_fn = visibility_fn;
2217 view->parent =
nullptr;
2219 DRW_view_update(view, viewmat, winmat, culling_viewmat, culling_winmat);
2225 const float viewmat[4][4],
2226 const float winmat[4][4])
2229 const DRWView *ori_view = parent_view;
2230 while (ori_view->
parent !=
nullptr) {
2231 ori_view = ori_view->
parent;
2253 view->is_dirty =
true;
2260 const float viewmat[4][4],
2261 const float winmat[4][4],
2262 const float (*culling_viewmat)[4],
2263 const float (*culling_winmat)[4])
2270 view->is_dirty =
true;
2277#ifdef DRW_DEBUG_CULLING
2281 if (view->culling_mask != 0) {
2284 if (
G.debug_value == 0) {
2285 copy_m4_m4(
mv[index], culling_viewmat ? culling_viewmat : viewmat);
2286 copy_m4_m4(mw[index], culling_winmat ? culling_winmat : winmat);
2289 culling_winmat = mw[index];
2290 culling_viewmat =
mv[index];
2296 if (culling_winmat) {
2297 winmat = culling_winmat;
2301 copy_m4_m4(wininv, view->storage.wininv.ptr());
2304 float viewinv[4][4];
2305 if (culling_viewmat) {
2306 viewmat = culling_viewmat;
2310 copy_m4_m4(viewinv, view->storage.viewinv.ptr());
2316 &view->frustum_corners, viewinv, winmat, wininv, &view->frustum_bsphere);
2318#ifdef DRW_DEBUG_CULLING
2319 if (
G.debug_value != 0) {
2321 view->frustum_bsphere.center, view->frustum_bsphere.radius,
blender::float4{1, 1, 0, 1});
2348 view->clip_planes_len = plane_len;
2349 if (plane_len > 0) {
2350 memcpy(view->clip_planes, planes,
sizeof(
float[4]) * plane_len);
2356 memcpy(corners, &view->frustum_corners,
sizeof(view->frustum_corners));
2361 memcpy(planes, &view->frustum_planes,
sizeof(view->frustum_planes));
2373 const float4x4 &projmat = view->storage.winmat;
2376 return -projmat[3][2] / (projmat[2][2] - 1.0f);
2379 return -(projmat[3][2] + 1.0f) / projmat[2][2];
2385 const float4x4 &projmat = view->storage.winmat;
2388 return -projmat[3][2] / (projmat[2][2] + 1.0f);
2391 return -(projmat[3][2] - 1.0f) / projmat[2][2];
2428 pass->shgroups.first =
nullptr;
2429 pass->shgroups.last =
nullptr;
2433 pass->original =
nullptr;
2434 pass->next =
nullptr;
2442 pass->original = original;
2451 first->
next = second;
2456 if (pass->original) {
2499#define SORT_IMPL_LINKTYPE DRWShadingGroup
2501#define SORT_IMPL_FUNC shgroup_sort_fn_r
2503#undef SORT_IMPL_FUNC
2505#undef SORT_IMPL_LINKTYPE
2511 if (!(pass->shgroups.first && pass->shgroups.first->next)) {
2522 for (; cmd_chunk && handle == 0; cmd_chunk = cmd_chunk->
next) {
2523 for (
int i = 0; i < cmd_chunk->
command_used && handle == 0; i++) {
2544 }
while ((shgroup = shgroup->
next));
2551 while ((last = last->
next)) {
2555 pass->shgroups.last = last;
2560 pass->shgroups.
last = pass->shgroups.first;
void BKE_curve_texspace_ensure(Curve *cu)
int CustomData_get_layer_index_n(const CustomData *data, eCustomDataType type, int n)
const char * CustomData_get_active_layer_name(const CustomData *data, eCustomDataType type)
ImageGPUTextures BKE_image_get_gpu_material_texture(Image *image, ImageUser *iuser, const bool use_tile_mapping)
void BKE_mesh_texspace_get_reference(Mesh *mesh, char **r_texspace_flag, float **r_texspace_location, float **r_texspace_size)
General operations, lookup, etc. for blender objects.
void BKE_boundbox_init_from_minmax(BoundBox *bb, const float min[3], const float max[3])
std::optional< blender::Bounds< blender::float3 > > BKE_object_boundbox_get(const Object *ob)
Mesh * BKE_object_get_original_mesh(const Object *object)
Paint * BKE_paint_get_active_from_context(const bContext *C)
void BKE_pbvh_draw_debug_cb(blender::bke::pbvh::Tree &pbvh, void(*draw_fn)(blender::bke::pbvh::Node *node, void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag), void *user_data)
bool BKE_pbvh_node_fully_hidden_get(const blender::bke::pbvh::Node &node)
int BKE_pbvh_debug_draw_gen_get(blender::bke::pbvh::Node &node)
bool BKE_pbvh_node_frustum_contain_AABB(const blender::bke::pbvh::Node *node, const PBVHFrustumPlanes *frustum)
std::optional< blender::Bounds< blender::float3 > > BKE_volume_min_max(const Volume *volume)
#define BLI_assert_msg(a, msg)
BLI_INLINE unsigned int BLI_hash_string(const char *str)
BLI_INLINE unsigned int BLI_hash_int_2d(unsigned int kx, unsigned int ky)
Single link-list utility macros. (header only api).
#define BLI_LINKS_PREPEND(list, link)
#define BLI_LINKS_INSERT_AFTER(list, node, link)
#define BLI_LINKS_APPEND(list, link)
void BLI_linklist_reverse(LinkNode **listp) ATTR_NONNULL(1)
#define LISTBASE_FOREACH(type, var, list)
MINLINE unsigned int bitscan_forward_uint(unsigned int a)
void projmat_dimensions(const float winmat[4][4], float *r_left, float *r_right, float *r_bottom, float *r_top, float *r_near, float *r_far)
void planes_from_projmat(const float mat[4][4], float left[4], float right[4], float bottom[4], float top[4], float near[4], float far[4])
void mul_v3_project_m4_v3(float r[3], const float mat[4][4], const float vec[3])
void mul_m4_m4m4(float R[4][4], const float A[4][4], const float B[4][4])
void transpose_m4_m4(float R[4][4], const float M[4][4])
void mul_project_m4_v3(const float mat[4][4], float vec[3])
void mul_m4_v3(const float M[4][4], float r[3])
void copy_m4_m4(float m1[4][4], const float m2[4][4])
void mul_v3_m4v3(float r[3], const float mat[4][4], const float vec[3])
bool is_negative_m4(const float mat[4][4])
bool invert_m4_m4(float inverse[4][4], const float mat[4][4])
void mul_m4_v4(const float mat[4][4], float r[4])
MINLINE void copy_v4_v4(float r[4], const float a[4])
MINLINE float len_v2(const float v[2]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_squared_v3(const float v[3]) ATTR_WARN_UNUSED_RESULT
MINLINE float len_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v2_v2(float r[2], const float a[2])
MINLINE void mul_v3_v3(float r[3], const float a[3])
MINLINE float len_squared_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
MINLINE void sub_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void mul_v3_fl(float r[3], float f)
MINLINE void copy_v3_v3(float r[3], const float a[3])
MINLINE void copy_v3_fl3(float v[3], float x, float y, float z)
MINLINE float dot_v3v3(const float a[3], const float b[3]) ATTR_WARN_UNUSED_RESULT
void interp_v3_v3v3(float r[3], const float a[3], const float b[3], float t)
MINLINE void negate_v3(float r[3])
MINLINE void invert_v3(float r[3])
void mid_v3_v3v3(float r[3], const float a[3], const float b[3])
MINLINE void copy_v3_fl(float r[3], float f)
MINLINE void mul_v3_v3fl(float r[3], const float a[3], float f)
MINLINE void mul_v2_v2fl(float r[2], const float a[2], float f)
MINLINE void add_v3_v3(float r[3], const float a[3])
MINLINE float normalize_v3(float n[3])
void * BLI_memblock_elem_get(BLI_memblock *mblk, int chunk, int elem) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
void * BLI_memblock_alloc(BLI_memblock *mblk) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL(1)
void BLI_memblock_iternew(BLI_memblock *mblk, BLI_memblock_iter *iter) ATTR_NONNULL()
void * BLI_memblock_iterstep(BLI_memblock_iter *iter) ATTR_WARN_UNUSED_RESULT ATTR_NONNULL()
#define STRNCPY(dst, src)
#define UNUSED_VARS_NDEBUG(...)
#define BASE_SELECTED(v3d, base)
@ PAINT_SCULPT_DELAY_UPDATES
#define DRW_shgroup_call_no_cull(shgroup, geom, ob)
#define DRW_DEBUG_FILE_LINE_ARGS
bool DRWCallVisibilityFn(bool vis_in, void *user_data)
#define DRW_shgroup_uniform_block(shgroup, name, ubo)
GPUPass * GPU_material_get_pass(GPUMaterial *material)
const ListBase * GPU_material_layer_attributes(const GPUMaterial *material)
ListBase GPU_material_textures(GPUMaterial *material)
const GPUUniformAttrList * GPU_material_uniform_attributes(const GPUMaterial *material)
GPUUniformBuf * GPU_material_uniform_buffer_get(GPUMaterial *material)
int GPU_shader_get_sampler_binding(GPUShader *shader, const char *name)
int GPU_shader_get_uniform(GPUShader *shader, const char *name)
int GPU_shader_get_ubo_binding(GPUShader *shader, const char *name)
int GPU_shader_get_ssbo_binding(GPUShader *shader, const char *name)
int GPU_shader_get_builtin_block(GPUShader *shader, int builtin)
@ GPU_UNIFORM_VIEWPROJECTION_INV
@ GPU_UNIFORM_RESOURCE_ID
@ GPU_UNIFORM_VIEWPROJECTION
@ GPU_UNIFORM_BASE_INSTANCE
@ GPU_UNIFORM_PROJECTION_INV
@ GPU_UNIFORM_MODELVIEW_INV
@ GPU_UNIFORM_RESOURCE_CHUNK
int GPU_shader_get_builtin_uniform(GPUShader *shader, int builtin)
@ GPU_UNIFORM_BLOCK_DRW_VIEW
@ GPU_UNIFORM_BLOCK_DRW_MODEL
@ GPU_UNIFORM_BLOCK_MODEL
@ GPU_UNIFORM_BLOCK_DRW_CLIPPING
@ GPU_UNIFORM_BLOCK_DRW_INFOS
void GPU_texture_ref(GPUTexture *texture)
void GPU_vertbuf_vert_set(blender::gpu::VertBuf *verts, uint v_idx, const void *data)
void GPU_vertbuf_data_resize(blender::gpu::VertBuf &verts, uint v_len)
void GPU_vertbuf_attr_set(blender::gpu::VertBuf *, uint a_idx, uint v_idx, const void *data)
const GPUVertFormat * GPU_vertbuf_get_format(const blender::gpu::VertBuf *verts)
uint GPU_vertbuf_get_vertex_alloc(const blender::gpu::VertBuf *verts)
#define MEM_recallocN(vmemh, len)
Group Output data from inside of a node group A color picker Mix two input colors RGB to Convert a color s luminance to a grayscale value Generate a normal vector and a dot product Brightness Control the brightness and contrast of the input color Vector Map input vector components with curves Camera Retrieve information about the camera and how it relates to the current shading point s position Clamp a value between a minimum and a maximum Vector Perform vector math operation Invert Invert a producing a negative Combine Generate a color from its and blue channels(Deprecated)") DefNode(ShaderNode
struct GPUShader GPUShader
ATTR_WARN_UNUSED_RESULT const BMVert const BMEdge * e
static btDbvtVolume bounds(btDbvtNode **leaves, int count)
btMatrix3x3 inverse() const
Return the inverse of the matrix.
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
SIMD_FORCE_INLINE btScalar length() const
Return the length of the vector.
constexpr bool is_empty() const
void append(const T &value)
std::unique_ptr< DrawCache > draw_data
virtual Span< int > ensure_material_indices(const Object &object)=0
virtual Span< gpu::Batch * > ensure_lines_batches(const Object &object, const ViewportRequest &request, const IndexMask &nodes_to_update)=0
virtual Span< gpu::Batch * > ensure_tris_batches(const Object &object, const ViewportRequest &request, const IndexMask &nodes_to_update)=0
void foreach_index(Fn &&fn) const
local_group_size(16, 16) .push_constant(Type b
DEGForeachIDComponentCallback callback
Utilities for rendering attributes.
blender::gpu::Batch * drw_cache_procedural_lines_get()
blender::gpu::Batch * drw_cache_procedural_triangles_get()
blender::gpu::Batch * drw_cache_procedural_triangle_strips_get()
blender::gpu::Batch * drw_cache_procedural_points_get()
void DRW_debug_modelmat(const float modelmat[4][4])
void DRW_debug_sphere(const float center[3], float radius, const float color[4])
void DRW_debug_bbox(const BoundBox *bbox, const float color[4])
blender::gpu::Batch * DRW_temp_batch_request(DRWInstanceDataList *idatalist, blender::gpu::VertBuf *buf, GPUPrimType prim_type)
void DRW_uniform_attrs_pool_flush_all(GHash *table)
blender::gpu::VertBuf * DRW_temp_buffer_request(DRWInstanceDataList *idatalist, GPUVertFormat *format, int *vert_len)
blender::gpu::Batch * DRW_temp_batch_instance_request(DRWInstanceDataList *idatalist, blender::gpu::VertBuf *buf, blender::gpu::Batch *instancer, blender::gpu::Batch *geom)
void drw_uniform_attrs_pool_update(GHash *table, const GPUUniformAttrList *key, DRWResourceHandle *handle, const Object *ob, const Object *dupli_parent, const DupliObject *dupli_source)
#define DRW_BUFFER_VERTS_CHUNK
Object * DRW_object_get_dupli_parent(const Object *)
const DRWContextState * DRW_context_state_get()
BLI_INLINE void * DRW_memblock_elem_from_handle(BLI_memblock *memblock, const DRWResourceHandle *handle)
#define DRW_MAX_DRAW_CMD_TYPE
@ DRW_UNIFORM_VERTEX_BUFFER_AS_TEXTURE_REF
@ DRW_UNIFORM_BLOCK_OBINFOS
@ DRW_UNIFORM_TFEEDBACK_TARGET
@ DRW_UNIFORM_TEXTURE_REF
@ DRW_UNIFORM_MODEL_MATRIX
@ DRW_UNIFORM_VERTEX_BUFFER_AS_STORAGE
@ DRW_UNIFORM_MODEL_MATRIX_INVERSE
@ DRW_UNIFORM_VERTEX_BUFFER_AS_STORAGE_REF
@ DRW_UNIFORM_BASE_INSTANCE
@ DRW_UNIFORM_BLOCK_OBMATS
@ DRW_UNIFORM_RESOURCE_ID
@ DRW_UNIFORM_STORAGE_BLOCK_REF
@ DRW_UNIFORM_VERTEX_BUFFER_AS_TEXTURE
@ DRW_UNIFORM_RESOURCE_CHUNK
@ DRW_UNIFORM_BLOCK_OBATTRS
@ DRW_UNIFORM_STORAGE_BLOCK
@ DRW_UNIFORM_BLOCK_VLATTRS
BLI_INLINE uint32_t DRW_handle_chunk_get(const DRWResourceHandle *handle)
#define DRW_RESOURCE_CHUNK_LEN
@ DRW_CMD_COMPUTE_INDIRECT
@ DRW_CMD_DRAW_INSTANCE_RANGE
@ DRW_CMD_DRAW_PROCEDURAL
BLI_INLINE void DRW_handle_increment(DRWResourceHandle *handle)
BLI_INLINE uint32_t DRW_handle_id_get(const DRWResourceHandle *handle)
uint32_t DRWResourceHandle
BLI_INLINE void DRW_handle_negative_scale_enable(DRWResourceHandle *handle)
const DRWView * DRW_view_default_get()
DRWShadingGroup * DRW_shgroup_create(GPUShader *shader, DRWPass *pass)
static void drw_command_compute(DRWShadingGroup *shgroup, int groups_x_len, int groups_y_len, int groups_z_len)
void DRW_view_frustum_corners_get(const DRWView *view, BoundBox *corners)
float DRW_view_near_distance_get(const DRWView *view)
void DRW_shgroup_uniform_float_copy(DRWShadingGroup *shgroup, const char *name, const float value)
void drw_resource_buffer_finish(DRWData *vmempool)
static void drw_command_draw(DRWShadingGroup *shgroup, blender::gpu::Batch *batch, DRWResourceHandle handle)
static void * drw_command_create(DRWShadingGroup *shgroup, eDRWCommandType type)
void DRW_shgroup_call_ex(DRWShadingGroup *shgroup, const Object *ob, const float(*obmat)[4], blender::gpu::Batch *geom, bool bypass_culling, void *user_data)
void DRW_view_persmat_get(const DRWView *view, float mat[4][4], bool inverse)
void DRW_shgroup_state_disable(DRWShadingGroup *shgroup, DRWState state)
bool DRW_shgroup_is_empty(DRWShadingGroup *shgroup)
void DRW_shgroup_uniform_texture_ex(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex, GPUSamplerState sampler_state)
void DRW_shgroup_buffer_texture(DRWShadingGroup *shgroup, const char *name, blender::gpu::VertBuf *vertex_buffer)
static void drw_command_barrier(DRWShadingGroup *shgroup, eGPUBarrier type)
void DRW_view_frustum_planes_get(const DRWView *view, float planes[6][4])
void DRW_shgroup_uniform_vec4(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
eDRWCommandType command_type_get(const uint64_t *command_type_bits, int index)
static void command_type_set(uint64_t *command_type_bits, int index, eDRWCommandType type)
void DRW_shgroup_uniform_texture(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
static void drw_command_compute_ref(DRWShadingGroup *shgroup, int groups_ref[3])
void DRW_shgroup_uniform_ivec3_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
uint32_t DRW_object_resource_id_get(Object *)
static int pass_shgroup_dist_sort(const void *a, const void *b)
static void drw_command_draw_procedural(DRWShadingGroup *shgroup, blender::gpu::Batch *batch, DRWResourceHandle handle, uint vert_count)
static void drw_call_culling_init(DRWCullingState *cull, const Object *ob)
void DRW_pass_foreach_shgroup(DRWPass *pass, void(*callback)(void *user_data, DRWShadingGroup *shgrp), void *user_data)
void DRW_shgroup_call_instances_with_attrs(DRWShadingGroup *shgroup, const Object *ob, blender::gpu::Batch *geom, blender::gpu::Batch *inst_attributes)
void DRW_buffer_add_entry_struct(DRWCallBuffer *callbuf, const void *data)
void DRW_shgroup_stencil_set(DRWShadingGroup *shgroup, uint write_mask, uint reference, uint compare_mask)
static void drw_shgroup_uniform_create_ex(DRWShadingGroup *shgroup, int loc, DRWUniformType type, const void *value, GPUSamplerState sampler_state, int length, int arraysize)
DRWPass * DRW_pass_create(const char *name, DRWState state)
static DRWResourceHandle drw_resource_handle(DRWShadingGroup *shgroup, const float(*obmat)[4], const Object *ob)
void DRW_shgroup_call_instances(DRWShadingGroup *shgroup, const Object *ob, blender::gpu::Batch *geom, uint count)
void DRW_shgroup_call_compute_indirect(DRWShadingGroup *shgroup, GPUStorageBuf *indirect_buf)
void DRW_buffer_add_entry_array(DRWCallBuffer *callbuf, const void *attr[], uint attr_len)
static void draw_call_sort(DRWCommand *array, DRWCommand *array_tmp, int array_len)
void DRW_shgroup_state_enable(DRWShadingGroup *shgroup, DRWState state)
static DRWShadingGroup * drw_shgroup_material_create_ex(GPUPass *gpupass, DRWPass *pass)
void DRW_shgroup_uniform_ivec2_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
DRWCallBuffer * DRW_shgroup_call_buffer_instance(DRWShadingGroup *shgroup, GPUVertFormat *format, blender::gpu::Batch *geom)
void DRW_pass_link(DRWPass *first, DRWPass *second)
void DRW_shgroup_uniform_vec3_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_shgroup_uniform_vec3(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
bool DRW_view_is_persp_get(const DRWView *view)
void DRW_shgroup_call_sculpt(DRWShadingGroup *shgroup, Object *ob, bool use_wire, bool use_mask, bool use_fset, bool use_color, bool use_uv)
void DRW_shgroup_uniform_ivec2(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
void DRW_sculpt_debug_cb(blender::bke::pbvh::Node *node, void *user_data, const float bmin[3], const float bmax[3], PBVHNodeFlags flag)
DRWShadingGroup * DRW_shgroup_create_sub(DRWShadingGroup *shgroup)
void DRW_shgroup_call_compute(DRWShadingGroup *shgroup, int groups_x_len, int groups_y_len, int groups_z_len)
static void drw_command_draw_instance(DRWShadingGroup *shgroup, blender::gpu::Batch *batch, DRWResourceHandle handle, uint count, bool use_attr)
static void drw_command_draw_intance_range(DRWShadingGroup *shgroup, blender::gpu::Batch *batch, DRWResourceHandle handle, uint start, uint count)
static void drw_command_set_mutable_state(DRWShadingGroup *shgroup, DRWState enable, DRWState disable)
DRWView * DRW_view_create_sub(const DRWView *parent_view, const float viewmat[4][4], const float winmat[4][4])
static void drw_shgroup_material_texture(DRWShadingGroup *grp, GPUTexture *gputex, const char *name, GPUSamplerState state)
void DRW_shgroup_barrier(DRWShadingGroup *shgroup, eGPUBarrier type)
void DRW_shgroup_uniform_ivec3(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
static void drw_command_compute_indirect(DRWShadingGroup *shgroup, GPUStorageBuf *indirect_buf)
void DRW_view_winmat_get(const DRWView *view, float mat[4][4], bool inverse)
void DRW_shgroup_uniform_int_copy(DRWShadingGroup *shgroup, const char *name, const int value)
static void drw_call_obinfos_init(DRWObjectInfos *ob_infos, const Object *ob)
void DRW_pass_sort_shgroup_z(DRWPass *pass)
bool DRW_pass_is_empty(DRWPass *pass)
#define SCULPT_DEBUG_BUFFERS
static void drw_call_calc_orco(const Object *ob, float(*r_orcofacs)[4])
void DRW_shgroup_uniform_bool(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
void DRW_shgroup_uniform_mat3(DRWShadingGroup *shgroup, const char *name, const float(*value)[3])
static void drw_command_set_select_id(DRWShadingGroup *shgroup, blender::gpu::VertBuf *buf, uint select_id)
void DRW_shgroup_call_compute_ref(DRWShadingGroup *shgroup, int groups_ref[3])
GPUVertFormat * DRW_shgroup_instance_format_array(const DRWInstanceAttrFormat attrs[], int arraysize)
static DRWResourceHandle drw_resource_handle_new(const float(*obmat)[4], const Object *ob)
void DRW_shgroup_storage_block_ex(DRWShadingGroup *shgroup, const char *name, const GPUStorageBuf *ssbo DRW_DEBUG_FILE_LINE_ARGS)
void DRW_view_update(DRWView *view, const float viewmat[4][4], const float winmat[4][4], const float(*culling_viewmat)[4], const float(*culling_winmat)[4])
void DRW_shgroup_call_instance_range(DRWShadingGroup *shgroup, const Object *ob, blender::gpu::Batch *geom, uint i_sta, uint i_num)
static float sculpt_debug_colors[9][4]
void DRW_shgroup_uniform_int(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
static void drw_command_set_stencil_mask(DRWShadingGroup *shgroup, uint write_mask, uint reference, uint compare_mask)
static void drw_shgroup_uniform(DRWShadingGroup *shgroup, const char *name, DRWUniformType type, const void *value, int length, int arraysize)
void DRW_shgroup_call_range(DRWShadingGroup *shgroup, const Object *ob, blender::gpu::Batch *geom, uint v_sta, uint v_num)
void DRW_shgroup_add_material_resources(DRWShadingGroup *grp, GPUMaterial *material)
void DRW_shgroup_call_procedural_triangles(DRWShadingGroup *shgroup, const Object *ob, uint tri_count)
void DRW_shgroup_uniform_ivec4(DRWShadingGroup *shgroup, const char *name, const int *value, int arraysize)
void DRW_shgroup_call_procedural_points(DRWShadingGroup *shgroup, const Object *ob, uint point_count)
static void drw_command_draw_indirect(DRWShadingGroup *shgroup, blender::gpu::Batch *batch, DRWResourceHandle handle, GPUStorageBuf *indirect_buf)
void DRW_shgroup_buffer_texture_ref(DRWShadingGroup *shgroup, const char *name, blender::gpu::VertBuf **vertex_buffer)
float DRW_view_far_distance_get(const DRWView *view)
static void draw_pbvh_nodes(const Object &object, const blender::Span< blender::gpu::Batch * > batches, const blender::Span< int > material_indices, const blender::Span< DRWShadingGroup * > shading_groups, const blender::IndexMask &nodes_to_draw)
void DRW_shgroup_call_sculpt_with_materials(DRWShadingGroup **shgroups, GPUMaterial **gpumats, int num_shgroups, const Object *ob)
void DRW_shgroup_storage_block_ref_ex(DRWShadingGroup *shgroup, const char *name, GPUStorageBuf **ssbo DRW_DEBUG_FILE_LINE_ARGS)
void DRW_shgroup_uniform_block_ref_ex(DRWShadingGroup *shgroup, const char *name, GPUUniformBuf **ubo DRW_DEBUG_FILE_LINE_ARGS)
void DRW_view_clip_planes_set(DRWView *view, float(*planes)[4], int plane_len)
void DRW_shgroup_call_procedural_indirect(DRWShadingGroup *shgroup, GPUPrimType primitive_type, Object *ob, GPUStorageBuf *indirect_buf)
static GPUVertFormat inst_select_format
void DRW_shgroup_call_procedural_lines(DRWShadingGroup *shgroup, const Object *ob, uint line_count)
void DRW_shgroup_uniform_vec4_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
BLI_INLINE void drw_call_matrix_init(DRWObjectMatrix *ob_mats, const Object *ob, const float(*obmat)[4])
void DRW_shgroup_uniform_texture_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
void DRW_shgroup_clear_framebuffer(DRWShadingGroup *shgroup, eGPUFrameBufferBits channels, uchar r, uchar g, uchar b, uchar a, float depth, uchar stencil)
void DRW_shgroup_uniform_bool_copy(DRWShadingGroup *shgroup, const char *name, const bool value)
void DRW_shgroup_uniform_mat4_copy(DRWShadingGroup *shgroup, const char *name, const float(*value)[4])
void DRW_shgroup_uniform_mat4(DRWShadingGroup *shgroup, const char *name, const float(*value)[4])
void DRW_shgroup_uniform_image_ref(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex)
void DRW_shgroup_uniform_float(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
static void draw_frustum_culling_planes_calc(const float(*persmat)[4], float(*frustum_planes)[4])
static void draw_frustum_boundbox_calc(const float(*viewinv)[4], const float(*projmat)[4], BoundBox *r_bbox)
void DRW_shgroup_uniform_vec2_copy(DRWShadingGroup *shgroup, const char *name, const float *value)
void DRW_shgroup_uniform_texture_ref_ex(DRWShadingGroup *shgroup, const char *name, GPUTexture **tex, GPUSamplerState sampler_state)
static void draw_frustum_bound_sphere_calc(const BoundBox *bbox, const float(*viewinv)[4], const float(*projmat)[4], const float(*projinv)[4], BoundSphere *bsphere)
DRWShadingGroup * DRW_shgroup_transform_feedback_create(GPUShader *shader, DRWPass *pass, blender::gpu::VertBuf *tf_target)
void DRW_view_default_set(const DRWView *view)
static void drw_command_draw_range(DRWShadingGroup *shgroup, blender::gpu::Batch *batch, DRWResourceHandle handle, uint start, uint count)
void DRW_shgroup_uniform_block_ex(DRWShadingGroup *shgroup, const char *name, const GPUUniformBuf *ubo DRW_DEBUG_FILE_LINE_ARGS)
static void drw_sculpt_generate_calls(DRWSculptCallbackData *scd)
static void drw_shgroup_call_procedural_add_ex(DRWShadingGroup *shgroup, blender::gpu::Batch *geom, const Object *ob, uint vert_count)
DRWCallBuffer * DRW_shgroup_call_buffer(DRWShadingGroup *shgroup, GPUVertFormat *format, GPUPrimType prim_type)
void DRW_pass_sort_shgroup_reverse(DRWPass *pass)
void DRW_view_update_sub(DRWView *view, const float viewmat[4][4], const float winmat[4][4])
static void draw_view_matrix_state_update(DRWView *view, const float viewmat[4][4], const float winmat[4][4])
static void drw_sculpt_get_frustum_planes(const Object *ob, float planes[6][4])
void DRW_shgroup_vertex_buffer_ref_ex(DRWShadingGroup *shgroup, const char *name, blender::gpu::VertBuf **vertex_buffer DRW_DEBUG_FILE_LINE_ARGS)
void DRW_shgroup_uniform_vec2(DRWShadingGroup *shgroup, const char *name, const float *value, int arraysize)
void DRW_shgroup_uniform_image(DRWShadingGroup *shgroup, const char *name, const GPUTexture *tex)
void DRW_shgroup_uniform_ivec4_copy(DRWShadingGroup *shgroup, const char *name, const int *value)
static DRWShadingGroup * drw_shgroup_create_ex(GPUShader *shader, DRWPass *pass)
void DRW_shgroup_stencil_mask(DRWShadingGroup *shgroup, uint mask)
static void drw_shgroup_init(DRWShadingGroup *shgroup, GPUShader *shader)
DRWShadingGroup * DRW_shgroup_material_create(GPUMaterial *material, DRWPass *pass)
void DRW_shgroup_vertex_buffer_ex(DRWShadingGroup *shgroup, const char *name, blender::gpu::VertBuf *vertex_buffer DRW_DEBUG_FILE_LINE_ARGS)
DRWView * DRW_view_create(const float viewmat[4][4], const float winmat[4][4], const float(*culling_viewmat)[4], const float(*culling_winmat)[4], DRWCallVisibilityFn *visibility_fn)
static void drw_command_clear(DRWShadingGroup *shgroup, eGPUFrameBufferBits channels, uchar r, uchar g, uchar b, uchar a, float depth, uchar stencil)
DRWPass * DRW_pass_create_instance(const char *name, DRWPass *original, DRWState state)
#define SCULPT_DEBUG_COLOR(id)
void DRW_view_viewmat_get(const DRWView *view, float mat[4][4], bool inverse)
@ DRW_STATE_PROGRAM_POINT_SIZE
draw_view in_light_buf[] float
GPUShader * GPU_pass_shader_get(GPUPass *pass)
void * MEM_mallocN_aligned(size_t len, size_t alignment, const char *str)
void MEM_freeN(void *vmemh)
void *(* MEM_callocN)(size_t len, const char *str)
unsigned __int64 uint64_t
float texspace_location[3]
blender::gpu::VertBuf * buf
blender::gpu::VertBuf * buf_select
eGPUFrameBufferBits clear_channels
GPUStorageBuf * indirect_buf
blender::gpu::Batch * batch
GPUStorageBuf * indirect_buf
blender::gpu::Batch * batch
blender::gpu::Batch * batch
blender::gpu::Batch * batch
blender::gpu::Batch * batch
blender::gpu::Batch * batch
blender::gpu::VertBuf * select_buf
GPUUniformBuf ** obinfos_ubo
BLI_memblock * cullstates
DRWInstanceDataList * idatalist
BLI_memblock * callbuffers
BLI_memblock * commands_small
GPUUniformBuf ** matrices_ubo
DRWResourceHandle ob_handle
DRWResourceHandle pass_handle
DRWResourceHandle resource_handle
DupliObject * dupli_source
bool ob_state_obinfo_init
struct DRWPass::@294 shgroups
blender::Span< blender::draw::pbvh::AttributeRequest > attrs
DRWShadingGroup ** shading_groups
struct DRWCommandChunk * first
struct DRWShadingGroup::@289::@293 z_sorting
const struct GPUUniformAttrList * uniform_attrs
DRWResourceHandle pass_handle
struct DRWShadingGroup::@288 cmd
struct DRWCommandChunk * last
DRWUniformChunk * uniforms
GPUUniformBuf * clipping_ubo
static constexpr GPUSamplerState internal_sampler()
static constexpr GPUSamplerState default_sampler()
GPUTexture * tile_mapping
blender::bke::AttrDomain domain
DRW_AttributeRequest requests[GPU_MAX_ATTR]