Cycles: refactor to move part of KernelData definition to template header
To be used for specialization on Metal in a following commit, turning these members into compile time constants. Ref D14645
This commit is contained in:
parent
2e70d5cb98
commit
79da7f2a8f
|
@ -197,7 +197,7 @@ void CPUDevice::const_copy_to(const char *name, void *host, size_t size)
|
|||
|
||||
// Update scene handle (since it is different for each device on multi devices)
|
||||
KernelData *const data = (KernelData *)host;
|
||||
data->bvh.scene = embree_scene;
|
||||
data->device_bvh = embree_scene;
|
||||
}
|
||||
#endif
|
||||
kernel_const_copy(&kernel_globals, name, host, size);
|
||||
|
|
|
@ -2047,7 +2047,7 @@ void OptiXDevice::const_copy_to(const char *name, void *host, size_t size)
|
|||
|
||||
/* Update traversable handle (since it is different for each device on multi devices). */
|
||||
KernelData *const data = (KernelData *)host;
|
||||
*(OptixTraversableHandle *)&data->bvh.scene = tlas_handle;
|
||||
*(OptixTraversableHandle *)&data->device_bvh = tlas_handle;
|
||||
|
||||
update_launch_params(offsetof(KernelParamsOptiX, data), host, size);
|
||||
return;
|
||||
|
|
|
@ -282,6 +282,7 @@ set(SRC_KERNEL_UTIL_HEADERS
|
|||
|
||||
set(SRC_KERNEL_TYPES_HEADERS
|
||||
data_arrays.h
|
||||
data_template.h
|
||||
tables.h
|
||||
types.h
|
||||
)
|
||||
|
|
|
@ -172,7 +172,7 @@ ccl_device_intersect bool scene_intersect(KernelGlobals kg,
|
|||
ray_flags |= OPTIX_RAY_FLAG_TERMINATE_ON_FIRST_HIT;
|
||||
}
|
||||
|
||||
optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
|
||||
optixTrace(scene_intersect_valid(ray) ? kernel_data.device_bvh : 0,
|
||||
ray->P,
|
||||
ray->D,
|
||||
0.0f,
|
||||
|
@ -295,14 +295,14 @@ ccl_device_intersect bool scene_intersect(KernelGlobals kg,
|
|||
}
|
||||
|
||||
# ifdef __EMBREE__
|
||||
if (kernel_data.bvh.scene) {
|
||||
if (kernel_data.device_bvh) {
|
||||
isect->t = ray->t;
|
||||
CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_REGULAR);
|
||||
IntersectContext rtc_ctx(&ctx);
|
||||
RTCRayHit ray_hit;
|
||||
ctx.ray = ray;
|
||||
kernel_embree_setup_rayhit(*ray, ray_hit, visibility);
|
||||
rtcIntersect1(kernel_data.bvh.scene, &rtc_ctx.context, &ray_hit);
|
||||
rtcIntersect1(kernel_data.device_bvh, &rtc_ctx.context, &ray_hit);
|
||||
if (ray_hit.hit.geomID != RTC_INVALID_GEOMETRY_ID &&
|
||||
ray_hit.hit.primID != RTC_INVALID_GEOMETRY_ID) {
|
||||
kernel_embree_convert_hit(kg, &ray_hit.ray, &ray_hit.hit, isect);
|
||||
|
@ -357,7 +357,7 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals kg,
|
|||
if (local_isect) {
|
||||
local_isect->num_hits = 0; /* Initialize hit count to zero. */
|
||||
}
|
||||
optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
|
||||
optixTrace(scene_intersect_valid(ray) ? kernel_data.device_bvh : 0,
|
||||
ray->P,
|
||||
ray->D,
|
||||
0.0f,
|
||||
|
@ -451,7 +451,7 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals kg,
|
|||
}
|
||||
|
||||
# ifdef __EMBREE__
|
||||
if (kernel_data.bvh.scene) {
|
||||
if (kernel_data.device_bvh) {
|
||||
const bool has_bvh = !(kernel_data_fetch(object_flag, local_object) &
|
||||
SD_OBJECT_TRANSFORM_APPLIED);
|
||||
CCLIntersectContext ctx(
|
||||
|
@ -470,7 +470,7 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals kg,
|
|||
|
||||
/* If this object has its own BVH, use it. */
|
||||
if (has_bvh) {
|
||||
RTCGeometry geom = rtcGetGeometry(kernel_data.bvh.scene, local_object * 2);
|
||||
RTCGeometry geom = rtcGetGeometry(kernel_data.device_bvh, local_object * 2);
|
||||
if (geom) {
|
||||
float3 P = ray->P;
|
||||
float3 dir = ray->D;
|
||||
|
@ -496,7 +496,7 @@ ccl_device_intersect bool scene_intersect_local(KernelGlobals kg,
|
|||
}
|
||||
}
|
||||
else {
|
||||
rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray);
|
||||
rtcOccluded1(kernel_data.device_bvh, &rtc_ctx.context, &rtc_ray);
|
||||
}
|
||||
|
||||
/* rtcOccluded1 sets tfar to -inf if a hit was found. */
|
||||
|
@ -539,7 +539,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
|
|||
ray_mask = 0xFF;
|
||||
}
|
||||
|
||||
optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
|
||||
optixTrace(scene_intersect_valid(ray) ? kernel_data.device_bvh : 0,
|
||||
ray->P,
|
||||
ray->D,
|
||||
0.0f,
|
||||
|
@ -633,7 +633,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
|
|||
}
|
||||
|
||||
# ifdef __EMBREE__
|
||||
if (kernel_data.bvh.scene) {
|
||||
if (kernel_data.device_bvh) {
|
||||
CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_SHADOW_ALL);
|
||||
Intersection *isect_array = (Intersection *)state->shadow_isect;
|
||||
ctx.isect_s = isect_array;
|
||||
|
@ -642,7 +642,7 @@ ccl_device_intersect bool scene_intersect_shadow_all(KernelGlobals kg,
|
|||
IntersectContext rtc_ctx(&ctx);
|
||||
RTCRay rtc_ray;
|
||||
kernel_embree_setup_ray(*ray, rtc_ray, visibility);
|
||||
rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray);
|
||||
rtcOccluded1(kernel_data.device_bvh, &rtc_ctx.context, &rtc_ray);
|
||||
|
||||
*num_recorded_hits = ctx.num_recorded_hits;
|
||||
*throughput = ctx.throughput;
|
||||
|
@ -698,7 +698,7 @@ ccl_device_intersect bool scene_intersect_volume(KernelGlobals kg,
|
|||
ray_mask = 0xFF;
|
||||
}
|
||||
|
||||
optixTrace(scene_intersect_valid(ray) ? kernel_data.bvh.scene : 0,
|
||||
optixTrace(scene_intersect_valid(ray) ? kernel_data.device_bvh : 0,
|
||||
ray->P,
|
||||
ray->D,
|
||||
0.0f,
|
||||
|
@ -825,7 +825,7 @@ ccl_device_intersect uint scene_intersect_volume_all(KernelGlobals kg,
|
|||
}
|
||||
|
||||
# ifdef __EMBREE__
|
||||
if (kernel_data.bvh.scene) {
|
||||
if (kernel_data.device_bvh) {
|
||||
CCLIntersectContext ctx(kg, CCLIntersectContext::RAY_VOLUME_ALL);
|
||||
ctx.isect_s = isect;
|
||||
ctx.max_hits = max_hits;
|
||||
|
@ -834,7 +834,7 @@ ccl_device_intersect uint scene_intersect_volume_all(KernelGlobals kg,
|
|||
IntersectContext rtc_ctx(&ctx);
|
||||
RTCRay rtc_ray;
|
||||
kernel_embree_setup_ray(*ray, rtc_ray, visibility);
|
||||
rtcOccluded1(kernel_data.bvh.scene, &rtc_ctx.context, &rtc_ray);
|
||||
rtcOccluded1(kernel_data.device_bvh, &rtc_ctx.context, &rtc_ray);
|
||||
return ctx.num_hits;
|
||||
}
|
||||
# endif /* __EMBREE__ */
|
||||
|
|
|
@ -107,7 +107,7 @@ ccl_device_inline bool kernel_embree_is_self_intersection(const KernelGlobals kg
|
|||
const int oID = hit->instID[0] / 2;
|
||||
if ((ray->self.object == oID) || (ray->self.light_object == oID)) {
|
||||
RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData(
|
||||
rtcGetGeometry(kernel_data.bvh.scene, hit->instID[0]));
|
||||
rtcGetGeometry(kernel_data.device_bvh, hit->instID[0]));
|
||||
const int pID = hit->primID +
|
||||
(intptr_t)rtcGetGeometryUserData(rtcGetGeometry(inst_scene, hit->geomID));
|
||||
status = intersection_skip_self_shadow(ray->self, oID, pID);
|
||||
|
@ -117,7 +117,7 @@ ccl_device_inline bool kernel_embree_is_self_intersection(const KernelGlobals kg
|
|||
const int oID = hit->geomID / 2;
|
||||
if ((ray->self.object == oID) || (ray->self.light_object == oID)) {
|
||||
const int pID = hit->primID + (intptr_t)rtcGetGeometryUserData(
|
||||
rtcGetGeometry(kernel_data.bvh.scene, hit->geomID));
|
||||
rtcGetGeometry(kernel_data.device_bvh, hit->geomID));
|
||||
status = intersection_skip_self_shadow(ray->self, oID, pID);
|
||||
}
|
||||
}
|
||||
|
@ -133,14 +133,14 @@ ccl_device_inline void kernel_embree_convert_hit(KernelGlobals kg,
|
|||
isect->t = ray->tfar;
|
||||
if (hit->instID[0] != RTC_INVALID_GEOMETRY_ID) {
|
||||
RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData(
|
||||
rtcGetGeometry(kernel_data.bvh.scene, hit->instID[0]));
|
||||
rtcGetGeometry(kernel_data.device_bvh, hit->instID[0]));
|
||||
isect->prim = hit->primID +
|
||||
(intptr_t)rtcGetGeometryUserData(rtcGetGeometry(inst_scene, hit->geomID));
|
||||
isect->object = hit->instID[0] / 2;
|
||||
}
|
||||
else {
|
||||
isect->prim = hit->primID + (intptr_t)rtcGetGeometryUserData(
|
||||
rtcGetGeometry(kernel_data.bvh.scene, hit->geomID));
|
||||
rtcGetGeometry(kernel_data.device_bvh, hit->geomID));
|
||||
isect->object = hit->geomID / 2;
|
||||
}
|
||||
|
||||
|
@ -166,7 +166,7 @@ ccl_device_inline void kernel_embree_convert_sss_hit(
|
|||
isect->v = hit->u;
|
||||
isect->t = ray->tfar;
|
||||
RTCScene inst_scene = (RTCScene)rtcGetGeometryUserData(
|
||||
rtcGetGeometry(kernel_data.bvh.scene, object * 2));
|
||||
rtcGetGeometry(kernel_data.device_bvh, object * 2));
|
||||
isect->prim = hit->primID +
|
||||
(intptr_t)rtcGetGeometryUserData(rtcGetGeometry(inst_scene, hit->geomID));
|
||||
isect->object = object;
|
||||
|
|
|
@ -368,7 +368,7 @@ ccl_device_inline void camera_sample(KernelGlobals kg,
|
|||
ccl_private Ray *ray)
|
||||
{
|
||||
/* pixel filter */
|
||||
int filter_table_offset = kernel_data.film.filter_table_offset;
|
||||
int filter_table_offset = kernel_data.tables.filter_table_offset;
|
||||
float raster_x = x + lookup_table_read(kg, filter_u, filter_table_offset, FILTER_TABLE_SIZE);
|
||||
float raster_y = y + lookup_table_read(kg, filter_v, filter_table_offset, FILTER_TABLE_SIZE);
|
||||
|
||||
|
|
|
@ -0,0 +1,199 @@
|
|||
/* SPDX-License-Identifier: Apache-2.0
|
||||
* Copyright 2011-2022 Blender Foundation */
|
||||
|
||||
#ifndef KERNEL_STRUCT_BEGIN
|
||||
# define KERNEL_STRUCT_BEGIN(name, parent)
|
||||
#endif
|
||||
#ifndef KERNEL_STRUCT_END
|
||||
# define KERNEL_STRUCT_END(name)
|
||||
#endif
|
||||
#ifndef KERNEL_STRUCT_MEMBER
|
||||
# define KERNEL_STRUCT_MEMBER(parent, type, name)
|
||||
#endif
|
||||
|
||||
/* Background. */
|
||||
|
||||
KERNEL_STRUCT_BEGIN(KernelBackground, background)
|
||||
/* xyz store direction, w the angle. float4 instead of float3 is used
|
||||
* to ensure consistent padding/alignment across devices. */
|
||||
KERNEL_STRUCT_MEMBER(background, float4, sun)
|
||||
/* Only shader index. */
|
||||
KERNEL_STRUCT_MEMBER(background, int, surface_shader)
|
||||
KERNEL_STRUCT_MEMBER(background, int, volume_shader)
|
||||
KERNEL_STRUCT_MEMBER(background, float, volume_step_size)
|
||||
KERNEL_STRUCT_MEMBER(background, int, transparent)
|
||||
KERNEL_STRUCT_MEMBER(background, float, transparent_roughness_squared_threshold)
|
||||
/* Portal sampling. */
|
||||
KERNEL_STRUCT_MEMBER(background, float, portal_weight)
|
||||
KERNEL_STRUCT_MEMBER(background, int, num_portals)
|
||||
KERNEL_STRUCT_MEMBER(background, int, portal_offset)
|
||||
/* Sun sampling. */
|
||||
KERNEL_STRUCT_MEMBER(background, float, sun_weight)
|
||||
/* Importance map sampling. */
|
||||
KERNEL_STRUCT_MEMBER(background, float, map_weight)
|
||||
KERNEL_STRUCT_MEMBER(background, int, map_res_x)
|
||||
KERNEL_STRUCT_MEMBER(background, int, map_res_y)
|
||||
/* Multiple importance sampling. */
|
||||
KERNEL_STRUCT_MEMBER(background, int, use_mis)
|
||||
/* Lightgroup. */
|
||||
KERNEL_STRUCT_MEMBER(background, int, lightgroup)
|
||||
/* Padding. */
|
||||
KERNEL_STRUCT_MEMBER(background, int, pad1)
|
||||
KERNEL_STRUCT_MEMBER(background, int, pad2)
|
||||
KERNEL_STRUCT_MEMBER(background, int, pad3)
|
||||
KERNEL_STRUCT_END(KernelBackground)
|
||||
|
||||
/* BVH: own BVH2 if no native device acceleration struct used. */
|
||||
|
||||
KERNEL_STRUCT_BEGIN(KernelBVH, bvh)
|
||||
KERNEL_STRUCT_MEMBER(bvh, int, root)
|
||||
KERNEL_STRUCT_MEMBER(bvh, int, have_motion)
|
||||
KERNEL_STRUCT_MEMBER(bvh, int, have_curves)
|
||||
KERNEL_STRUCT_MEMBER(bvh, int, bvh_layout)
|
||||
KERNEL_STRUCT_MEMBER(bvh, int, use_bvh_steps)
|
||||
KERNEL_STRUCT_MEMBER(bvh, int, curve_subdivisions)
|
||||
KERNEL_STRUCT_MEMBER(bvh, int, pad1)
|
||||
KERNEL_STRUCT_MEMBER(bvh, int, pad2)
|
||||
KERNEL_STRUCT_END(KernelBVH)
|
||||
|
||||
/* Film. */
|
||||
|
||||
KERNEL_STRUCT_BEGIN(KernelFilm, film)
|
||||
/* XYZ to rendering color space transform. float4 instead of float3 to
|
||||
* ensure consistent padding/alignment across devices. */
|
||||
KERNEL_STRUCT_MEMBER(film, float4, xyz_to_r)
|
||||
KERNEL_STRUCT_MEMBER(film, float4, xyz_to_g)
|
||||
KERNEL_STRUCT_MEMBER(film, float4, xyz_to_b)
|
||||
KERNEL_STRUCT_MEMBER(film, float4, rgb_to_y)
|
||||
/* Rec709 to rendering color space. */
|
||||
KERNEL_STRUCT_MEMBER(film, float4, rec709_to_r)
|
||||
KERNEL_STRUCT_MEMBER(film, float4, rec709_to_g)
|
||||
KERNEL_STRUCT_MEMBER(film, float4, rec709_to_b)
|
||||
KERNEL_STRUCT_MEMBER(film, int, is_rec709)
|
||||
/* Exposuse. */
|
||||
KERNEL_STRUCT_MEMBER(film, float, exposure)
|
||||
/* Passed used. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_flag)
|
||||
KERNEL_STRUCT_MEMBER(film, int, light_pass_flag)
|
||||
/* Pass offsets. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_stride)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_combined)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_depth)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_position)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_normal)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_roughness)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_motion)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_motion_weight)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_uv)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_object_id)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_material_id)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_diffuse_color)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_glossy_color)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_transmission_color)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_diffuse_indirect)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_glossy_indirect)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_transmission_indirect)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_volume_indirect)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_diffuse_direct)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_glossy_direct)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_transmission_direct)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_volume_direct)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_emission)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_background)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_ao)
|
||||
KERNEL_STRUCT_MEMBER(film, float, pass_alpha_threshold)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_shadow)
|
||||
KERNEL_STRUCT_MEMBER(film, float, pass_shadow_scale)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_shadow_catcher)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_shadow_catcher_sample_count)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_shadow_catcher_matte)
|
||||
/* Cryptomatte. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, cryptomatte_passes)
|
||||
KERNEL_STRUCT_MEMBER(film, int, cryptomatte_depth)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_cryptomatte)
|
||||
/* Adaptive sampling. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_adaptive_aux_buffer)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_sample_count)
|
||||
/* Mist. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_mist)
|
||||
KERNEL_STRUCT_MEMBER(film, float, mist_start)
|
||||
KERNEL_STRUCT_MEMBER(film, float, mist_inv_depth)
|
||||
KERNEL_STRUCT_MEMBER(film, float, mist_falloff)
|
||||
/* Denoising. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_denoising_normal)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_denoising_albedo)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_denoising_depth)
|
||||
/* AOVs. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_aov_color)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_aov_value)
|
||||
/* Light groups. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_lightgroup)
|
||||
/* Baking. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_bake_primitive)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pass_bake_differential)
|
||||
/* Shadow catcher. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, use_approximate_shadow_catcher)
|
||||
/* Padding. */
|
||||
KERNEL_STRUCT_MEMBER(film, int, pad1)
|
||||
KERNEL_STRUCT_MEMBER(film, int, pad2)
|
||||
KERNEL_STRUCT_END(KernelFilm)
|
||||
|
||||
/* Integrator. */
|
||||
|
||||
KERNEL_STRUCT_BEGIN(KernelIntegrator, integrator)
|
||||
/* Emission. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, use_direct_light)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, num_distribution)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, num_all_lights)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, pdf_triangles)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, pdf_lights)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, light_inv_rr_threshold)
|
||||
/* Bounces. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, min_bounce)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, max_bounce)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, max_diffuse_bounce)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, max_glossy_bounce)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, max_transmission_bounce)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, max_volume_bounce)
|
||||
/* AO bounces. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, ao_bounces)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, ao_bounces_distance)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, ao_bounces_factor)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, ao_additive_factor)
|
||||
/* Transparency. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, transparent_min_bounce)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, transparent_max_bounce)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, transparent_shadows)
|
||||
/* Caustics. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, caustics_reflective)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, caustics_refractive)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, filter_glossy)
|
||||
/* Seed. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, seed)
|
||||
/* Clamp. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, sample_clamp_direct)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, sample_clamp_indirect)
|
||||
/* MIS. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, use_lamp_mis)
|
||||
/* Caustics. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, use_caustics)
|
||||
/* Sampling pattern. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, sampling_pattern)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, scrambling_distance)
|
||||
/* Volume render. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, use_volumes)
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, volume_max_steps)
|
||||
KERNEL_STRUCT_MEMBER(integrator, float, volume_step_rate)
|
||||
/* Shadow catcher. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, has_shadow_catcher)
|
||||
/* Closure filter. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, filter_closures)
|
||||
/* MIS debugging. */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, direct_light_sampling_type)
|
||||
/* Padding */
|
||||
KERNEL_STRUCT_MEMBER(integrator, int, pad1)
|
||||
KERNEL_STRUCT_END(KernelIntegrator)
|
||||
|
||||
#undef KERNEL_STRUCT_BEGIN
|
||||
#undef KERNEL_STRUCT_MEMBER
|
||||
#undef KERNEL_STRUCT_END
|
|
@ -1072,94 +1072,6 @@ typedef struct KernelCamera {
|
|||
} KernelCamera;
|
||||
static_assert_align(KernelCamera, 16);
|
||||
|
||||
typedef struct KernelFilm {
|
||||
float exposure;
|
||||
int pass_flag;
|
||||
|
||||
int light_pass_flag;
|
||||
int pass_stride;
|
||||
|
||||
int pass_combined;
|
||||
int pass_depth;
|
||||
int pass_position;
|
||||
int pass_normal;
|
||||
int pass_roughness;
|
||||
int pass_motion;
|
||||
|
||||
int pass_motion_weight;
|
||||
int pass_uv;
|
||||
int pass_object_id;
|
||||
int pass_material_id;
|
||||
|
||||
int pass_diffuse_color;
|
||||
int pass_glossy_color;
|
||||
int pass_transmission_color;
|
||||
|
||||
int pass_diffuse_indirect;
|
||||
int pass_glossy_indirect;
|
||||
int pass_transmission_indirect;
|
||||
int pass_volume_indirect;
|
||||
|
||||
int pass_diffuse_direct;
|
||||
int pass_glossy_direct;
|
||||
int pass_transmission_direct;
|
||||
int pass_volume_direct;
|
||||
|
||||
int pass_emission;
|
||||
int pass_background;
|
||||
int pass_ao;
|
||||
float pass_alpha_threshold;
|
||||
|
||||
int pass_shadow;
|
||||
float pass_shadow_scale;
|
||||
|
||||
int pass_shadow_catcher;
|
||||
int pass_shadow_catcher_sample_count;
|
||||
int pass_shadow_catcher_matte;
|
||||
|
||||
int filter_table_offset;
|
||||
|
||||
int cryptomatte_passes;
|
||||
int cryptomatte_depth;
|
||||
int pass_cryptomatte;
|
||||
|
||||
int pass_adaptive_aux_buffer;
|
||||
int pass_sample_count;
|
||||
|
||||
int pass_mist;
|
||||
float mist_start;
|
||||
float mist_inv_depth;
|
||||
float mist_falloff;
|
||||
|
||||
int pass_denoising_normal;
|
||||
int pass_denoising_albedo;
|
||||
int pass_denoising_depth;
|
||||
|
||||
int pass_aov_color;
|
||||
int pass_aov_value;
|
||||
int pass_lightgroup;
|
||||
|
||||
/* XYZ to rendering color space transform. float4 instead of float3 to
|
||||
* ensure consistent padding/alignment across devices. */
|
||||
float4 xyz_to_r;
|
||||
float4 xyz_to_g;
|
||||
float4 xyz_to_b;
|
||||
float4 rgb_to_y;
|
||||
/* Rec709 to rendering color space. */
|
||||
float4 rec709_to_r;
|
||||
float4 rec709_to_g;
|
||||
float4 rec709_to_b;
|
||||
int is_rec709;
|
||||
|
||||
int pass_bake_primitive;
|
||||
int pass_bake_differential;
|
||||
|
||||
int use_approximate_shadow_catcher;
|
||||
|
||||
int pad1;
|
||||
} KernelFilm;
|
||||
static_assert_align(KernelFilm, 16);
|
||||
|
||||
typedef struct KernelFilmConvert {
|
||||
int pass_offset;
|
||||
int pass_stride;
|
||||
|
@ -1201,108 +1113,6 @@ typedef struct KernelFilmConvert {
|
|||
} KernelFilmConvert;
|
||||
static_assert_align(KernelFilmConvert, 16);
|
||||
|
||||
typedef struct KernelBackground {
|
||||
/* only shader index */
|
||||
int surface_shader;
|
||||
int volume_shader;
|
||||
float volume_step_size;
|
||||
int transparent;
|
||||
float transparent_roughness_squared_threshold;
|
||||
|
||||
/* portal sampling */
|
||||
float portal_weight;
|
||||
int num_portals;
|
||||
int portal_offset;
|
||||
|
||||
/* sun sampling */
|
||||
float sun_weight;
|
||||
/* xyz store direction, w the angle. float4 instead of float3 is used
|
||||
* to ensure consistent padding/alignment across devices. */
|
||||
float4 sun;
|
||||
|
||||
/* map sampling */
|
||||
float map_weight;
|
||||
int map_res_x;
|
||||
int map_res_y;
|
||||
|
||||
int use_mis;
|
||||
|
||||
int lightgroup;
|
||||
|
||||
/* Padding */
|
||||
int pad1, pad2;
|
||||
} KernelBackground;
|
||||
static_assert_align(KernelBackground, 16);
|
||||
|
||||
typedef struct KernelIntegrator {
|
||||
/* emission */
|
||||
int use_direct_light;
|
||||
int num_distribution;
|
||||
int num_all_lights;
|
||||
float pdf_triangles;
|
||||
float pdf_lights;
|
||||
float light_inv_rr_threshold;
|
||||
|
||||
/* bounces */
|
||||
int min_bounce;
|
||||
int max_bounce;
|
||||
|
||||
int max_diffuse_bounce;
|
||||
int max_glossy_bounce;
|
||||
int max_transmission_bounce;
|
||||
int max_volume_bounce;
|
||||
|
||||
/* AO bounces */
|
||||
int ao_bounces;
|
||||
float ao_bounces_distance;
|
||||
float ao_bounces_factor;
|
||||
float ao_additive_factor;
|
||||
|
||||
/* transparent */
|
||||
int transparent_min_bounce;
|
||||
int transparent_max_bounce;
|
||||
int transparent_shadows;
|
||||
|
||||
/* caustics */
|
||||
int caustics_reflective;
|
||||
int caustics_refractive;
|
||||
float filter_glossy;
|
||||
|
||||
/* seed */
|
||||
int seed;
|
||||
|
||||
/* clamp */
|
||||
float sample_clamp_direct;
|
||||
float sample_clamp_indirect;
|
||||
|
||||
/* mis */
|
||||
int use_lamp_mis;
|
||||
|
||||
/* caustics */
|
||||
int use_caustics;
|
||||
|
||||
/* sampler */
|
||||
int sampling_pattern;
|
||||
|
||||
/* volume render */
|
||||
int use_volumes;
|
||||
int volume_max_steps;
|
||||
float volume_step_rate;
|
||||
|
||||
int has_shadow_catcher;
|
||||
float scrambling_distance;
|
||||
|
||||
/* Closure filter. */
|
||||
int filter_closures;
|
||||
|
||||
/* MIS debugging. */
|
||||
int direct_light_sampling_type;
|
||||
|
||||
/* padding */
|
||||
int pad1;
|
||||
} KernelIntegrator;
|
||||
static_assert_align(KernelIntegrator, 16);
|
||||
|
||||
typedef enum KernelBVHLayout {
|
||||
BVH_LAYOUT_NONE = 0,
|
||||
|
||||
|
@ -1320,36 +1130,19 @@ typedef enum KernelBVHLayout {
|
|||
BVH_LAYOUT_ALL = BVH_LAYOUT_BVH2 | BVH_LAYOUT_EMBREE | BVH_LAYOUT_OPTIX | BVH_LAYOUT_METAL,
|
||||
} KernelBVHLayout;
|
||||
|
||||
typedef struct KernelBVH {
|
||||
/* Own BVH */
|
||||
int root;
|
||||
int have_motion;
|
||||
int have_curves;
|
||||
int bvh_layout;
|
||||
int use_bvh_steps;
|
||||
int curve_subdivisions;
|
||||
|
||||
/* Custom BVH */
|
||||
#ifdef __KERNEL_OPTIX__
|
||||
OptixTraversableHandle scene;
|
||||
#elif defined __METALRT__
|
||||
metalrt_as_type scene;
|
||||
#else
|
||||
# ifdef __EMBREE__
|
||||
RTCScene scene;
|
||||
# ifndef __KERNEL_64_BIT__
|
||||
int pad2;
|
||||
# endif
|
||||
# else
|
||||
int scene, pad2;
|
||||
# endif
|
||||
#endif
|
||||
} KernelBVH;
|
||||
static_assert_align(KernelBVH, 16);
|
||||
/* Specialized struct that can become constants in dynamic compilation. */
|
||||
#define KERNEL_STRUCT_BEGIN(name, parent) struct name {
|
||||
#define KERNEL_STRUCT_END(name) \
|
||||
} \
|
||||
; \
|
||||
static_assert_align(name, 16);
|
||||
#define KERNEL_STRUCT_MEMBER(parent, type, name) type name;
|
||||
#include "kernel/data_template.h"
|
||||
|
||||
typedef struct KernelTables {
|
||||
int beckmann_offset;
|
||||
int pad1, pad2, pad3;
|
||||
int filter_table_offset;
|
||||
int pad1, pad2;
|
||||
} KernelTables;
|
||||
static_assert_align(KernelTables, 16);
|
||||
|
||||
|
@ -1362,18 +1155,37 @@ typedef struct KernelBake {
|
|||
static_assert_align(KernelBake, 16);
|
||||
|
||||
typedef struct KernelData {
|
||||
/* Features and limits. */
|
||||
uint kernel_features;
|
||||
uint max_closures;
|
||||
uint max_shaders;
|
||||
uint volume_stack_size;
|
||||
|
||||
/* Always dynamic data mambers. */
|
||||
KernelCamera cam;
|
||||
KernelFilm film;
|
||||
KernelBackground background;
|
||||
KernelIntegrator integrator;
|
||||
KernelBVH bvh;
|
||||
KernelTables tables;
|
||||
KernelBake bake;
|
||||
KernelTables tables;
|
||||
|
||||
/* Potentially specialized data members. */
|
||||
#define KERNEL_STRUCT_BEGIN(name, parent) name parent;
|
||||
#include "kernel/data_template.h"
|
||||
|
||||
/* Device specific BVH. */
|
||||
#ifdef __KERNEL_OPTIX__
|
||||
OptixTraversableHandle device_bvh;
|
||||
#elif defined __METALRT__
|
||||
metalrt_as_type device_bvh;
|
||||
#else
|
||||
# ifdef __EMBREE__
|
||||
RTCScene device_bvh;
|
||||
# ifndef __KERNEL_64_BIT__
|
||||
int pad1;
|
||||
# endif
|
||||
# else
|
||||
int device_bvh, pad1;
|
||||
# endif
|
||||
#endif
|
||||
int pad2, pad3;
|
||||
} KernelData;
|
||||
static_assert_align(KernelData, 16);
|
||||
|
||||
|
|
|
@ -394,7 +394,7 @@ void Film::device_update(Device *device, DeviceScene *dscene, Scene *scene)
|
|||
vector<float> table = filter_table(filter_type, filter_width);
|
||||
scene->lookup_tables->remove_table(&filter_table_offset_);
|
||||
filter_table_offset_ = scene->lookup_tables->add_table(dscene, table);
|
||||
kfilm->filter_table_offset = (int)filter_table_offset_;
|
||||
dscene->data.tables.filter_table_offset = (int)filter_table_offset_;
|
||||
|
||||
/* mist pass parameters */
|
||||
kfilm->mist_start = mist_start;
|
||||
|
|
|
@ -1362,7 +1362,7 @@ void GeometryManager::device_update_bvh(Device *device,
|
|||
dscene->data.bvh.use_bvh_steps = (scene->params.num_bvh_time_steps != 0);
|
||||
dscene->data.bvh.curve_subdivisions = scene->params.curve_subdivisions();
|
||||
/* The scene handle is set in 'CPUDevice::const_copy_to' and 'OptiXDevice::const_copy_to' */
|
||||
dscene->data.bvh.scene = 0;
|
||||
dscene->data.device_bvh = 0;
|
||||
}
|
||||
|
||||
/* Set of flags used to help determining what data has been modified or needs reallocation, so we
|
||||
|
|
Loading…
Reference in New Issue