Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Jones <michael_p_jones@apple.com>2021-10-14 15:53:40 +0300
committerMichael Jones <michael_p_jones@apple.com>2021-10-14 18:14:43 +0300
commita0f269f682dab848afc80cd322d04a0c4a815cae (patch)
tree0978b1888273fbaa2d14550bde484c5247fa89ff /intern/cycles/kernel/closure/bssrdf.h
parent47caeb8c26686e24ea7e694f94fabee44f3d2dca (diff)
Cycles: Kernel address space changes for MSL
This is the first of a sequence of changes to support compiling Cycles kernels as MSL (Metal Shading Language) in preparation for a Metal GPU device implementation. MSL requires that all pointer types be declared with explicit address space attributes (device, thread, etc...). There is already precedent for this with Cycles' address space macros (ccl_global, ccl_private, etc...), therefore the first step of MSL-enablement is to apply these consistently. Line-for-line this represents the largest change required to enable MSL. Applying this change first will simplify future patches as well as offering the emergent benefit of enhanced descriptiveness. The vast majority of deltas in this patch fall into one of two cases: - Ensuring ccl_private is specified for thread-local pointer types - Ensuring ccl_global is specified for device-wide pointer types Additionally, the ccl_addr_space qualifier can be removed. Prior to Cycles X, ccl_addr_space was used as a context-dependent address space qualifier, but now it is either redundant (e.g. in struct typedefs), or can be replaced by ccl_global in the case of pointer types. Associated function variants (e.g. lcg_step_float_addrspace) are also redundant. In cases where address space qualifiers are chained with "const", this patch places the address space qualifier first. The rationale for this is that the choice of address space is likely to have the greater impact on runtime performance and overall architecture. The final part of this patch is the addition of a metal/compat.h header. This is partially complete and will be extended in future patches, paving the way for the full Metal implementation. Ref T92212 Reviewed By: brecht Maniphest Tasks: T92212 Differential Revision: https://developer.blender.org/D12864
Diffstat (limited to 'intern/cycles/kernel/closure/bssrdf.h')
-rw-r--r--intern/cycles/kernel/closure/bssrdf.h35
1 files changed, 24 insertions, 11 deletions
diff --git a/intern/cycles/kernel/closure/bssrdf.h b/intern/cycles/kernel/closure/bssrdf.h
index 07415c53ec5..9df69e073c1 100644
--- a/intern/cycles/kernel/closure/bssrdf.h
+++ b/intern/cycles/kernel/closure/bssrdf.h
@@ -18,7 +18,7 @@
CCL_NAMESPACE_BEGIN
-typedef ccl_addr_space struct Bssrdf {
+typedef struct Bssrdf {
SHADER_CLOSURE_BASE;
float3 radius;
@@ -66,7 +66,9 @@ ccl_device float bssrdf_dipole_compute_alpha_prime(float rd, float fourthirdA)
return xmid;
}
-ccl_device void bssrdf_setup_radius(Bssrdf *bssrdf, const ClosureType type, const float eta)
+ccl_device void bssrdf_setup_radius(ccl_private Bssrdf *bssrdf,
+ const ClosureType type,
+ const float eta)
{
if (type == CLOSURE_BSSRDF_BURLEY_ID || type == CLOSURE_BSSRDF_RANDOM_WALK_FIXED_RADIUS_ID) {
/* Scale mean free path length so it gives similar looking result to older
@@ -114,7 +116,7 @@ ccl_device_inline float3 bssrdf_burley_compatible_mfp(float3 r)
return 0.25f * M_1_PI_F * r;
}
-ccl_device void bssrdf_burley_setup(Bssrdf *bssrdf)
+ccl_device void bssrdf_burley_setup(ccl_private Bssrdf *bssrdf)
{
/* Mean free path length. */
const float3 l = bssrdf_burley_compatible_mfp(bssrdf->radius);
@@ -195,7 +197,10 @@ ccl_device_forceinline float bssrdf_burley_root_find(float xi)
return r;
}
-ccl_device void bssrdf_burley_sample(const float d, float xi, float *r, float *h)
+ccl_device void bssrdf_burley_sample(const float d,
+ float xi,
+ ccl_private float *r,
+ ccl_private float *h)
{
const float Rm = BURLEY_TRUNCATE * d;
const float r_ = bssrdf_burley_root_find(xi * BURLEY_TRUNCATE_CDF) * d;
@@ -221,7 +226,10 @@ ccl_device float bssrdf_num_channels(const float3 radius)
return channels;
}
-ccl_device void bssrdf_sample(const float3 radius, float xi, float *r, float *h)
+ccl_device void bssrdf_sample(const float3 radius,
+ float xi,
+ ccl_private float *r,
+ ccl_private float *h)
{
const float num_channels = bssrdf_num_channels(radius);
float sampled_radius;
@@ -261,9 +269,10 @@ ccl_device_forceinline float bssrdf_pdf(const float3 radius, float r)
/* Setup */
-ccl_device_inline Bssrdf *bssrdf_alloc(ShaderData *sd, float3 weight)
+ccl_device_inline ccl_private Bssrdf *bssrdf_alloc(ccl_private ShaderData *sd, float3 weight)
{
- Bssrdf *bssrdf = (Bssrdf *)closure_alloc(sd, sizeof(Bssrdf), CLOSURE_NONE_ID, weight);
+ ccl_private Bssrdf *bssrdf = (ccl_private Bssrdf *)closure_alloc(
+ sd, sizeof(Bssrdf), CLOSURE_NONE_ID, weight);
if (bssrdf == NULL) {
return NULL;
@@ -274,13 +283,16 @@ ccl_device_inline Bssrdf *bssrdf_alloc(ShaderData *sd, float3 weight)
return (sample_weight >= CLOSURE_WEIGHT_CUTOFF) ? bssrdf : NULL;
}
-ccl_device int bssrdf_setup(ShaderData *sd, Bssrdf *bssrdf, ClosureType type, const float ior)
+ccl_device int bssrdf_setup(ccl_private ShaderData *sd,
+ ccl_private Bssrdf *bssrdf,
+ ClosureType type,
+ const float ior)
{
int flag = 0;
/* Add retro-reflection component as separate diffuse BSDF. */
if (bssrdf->roughness != FLT_MAX) {
- PrincipledDiffuseBsdf *bsdf = (PrincipledDiffuseBsdf *)bsdf_alloc(
+ ccl_private PrincipledDiffuseBsdf *bsdf = (ccl_private PrincipledDiffuseBsdf *)bsdf_alloc(
sd, sizeof(PrincipledDiffuseBsdf), bssrdf->weight);
if (bsdf) {
@@ -321,7 +333,7 @@ ccl_device int bssrdf_setup(ShaderData *sd, Bssrdf *bssrdf, ClosureType type, co
/* Add diffuse BSDF if any radius too small. */
#ifdef __PRINCIPLED__
if (bssrdf->roughness != FLT_MAX) {
- PrincipledDiffuseBsdf *bsdf = (PrincipledDiffuseBsdf *)bsdf_alloc(
+ ccl_private PrincipledDiffuseBsdf *bsdf = (ccl_private PrincipledDiffuseBsdf *)bsdf_alloc(
sd, sizeof(PrincipledDiffuseBsdf), diffuse_weight);
if (bsdf) {
@@ -333,7 +345,8 @@ ccl_device int bssrdf_setup(ShaderData *sd, Bssrdf *bssrdf, ClosureType type, co
else
#endif /* __PRINCIPLED__ */
{
- DiffuseBsdf *bsdf = (DiffuseBsdf *)bsdf_alloc(sd, sizeof(DiffuseBsdf), diffuse_weight);
+ ccl_private DiffuseBsdf *bsdf = (ccl_private DiffuseBsdf *)bsdf_alloc(
+ sd, sizeof(DiffuseBsdf), diffuse_weight);
if (bsdf) {
bsdf->N = bssrdf->N;