Fix: Reflection Probe Memory Alignment #110202

Merged
Jeroen Bakker merged 1 commits from Jeroen-Bakker/blender:eevee-next/fix/reflection-probe-data-alignment into main 2023-07-17 13:40:23 +02:00
3 changed files with 7 additions and 7 deletions

View File

@ -21,7 +21,7 @@ void ReflectionProbeModule::init()
world_probe_data.layer = 0;
world_probe_data.layer_subdivision = 0;
world_probe_data.area_index = 0;
world_probe_data.pos = float3(0.0f);
world_probe_data.pos = float4(0.0f);
data_buf_[0] = world_probe_data;
ReflectionProbe world_probe;
@ -125,7 +125,7 @@ void ReflectionProbeModule::sync_object(Object *ob, ObjectHandle &ob_handle)
probe_data.area_index = new_probe_data.area_index;
}
probe_data.pos = float3(float4x4(ob->object_to_world) * float4(0.0, 0.0, 0.0, 1.0));
probe_data.pos = float4x4(ob->object_to_world) * float4(0.0, 0.0, 0.0, 1.0);
}
ReflectionProbe &ReflectionProbeModule::find_or_insert(ObjectHandle &ob_handle,
@ -458,7 +458,7 @@ std::optional<ReflectionProbeUpdateInfo> ReflectionProbeModule::update_info_pop(
info.object_key = item.key;
info.resolution = 1 << (max_shift - probe_data.layer_subdivision - 1);
info.clipping_distances = item.value.clipping_distances;
info.probe_pos = probe_data.pos;
info.probe_pos = float3(probe_data.pos);
if (cubemap_tx_.ensure_cube(GPU_RGBA16F,
info.resolution,

View File

@ -1033,8 +1033,10 @@ struct ReflectionProbeData {
/**
* Position of the light probe in world space.
* World probe uses origin.
*
* 4th component is not used.
*/
packed_float3 pos;
float4 pos;
/** On which layer of the texture array is this reflection probe stored. */
int layer;
@ -1056,8 +1058,6 @@ struct ReflectionProbeData {
* LOD factor for mipmap selection.
*/
float lod_factor;
int _pad[1];
};
BLI_STATIC_ASSERT_ALIGN(ReflectionProbeData, 16)

View File

@ -65,7 +65,7 @@ int reflection_probes_find_closest(vec3 P)
for (int index = 1; reflection_probe_buf[index].layer != -1 && index < REFLECTION_PROBES_MAX;
index++)
{
float dist = distance(P, reflection_probe_buf[index].pos);
float dist = distance(P, reflection_probe_buf[index].pos.xyz);
if (dist < closest_distance) {
closest_distance = dist;
closest_index = index;