mirror of
https://github.com/blender/blender
synced 2026-09-29 04:37:17 +03:00
Some values don't need full float precision, and with millions of states reducing memory usage is important, while the math to pack/unpack these is quite cheap. On CPU full precision is used since there are few states and the extra conversion cost only hurts. This gives a 2% reduction in state size with just KERNEL_FEATURE_PATH_TRACING, and 9% reduction when enabling more features like LIGHT_PASSES + DENOISING or SUBSURFACE + VOLUME. Benchmarks do not show any significant impact on GPU render time either way. Pull Request: https://projects.blender.org/blender/blender/pulls/161876
121 lines
6.5 KiB
C
121 lines
6.5 KiB
C
/* SPDX-FileCopyrightText: 2011-2022 Blender Foundation
|
|
*
|
|
* SPDX-License-Identifier: Apache-2.0 */
|
|
|
|
/********************************* Shadow Path State **************************/
|
|
|
|
KERNEL_STRUCT_BEGIN(shadow_path)
|
|
/* Index of a pixel within the device render buffer. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint32_t, render_pixel_index, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Current sample number. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint32_t, sample, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Random number generator per-pixel info. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint32_t, rng_pixel, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Random number dimension offset. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, rng_offset, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Current ray bounce depth. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, bounce, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Current transparent ray bounce depth. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, transparent_bounce, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Current diffuse ray bounce depth. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, diffuse_bounce, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Current glossy ray bounce depth. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, glossy_bounce, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Current transmission ray bounce depth. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, transmission_bounce, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Current volume bounds ray bounce depth. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, volume_bounds_bounce, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Current portal ray bounce depth. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, portal_bounce, KERNEL_FEATURE_NODE_PORTAL)
|
|
/* DeviceKernel bit indicating queued kernels. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, queued_kernel, KERNEL_FEATURE_PATH_TRACING)
|
|
/* enum PathRayVisibilityFlag, limited to bits from PATH_RAY_VISIBILITY_ALL */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint8_t, visibility, KERNEL_FEATURE_PATH_TRACING)
|
|
/* enum PathRayFlag */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint32_t, flag, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Throughput. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, PackedSpectrum, throughput, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Throughput for shadow pass. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path,
|
|
PackedSpectrum,
|
|
unshadowed_throughput,
|
|
KERNEL_FEATURE_AO_ADDITIVE)
|
|
/* Ratio of throughput to distinguish diffuse / glossy / transmission render passes. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path,
|
|
SpectrumCompressedOnGPU,
|
|
pass_diffuse_weight,
|
|
KERNEL_FEATURE_LIGHT_PASSES)
|
|
KERNEL_STRUCT_MEMBER(shadow_path,
|
|
SpectrumCompressedOnGPU,
|
|
pass_glossy_weight,
|
|
KERNEL_FEATURE_LIGHT_PASSES)
|
|
/* Packed number of intersections found by ray-tracing, and on GPU also the resume hit index
|
|
* and skip_volume flag for cache miss handling.
|
|
* Note that this is the total number of intersections for the shadow ray.
|
|
* The number of recorded intersections in the shadow_isect array might be different as it contains
|
|
* up INTEGRATOR_SHADOW_ISECT_SIZE closest intersections. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint16_t, packed_num_hits, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Light group. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint8_t, lightgroup, KERNEL_FEATURE_PATH_TRACING)
|
|
/* Path guiding. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path,
|
|
SpectrumCompressedOnGPU,
|
|
unlit_throughput,
|
|
KERNEL_FEATURE_PATH_GUIDING)
|
|
#if defined(__PATH_GUIDING__)
|
|
KERNEL_STRUCT_MEMBER(shadow_path,
|
|
openpgl::cpp::PathSegment *,
|
|
path_segment,
|
|
KERNEL_FEATURE_PATH_GUIDING)
|
|
#else
|
|
KERNEL_STRUCT_MEMBER(shadow_path, uint64_t, path_segment, KERNEL_FEATURE_PATH_GUIDING)
|
|
#endif
|
|
KERNEL_STRUCT_MEMBER(shadow_path,
|
|
float,
|
|
guiding_light_linking_mis_weight,
|
|
KERNEL_FEATURE_PATH_GUIDING)
|
|
/* Only need when path tracing without the light tree. Stored as a single float to save
|
|
* space, as we do not expect to make it a big difference. */
|
|
KERNEL_STRUCT_MEMBER(shadow_path,
|
|
float,
|
|
bsdf_eval_average,
|
|
KernelFeatureRequest(KERNEL_FEATURE_PATH_TRACING, KERNEL_FEATURE_LIGHT_TREE))
|
|
KERNEL_STRUCT_END(shadow_path)
|
|
|
|
/********************************** Shadow Ray *******************************/
|
|
|
|
KERNEL_STRUCT_BEGIN_PACKED(shadow_ray, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_MEMBER_PACKED(shadow_ray, packed_float3, P, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_MEMBER_PACKED(shadow_ray, packed_float3, D, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_MEMBER_PACKED(shadow_ray, float, tmin, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_MEMBER_PACKED(shadow_ray, float, tmax, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_MEMBER_PACKED(shadow_ray, float, dP, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_MEMBER_PACKED(shadow_ray, int, self_light_object, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_MEMBER_PACKED(shadow_ray, int, self_light_prim, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_MEMBER_PACKED(shadow_ray, FloatCompressedOnGPU, time, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_MEMBER_PACKED(shadow_ray, FloatCompressedOnGPU, dD, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_END(shadow_ray)
|
|
|
|
/*********************** Shadow Intersection result **************************/
|
|
|
|
/* Result from scene intersection.
|
|
* It contains INTEGRATOR_SHADOW_ISECT_SIZE closest intersections of the shadow ray. */
|
|
KERNEL_STRUCT_BEGIN(shadow_isect)
|
|
KERNEL_STRUCT_ARRAY_MEMBER(shadow_isect, float, t, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_ARRAY_MEMBER(shadow_isect, float, u, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_ARRAY_MEMBER(shadow_isect, float, v, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_ARRAY_MEMBER(shadow_isect, int, prim, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_ARRAY_MEMBER(shadow_isect, int, object, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_ARRAY_MEMBER(shadow_isect, int, type, KERNEL_FEATURE_PATH_TRACING)
|
|
KERNEL_STRUCT_END_ARRAY(shadow_isect,
|
|
INTEGRATOR_SHADOW_ISECT_SIZE_CPU,
|
|
INTEGRATOR_SHADOW_ISECT_SIZE_GPU)
|
|
|
|
/**************************** Shadow Volume Stack *****************************/
|
|
|
|
KERNEL_STRUCT_BEGIN(shadow_volume_stack)
|
|
KERNEL_STRUCT_ARRAY_MEMBER(shadow_volume_stack, int, object, KERNEL_FEATURE_VOLUME)
|
|
KERNEL_STRUCT_ARRAY_MEMBER(shadow_volume_stack, int, shader, KERNEL_FEATURE_VOLUME)
|
|
KERNEL_STRUCT_END_ARRAY(shadow_volume_stack,
|
|
KERNEL_STRUCT_VOLUME_STACK_SIZE,
|
|
KERNEL_STRUCT_VOLUME_STACK_SIZE)
|