18 uint
mask = (bit_width > 31u) ? 0x0u : (0xFFFFFFFFu << bit_width);
19 return ~mask << bit_min;
22uint
zbin_mask(uint word_index, uint zbin_min, uint zbin_max)
24 uint word_start = word_index * 32u;
25 uint word_end = word_start + 31u;
26 uint local_min =
max(zbin_min, word_start);
27 uint local_max =
min(zbin_max, word_end);
28 uint mask_width = local_max - local_min + 1;
34 return int(
z *
scale + bias);
39template<
typename CallbackT,
typename ResourceT>
66 uint tile_word_offset;
81 uint word_max = local_max_index >> 5u;
82 if (local_word_idx > word_max) {
86 local_word = words[tile_word_offset + local_word_idx];
87 local_word &=
zbin_mask(local_word_idx, local_min_index, local_max_index);
96 local_word = simd_broadcast_first(simd_or(local_word));
104 uint receiver_light_set)
110 tile_word_offset = (tile_co.
x + tile_co.
y *
culling.tile_x_len) *
culling.tile_word_len;
112 zbin_index =
clamp(zbin_index, 0, CULLING_ZBIN_COUNT - 1);
113 uint zbin_data = zbins[zbin_index];
114 local_min_index = zbin_data & 0xFFFFu;
115 local_max_index = zbin_data >> 16u;
124 local_min_index = simd_broadcast_first(simd_min(local_min_index));
125 local_max_index = simd_broadcast_first(simd_max(local_max_index));
127 light_set = receiver_light_set;
138 index = int(
culling.local_lights_len) - 1;
144 if (index <
int(
culling.items_count)) {
149 uint word_min = local_min_index >> 5u;
150 local_word_idx = word_min;
151 next_local_word(lrd);
156 uint word_max = local_max_index >> 5u;
157 while (local_word_idx <= word_max) {
158 int bit_index =
findLSB(local_word);
159 if (bit_index != -1) {
160 local_word &= ~1u << uint(bit_index);
161 index = int(local_word_idx * 32u + uint(bit_index));
165 next_local_word(lrd);
208template<
typename CallbackT,
typename ResourceT>
222#ifdef SRT_CONSTANT_light_iter_force_no_culling
233 uint tile_word_offset = (tile_co.
x + tile_co.
y *
culling.tile_x_len) *
culling.tile_word_len;
235 zbin_index =
clamp(zbin_index, 0, CULLING_ZBIN_COUNT - 1);
236 uint zbin_data = zbins[zbin_index];
237 uint min_index = zbin_data & 0xFFFFu;
238 uint max_index = zbin_data >> 16u;
247 min_index = simd_broadcast_first(simd_min(min_index));
248 max_index = simd_broadcast_first(simd_max(max_index));
251 uint word_min = min_index >> 5u;
252 uint word_max = max_index >> 5u;
253 for (uint word_idx = word_min; word_idx <= word_max; word_idx++) {
254 uint word = words[tile_word_offset + word_idx];
255 word &=
zbin_mask(word_idx, min_index, max_index);
264 word = simd_broadcast_first(simd_or(word));
267 while ((bit_index =
findLSB(word)) != -1) {
268 word &= ~1u << uint(bit_index);
269 uint
index = word_idx * 32u + uint(bit_index);
SIMD_FORCE_INLINE const btScalar & z() const
Return the z value.
#define LIGHT_ATTENUATION_THRESHOLD
float light_attenuation_surface(LightData light, const bool is_directional, LightVector lv)
#define assert(assertion)
constexpr T clamp(T, U, U) RET
VecBase< int, D > findLSB(VecOp< int, D >) RET
float3x3 scale(float3x3 mat, float2 scale)
ccl_device_inline float2 mask(const MaskType mask, const float2 a)
int culling_z_to_zbin(float scale, float bias, float z)
void foreach_visible(const LightRenderData &srt, float2 pixel, float linear_view_z, CallbackT &cb, ResourceT &res)
uint bitfield_mask(uint bit_width, uint bit_min)
bool light_linking_affects_receiver(uint2 light_set_membership, uchar receiver_light_set)
@ LIGHT_ITER_PHASE_DIRECTIONAL
uint zbin_mask(uint word_index, uint zbin_min, uint zbin_max)
static LightVector get(LightData light, const bool is_directional, float3 P)
const LightData(& light_buf)[]
const uint(& light_tile_buf)[]
const LightCullingData & light_cull_buf
const uint(& light_zbin_buf)[]
bool should_skip(const eevee::LightRenderData &lrd, float3 P)
void init(const eevee::LightRenderData &lrd, float2 pixel, float linear_view_z, uint receiver_light_set)
bool next(const eevee::LightRenderData &lrd)