33 if (drw_data ==
nullptr) {
37 drw_data->
gsplat_module = MEM_new<GSplatModule>(
"GSplatModule");
43 MEM_delete(gsplat_module);
54 while (invocs_start < invocs_count) {
55 int num_invocs = std::min(
int64_t(invocs_count - invocs_start), max_invocs_per_dispatch);
59 invocs_start += num_invocs;
63template<
typename PassT>
73 auto &sub_ps = ps.sub(
"GSplatSubPass");
82 sub_ps.push_constant(
"viewport_size", viewport_size);
83 sub_ps.push_constant(
"resource_id", resource_id);
88template<
typename PassT>
104 const bool is_empty = pointcloud.
totpoint == 0;
110 module.sync_object(ob_ref, res_handle);
115 sub_ps.bind_texture(
"u", module.
dummy_vbo);
116 sub_ps.bind_texture(
"au", module.
dummy_vbo);
117 sub_ps.bind_texture(
"a", module.
dummy_vbo);
118 sub_ps.bind_texture(
"c", module.
dummy_vbo);
119 sub_ps.bind_texture(
"ac", module.
dummy_vbo);
124 sub_ps.bind_texture(
"ellipses_comp_tx",
126 sub_ps.bind_texture(
"radiance_comp_tx",
129 if (gpu_material !=
nullptr) {
133 char sampler_name[32];
137 if (
STREQ(gpu_attr.name,
"radiance")) {
140 sub_ps.bind_texture(sampler_name,
146 sub_ps.bind_texture(sampler_name,
147 (attribute_buf && !is_empty) ? attribute_buf : &module.
dummy_vbo);
159 compute_objects_.clear();
161 compute_ellipses_ps_.init();
163 compute_radiance_ps_.init();
165 compute_ellipses_radiance_ps_.init();
175 if (compute_objects_.contains(ob_key)) {
178 if (compute_objects_.is_empty()) {
183 compute_ellipses_radiance_ps_.shader_set(
186 compute_objects_.add(ob_key);
196 if (compute_objects_.is_empty()) {
200 manager.
submit(get_ps(type), view);
212 module.update(manager, view, GSplatEvalShader::Ellipses);
218 module.update(manager, view, GSplatEvalShader::Radiance);
224 module.update(manager, view, GSplatEvalShader::EllipsesRadiance);
constexpr int64_t first() const
void submit(PassSimple &pass, View &view)
IndexRange id_range() const
void dispatch(int group_len)
void push_constant(const char *name, const float &data)
detail::PassBase< command::DrawCommandBuf > Sub
#define DRW_GSPLAT_GROUP_SIZE
gpu::Batch * draw_subpass_setup(PassT &sub_ps, const ObjectRef &ob_ref, const ResourceHandleRange &res_handle, GPUMaterial *gpu_material)
void compute_pass_setup(PassT &ps, const ObjectRef &ob_ref, const ResourceHandleRange &res_handle)
static void batched_dispatch(const int invocs_count, PassSimple::Sub &pass)
void DRW_gsplat_module_free(draw::GSplatModule *module)
void DRW_gsplat_ensure_radiance(draw::Manager &manager, draw::View &view)
void DRW_gsplat_ensure_ellipses_radiance(draw::Manager &manager, draw::View &view)
bool pointcloud_is_gsplat(Object *ob)
void DRW_gsplat_init(DRWData *drw_data=nullptr)
void drw_curves_get_attribute_sampler_name(const StringRef layer_name, char r_sampler_name[32])
gpu::VertBuf ** DRW_gsplat_evaluated_attribute(PointCloud *pointcloud, StringRef name)
void DRW_gsplat_ensure_ellipses(draw::Manager &manager, draw::View &view)
void DRW_gsplat_begin_sync()
gpu::Batch * gsplat_sub_pass_setup(PassMain::Sub &sub_ps, const ObjectRef &ob_ref, const ResourceHandleRange &res_handle, GPUMaterial *gpu_material=nullptr)
BLI_assert(slot->slot_subtype.map==BMO_OP_SLOT_SUBTYPE_MAP_FLT)
gpu::Shader * DRW_shader_gsplat_compute_get(draw::GSplatEvalShader type)
int GPU_max_work_group_count(int index)
VecBase< float, 2 > float2
T & DRW_object_get_data_for_drawing(const Object &object)
ListBaseT< GPUMaterialAttribute > GPU_material_attributes(const GPUMaterial *material)
const DRWContext * DRW_context_get()
MINLINE uint divide_ceil_u(uint a, uint b)
float2 viewport_size_get() const
draw::GSplatModule * gsplat_module
gpu::VertBuf ** radiance_comp_buf_get()
gpu::UniformBuf * infos_buf_get()
gpu::Batch * surface_get(const PointCloud &pointcloud)
gpu::VertBuf * shape_data_buf_get()
static GSplatEvalCache & get(PointCloud &pointcloud)
gpu::VertBuf ** ellipses_comp_buf_get()
gpu::VertBuf * radiance_data_buf_get()
void update(draw::Manager &manager, draw::View &view, GSplatEvalShader type)
void sync_object(const ObjectRef &ob_ref, const ResourceHandleRange &res_handle)
gpu::UniformBuf * dummy_ubo