Fix: EEVEE: Broken object attributes on volume, pointcloud and curves

This was a simple oversight.

Also adding a version of `extract_object_attributes` for
single material object.

Fixes #123997
This commit is contained in:
Clément Foucault 2024-07-02 16:36:43 +02:00
parent f3fb3a9ecd
commit d8fef30b36
4 changed files with 39 additions and 3 deletions

@ -291,7 +291,7 @@ void Instance::object_sync(Object *ob)
sync.sync_point_cloud(ob, ob_handle, res_handle, ob_ref);
break;
case OB_VOLUME:
sync.sync_volume(ob, ob_handle, res_handle);
sync.sync_volume(ob, ob_handle, res_handle, ob_ref);
break;
case OB_CURVES:
sync.sync_curves(ob, ob_handle, res_handle, ob_ref);

@ -322,6 +322,8 @@ void SyncModule::sync_point_cloud(Object *ob,
inst_.manager->update_handle_bounds(res_handle, ob_ref, mat->inflate_bounds);
}
inst_.manager->extract_object_attributes(res_handle, ob_ref, material.shading.gpumat);
inst_.shadows.sync_object(ob,
ob_handle,
res_handle,
@ -335,7 +337,10 @@ void SyncModule::sync_point_cloud(Object *ob,
/** \name Volume Objects
* \{ */
void SyncModule::sync_volume(Object *ob, ObjectHandle & /*ob_handle*/, ResourceHandle res_handle)
void SyncModule::sync_volume(Object *ob,
ObjectHandle & /*ob_handle*/,
ResourceHandle res_handle,
const ObjectRef &ob_ref)
{
if (!inst_.use_volumes) {
return;
@ -363,6 +368,8 @@ void SyncModule::sync_volume(Object *ob, ObjectHandle & /*ob_handle*/, ResourceH
}
};
inst_.manager->extract_object_attributes(res_handle, ob_ref, material.volume_material.gpumat);
drawcall_add(material.volume_occupancy, geom, res_handle);
drawcall_add(material.volume_material, geom, res_handle);
}
@ -586,6 +593,8 @@ void SyncModule::sync_curves(Object *ob,
inst_.manager->update_handle_bounds(res_handle, ob_ref, mat->inflate_bounds);
}
inst_.manager->extract_object_attributes(res_handle, ob_ref, material.shading.gpumat);
inst_.shadows.sync_object(ob,
ob_handle,
res_handle,

@ -178,7 +178,10 @@ class SyncModule {
ObjectHandle &ob_handle,
ResourceHandle res_handle,
const ObjectRef &ob_ref);
void sync_volume(Object *ob, ObjectHandle &ob_handle, ResourceHandle res_handle);
void sync_volume(Object *ob,
ObjectHandle &ob_handle,
ResourceHandle res_handle,
const ObjectRef &ob_ref);
void sync_gpencil(Object *ob, ObjectHandle &ob_handle, ResourceHandle res_handle);
void sync_curves(Object *ob,
ObjectHandle &ob_handle,

@ -159,7 +159,11 @@ class Manager {
/**
* Populate additional per resource data on demand.
* IMPORTANT: Should be called only **once** per object.
*/
void extract_object_attributes(ResourceHandle handle,
const ObjectRef &ref,
const GPUMaterial *material);
void extract_object_attributes(ResourceHandle handle,
const ObjectRef &ref,
Span<GPUMaterial *> materials);
@ -294,6 +298,26 @@ inline void Manager::update_handle_bounds(ResourceHandle handle,
bounds_buf.current()[handle.resource_index()].sync(bounds_center, bounds_half_extent);
}
inline void Manager::extract_object_attributes(ResourceHandle handle,
const ObjectRef &ref,
const GPUMaterial *material)
{
ObjectInfos &infos = infos_buf.current().get_or_resize(handle.resource_index());
infos.object_attrs_offset = attribute_len_;
const GPUUniformAttrList *attr_list = GPU_material_uniform_attributes(material);
if (attr_list == nullptr) {
return;
}
LISTBASE_FOREACH (const GPUUniformAttr *, attr, &attr_list->list) {
if (attributes_buf.get_or_resize(attribute_len_).sync(ref, *attr)) {
infos.object_attrs_len++;
attribute_len_++;
}
}
}
inline void Manager::extract_object_attributes(ResourceHandle handle,
const ObjectRef &ref,
Span<GPUMaterial *> materials)