Blender V5.3
eevee_shadow_page_free.bsl.hh
Go to the documentation of this file.
1/* SPDX-FileCopyrightText: 2023 Blender Authors
2 *
3 * SPDX-License-Identifier: GPL-2.0-or-later */
4
12
13#pragma once
14
16
17namespace eevee::shadow {
18
21
22[[compute, local_size(SHADOW_TILEMAP_LOD0_LEN)]]
23void free([[resource_table]] PageAllocator &allocator,
24 [[resource_table]] TileMaps &tilemaps,
25 [[global_invocation_id]] const uint3 global_id,
26 [[local_invocation_index]] const uint local_tile)
27{
28 ShadowTileMapData tilemap_data = tilemaps.tilemaps_buf[global_id.z];
29
30 uint tile_start = tilemap_data.tiles_index;
31 for (int lod = 0; lod <= SHADOW_TILEMAP_LOD; lod++) {
32 uint lod_len = uint(SHADOW_TILEMAP_LOD0_LEN >> (lod * 2));
33 if (local_tile < lod_len) {
34 uint tile_index = tile_start + local_tile;
35
36 ShadowTileData tile = shadow_tile_unpack(allocator.tiles_buf[tile_index]);
37
38 bool is_orphaned = !tile.is_used && tile.do_update;
39 if (is_orphaned) {
40 if (tile.is_cached) {
41 allocator.page_cache_remove(tile);
42 }
43 if (tile.is_allocated) {
44 allocator.page_free(tile);
45 }
46 }
47
48 if (tile.is_used) {
49 if (tile.is_cached) {
50 allocator.page_cache_remove(tile);
51 }
52 if (!tile.is_allocated) {
53 atomicAdd(allocator.pages_infos_buf.page_alloc_count, 1);
54 }
55 }
56 else {
57 if (tile.is_allocated) {
58 allocator.page_cache_append(tile, tile_index);
59 }
60 }
61
62 allocator.tiles_buf[tile_index] = shadow_tile_pack(tile);
63 }
64 tile_start += lod_len;
65 }
66}
67
69
70} // namespace eevee::shadow
#define local_invocation_index
#define resource_table
#define global_invocation_id
#define compute
#define local_size(...)
int atomicAdd(int &, int) RET
const int tile_index
const ccl_global KernelWorkTile * tile
void free(PageAllocator &allocator, TileMaps &tilemaps, const uint3 global_id, const uint local_tile)
PipelineCompute page_free(free)
eevee::shadow::TileMaps TileMaps
eevee::shadow::PageAllocator PageAllocator