[Bf-blender-cvs] [695eb4505cc] soc-2022-many-lights-sampling: Cleanup: use `packed_float3` instead of `float[3]`
Weizhen Huang
noreply at git.blender.org
Mon Nov 28 22:19:30 CET 2022
Commit: 695eb4505cc5bfe252c7a338cde6ebde32461401
Author: Weizhen Huang
Date: Mon Nov 28 22:16:19 2022 +0100
Branches: soc-2022-many-lights-sampling
https://developer.blender.org/rB695eb4505cc5bfe252c7a338cde6ebde32461401
Cleanup: use `packed_float3` instead of `float[3]`
===================================================================
M intern/cycles/kernel/light/area.h
M intern/cycles/kernel/light/background.h
M intern/cycles/kernel/light/distant.h
M intern/cycles/kernel/light/point.h
M intern/cycles/kernel/light/spot.h
M intern/cycles/kernel/light/tree.h
M intern/cycles/kernel/types.h
M intern/cycles/scene/light.cpp
M release/datafiles/locale
M release/scripts/addons
M release/scripts/addons_contrib
M source/tools
===================================================================
diff --git a/intern/cycles/kernel/light/area.h b/intern/cycles/kernel/light/area.h
index 7d6f2a5bef9..f7c52db1692 100644
--- a/intern/cycles/kernel/light/area.h
+++ b/intern/cycles/kernel/light/area.h
@@ -162,13 +162,11 @@ ccl_device_inline bool area_light_sample(const ccl_global KernelLight *klight,
const float3 P,
ccl_private LightSample *ls)
{
- ls->P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ ls->P = klight->co;
- float3 extentu = make_float3(
- klight->area.extentu[0], klight->area.extentu[1], klight->area.extentu[2]);
- float3 extentv = make_float3(
- klight->area.extentv[0], klight->area.extentv[1], klight->area.extentv[2]);
- float3 Ng = make_float3(klight->area.dir[0], klight->area.dir[1], klight->area.dir[2]);
+ float3 extentu = klight->area.extentu;
+ float3 extentv = klight->area.extentv;
+ float3 Ng = klight->area.dir;
float invarea = fabsf(klight->area.invarea);
bool is_round = (klight->area.invarea < 0.0f);
@@ -256,18 +254,16 @@ ccl_device_inline bool area_light_intersect(const ccl_global KernelLight *klight
return false;
}
- const float3 extentu = make_float3(
- klight->area.extentu[0], klight->area.extentu[1], klight->area.extentu[2]);
- const float3 extentv = make_float3(
- klight->area.extentv[0], klight->area.extentv[1], klight->area.extentv[2]);
- const float3 Ng = make_float3(klight->area.dir[0], klight->area.dir[1], klight->area.dir[2]);
+ const float3 extentu = klight->area.extentu;
+ const float3 extentv = klight->area.extentv;
+ const float3 Ng = klight->area.dir;
/* One sided. */
if (dot(ray->D, Ng) >= 0.0f) {
return false;
}
- const float3 light_P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ const float3 light_P = klight->co;
float3 P;
return ray_quad_intersect(
@@ -285,12 +281,10 @@ ccl_device_inline bool area_light_sample_from_intersection(
/* area light */
float invarea = fabsf(klight->area.invarea);
- float3 extentu = make_float3(
- klight->area.extentu[0], klight->area.extentu[1], klight->area.extentu[2]);
- float3 extentv = make_float3(
- klight->area.extentv[0], klight->area.extentv[1], klight->area.extentv[2]);
- float3 Ng = make_float3(klight->area.dir[0], klight->area.dir[1], klight->area.dir[2]);
- float3 light_P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ float3 extentu = klight->area.extentu;
+ float3 extentv = klight->area.extentv;
+ float3 Ng = klight->area.dir;
+ float3 light_P = klight->co;
ls->u = isect->u;
ls->v = isect->v;
@@ -332,13 +326,11 @@ ccl_device_inline float area_light_tree_weight(const ccl_global KernelLight *kli
const float3 P,
const float3 N)
{
- float3 light_P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ float3 light_P = klight->co;
- float3 extentu = make_float3(
- klight->area.extentu[0], klight->area.extentu[1], klight->area.extentu[2]);
- float3 extentv = make_float3(
- klight->area.extentv[0], klight->area.extentv[1], klight->area.extentv[2]);
- float3 Ng = make_float3(klight->area.dir[0], klight->area.dir[1], klight->area.dir[2]);
+ float3 extentu = klight->area.extentu;
+ float3 extentv = klight->area.extentv;
+ float3 Ng = klight->area.dir;
bool is_round = (klight->area.invarea < 0.0f);
if (dot(light_P - P, Ng) > 0.0f) {
diff --git a/intern/cycles/kernel/light/background.h b/intern/cycles/kernel/light/background.h
index 3fc9e0776a4..95bd5d47f9f 100644
--- a/intern/cycles/kernel/light/background.h
+++ b/intern/cycles/kernel/light/background.h
@@ -134,8 +134,8 @@ ccl_device_inline bool background_portal_data_fetch_and_check_side(
int portal = kernel_data.integrator.portal_offset + index;
const ccl_global KernelLight *klight = &kernel_data_fetch(lights, portal);
- *lightpos = make_float3(klight->co[0], klight->co[1], klight->co[2]);
- *dir = make_float3(klight->area.dir[0], klight->area.dir[1], klight->area.dir[2]);
+ *lightpos = klight->co;
+ *dir = klight->area.dir;
/* Check whether portal is on the right side. */
if (dot(*dir, P - *lightpos) > 1e-4f)
@@ -166,10 +166,8 @@ ccl_device_inline float background_portal_pdf(
int portal = kernel_data.integrator.portal_offset + p;
const ccl_global KernelLight *klight = &kernel_data_fetch(lights, portal);
- float3 extentu = make_float3(
- klight->area.extentu[0], klight->area.extentu[1], klight->area.extentu[2]);
- float3 extentv = make_float3(
- klight->area.extentv[0], klight->area.extentv[1], klight->area.extentv[2]);
+ float3 extentu = klight->area.extentu;
+ float3 extentv = klight->area.extentv;
bool is_round = (klight->area.invarea < 0.0f);
if (!ray_quad_intersect(P,
@@ -242,10 +240,8 @@ ccl_device float3 background_portal_sample(KernelGlobals kg,
/* p is the portal to be sampled. */
int portal = kernel_data.integrator.portal_offset + p;
const ccl_global KernelLight *klight = &kernel_data_fetch(lights, portal);
- float3 extentu = make_float3(
- klight->area.extentu[0], klight->area.extentu[1], klight->area.extentu[2]);
- float3 extentv = make_float3(
- klight->area.extentv[0], klight->area.extentv[1], klight->area.extentv[2]);
+ float3 extentu = klight->area.extentu;
+ float3 extentv = klight->area.extentv;
bool is_round = (klight->area.invarea < 0.0f);
float3 D;
diff --git a/intern/cycles/kernel/light/distant.h b/intern/cycles/kernel/light/distant.h
index 140b10bd802..c074a6bf097 100644
--- a/intern/cycles/kernel/light/distant.h
+++ b/intern/cycles/kernel/light/distant.h
@@ -15,7 +15,7 @@ ccl_device_inline bool distant_light_sample(const ccl_global KernelLight *klight
ccl_private LightSample *ls)
{
/* distant light */
- float3 lightD = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ float3 lightD = klight->co;
float3 D = lightD;
float radius = klight->distant.radius;
float invarea = klight->distant.invarea;
@@ -71,7 +71,7 @@ ccl_device bool distant_light_sample_from_intersection(KernelGlobals kg,
* P
*/
- float3 lightD = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ float3 lightD = klight->co;
float costheta = dot(-lightD, ray_D);
float cosangle = klight->distant.cosangle;
diff --git a/intern/cycles/kernel/light/point.h b/intern/cycles/kernel/light/point.h
index abec114501f..edf4f899aed 100644
--- a/intern/cycles/kernel/light/point.h
+++ b/intern/cycles/kernel/light/point.h
@@ -14,9 +14,7 @@ ccl_device_inline bool point_light_sample(const ccl_global KernelLight *klight,
const float3 P,
ccl_private LightSample *ls)
{
- ls->P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
-
- float3 center = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ float3 center = klight->co;
float radius = klight->spot.radius;
/* disk oriented normal */
const float3 lightN = normalize(P - center);
@@ -64,7 +62,7 @@ ccl_device_inline bool point_light_intersect(const ccl_global KernelLight *kligh
ccl_private float *t)
{
/* Sphere light (aka, aligned disk light). */
- const float3 lightP = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ const float3 lightP = klight->co;
const float radius = klight->spot.radius;
if (radius == 0.0f) {
return false;
@@ -83,8 +81,7 @@ ccl_device_inline bool point_light_sample_from_intersection(
const float3 ray_D,
ccl_private LightSample *ccl_restrict ls)
{
- const float3 center = make_float3(klight->co[0], klight->co[1], klight->co[2]);
- const float3 lighN = normalize(ray_P - center);
+ const float3 lighN = normalize(ray_P - klight->co);
/* We set the light normal to the outgoing direction to support texturing. */
ls->Ng = -ls->D;
diff --git a/intern/cycles/kernel/light/spot.h b/intern/cycles/kernel/light/spot.h
index 8f1eff7c8b9..13fe1f63e74 100644
--- a/intern/cycles/kernel/light/spot.h
+++ b/intern/cycles/kernel/light/spot.h
@@ -34,11 +34,10 @@ ccl_device_inline bool spot_light_sample(const ccl_global KernelLight *klight,
const float3 P,
ccl_private LightSample *ls)
{
- ls->P = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ ls->P = klight->co;
- const float3 center = make_float3(klight->co[0], klight->co[1], klight->co[2]);
+ const float3 center = klight->co;
const float radius = klight->spot.radius;
- const float3 dir = make_float3(klight->spot.dir[0], klight->spot.dir[1], klight->spot.dir[2]);
/* disk oriented normal */
const float3 lightN = normalize(P - center);
ls->P = center;
@@ -59,7 +58,7 @@ ccl_device_inline bool spot_light_sample(const ccl_global KernelLight *klight,
/* spot light attenuation */
ls->eval_fac *= spot_light_attenuation(
- dir, klight->spot.cos_half_spot_angle, klight->spot.spot_smooth, -ls->D);
+ klight->spot.dir, klight->spot.cos_half_spot_angle, klight->spot.spot_smooth, -ls->D);
if (!in_volume_segment && ls->eval_fac == 0.0f) {
return false;
}
@@ -88,9 +87,8 @@ ccl_device_forceinline void spot_light_update_position(const ccl_global KernelLi
ls->pdf = invarea;
/* spot light attenuation */
- float3 dir = make_float3(klight->spot.dir[0], klight->spot.dir[1], klight->spot.dir[2]);
ls->eval_fac *= spot_light_attenuation(
- dir, klight->spot.cos_half_spot_angle, klight->spot.spot_smooth, ls->Ng);
+ klight->spot.dir, klight->spot.cos_half_spot_angle, klight->spot.spot_smooth, ls->Ng);
}
ccl_device_inline bool spot_light_intersect(const ccl_global KernelLight *klight,
@@ -98,7 +96,7 @@ ccl_device_inline bool spot_light_intersect(const ccl_global KernelLight *klight
ccl_private float *t)
{
/* Spot/Disk light. */
- const floa
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list