Blender V5.3
eevee::shadow Namespace Reference

Namespaces

namespace  usage

Classes

struct  Commands
struct  PageAllocator
struct  PageClear
struct  PageMask
struct  RendermapFinalize
struct  Statistics
struct  TagUpdate
struct  TilemapBounds
struct  TilemapBoundsCtx
struct  TilemapBoundsInit
struct  TilemapFinalize
struct  TilemapInit
struct  TileMaps
struct  Tiles
struct  VertIn
struct  VertOut
struct  ViewVisibility

Typedefs

using PageAllocator = eevee::shadow::PageAllocator
using Statistics = eevee::shadow::Statistics
using TileMaps = eevee::shadow::TileMaps

Functions

void allocate (PageAllocator &allocator, TileMaps &tilemaps, Statistics &stats, const uint3 global_id, const uint local_tile)
void page_clear_comp (PageClear &srt, const uint3 global_id)
void defrag (PageAllocator &allocator, Commands &cmds, Statistics &stats)
void free (PageAllocator &allocator, TileMaps &tilemaps, const uint3 global_id, const uint local_tile)
int shadow_tile_offset_lds (int2 tile, int lod)
bool thread_mask (int2 tile_co, int lod)
void mask (PageMask &srt, TileMaps &tilemaps, const uint3 global_id, const uint local_tile_index)
void tag_update_vert (TagUpdate &srt, TileMaps &tilemaps, const int inst_per_tilemap_id, const VertIn &v_in, VertOut &v_out, float4 &out_position)
void tag_update_frag (Tiles &tiles, TileMaps &tilemaps, const float4 frag_coord, const VertOut &v_out)
void tag_propagate (Tiles &tiles, TileMaps &tilemaps, const uint3 global_id)
void tilemap_bounds_clear (TilemapBoundsInit &srt, const uint3 global_id)
void tilemap_bounds_min_max (TilemapBounds &srt, const uint3 global_id, const uint local_index)
int viewport_select (int2 rect_size)
void tilemap_finalize_main (TilemapFinalize &srt, const uint3 global_id, const uint local_index)
void rendermap_finalize_main (RendermapFinalize &srt, const uint3 global_id)
void tilemap_init_main (TilemapInit &srt, const uint3 global_id, const uint local_index)
void comp_main (ViewVisibility &srt, const uint3 global_id)

Variables

PipelineCompute page_allocate (allocate)
PipelineCompute page_clear (page_clear_comp)
PipelineCompute page_defrag (defrag)
PipelineCompute page_free (free)
static constexpr uint SHADOW_TILE_AMENDED = SHADOW_IS_RENDERED
static constexpr uint SHADOW_TILE_MASKED = SHADOW_IS_ALLOCATED
PipelineCompute page_mask (mask)
PipelineGraphic tag_update (tag_update_vert, tag_update_frag)
PipelineCompute tag_update_propagate (tag_propagate)
PipelineCompute tag_usage_opaque (usage::tag_usage_opaque)
PipelineCompute tag_usage_surfels (usage::tag_usage_surfel)
PipelineCompute tag_usage_volume (usage::tag_usage_volume)
PipelineGraphic tag_usage_transparent (usage::tag_usage_vert, usage::tag_usage_frag)
PipelineCompute tilemap_bounds_init (tilemap_bounds_clear)
PipelineCompute tilemap_bounds (tilemap_bounds_min_max)
PipelineCompute tilemap_finalize (eevee::shadow::tilemap_finalize_main)
PipelineCompute tilemap_rendermap (eevee::shadow::rendermap_finalize_main)
PipelineCompute tilemap_init (tilemap_init_main)
PipelineCompute view_visibility (eevee::shadow::comp_main)

Detailed Description

Virtual shadow-mapping: Allocation.

Allocates pages to tiles needing them. Note that allocation can fail, in this case the tile is left with no page.

Virtual shadow-mapping: Defragment.

Defragment the cached page buffer making one continuous array.

Also pop_front the cached pages if there is not enough free pages for the needed allocations. Here is an example of the behavior of this buffer during one update cycle:

Initial state: 5 cached pages. Buffer starts at index 2 and ends at 6. [--xxxxx---------] After page free step: 2 cached pages were removed (r), 3 pages were inserted in the cache (i). [--xrxrxiii------] After page defragment step: The buffer is compressed into only 6 pages. [----xxxxxx------]

Virtual shadow-mapping: Tile page freeing.

Releases the allocated pages held by tile-maps that have been become unused. Also reclaim cached pages if the tiles needs them. Note that we also count the number of new page allocations needed.

Virtual shadow-mapping: Usage un-tagging.

Remove used tag from masked tiles (LOD overlap) or for load balancing (reducing the number of views per shadow map).

Virtual shadow-mapping: Update tagging

Any updated shadow caster needs to tag the shadow map tiles it was in and is now into. This is done in 2 pass of this same shader. One for past object bounds and one for new object bounds. The bounding boxes are rasterized and each fragment shader invocation tags the appropriate tiles.

Virtual shadow-mapping: Bounds computation for directional shadows.

Iterate through all shadow casters and extract min/max per directional shadow. This needs to happen first in the pipeline to allow tagging all relevant tile-map as dirty if their range changes.

Virtual shadow-mapping: Setup phase for tile-maps.

Clear the usage flag. Also tag for update shifted tiles for directional shadow clip-maps. Dispatched with one local thread per LOD0 tile and one work-group per tile-map.

Compute visibility of each resource bounds for a given shadow view. Checks for shadow linking properties and issue one draw call for each view.

Typedef Documentation

◆ PageAllocator

using eevee::shadow::PageAllocator = eevee::shadow::PageAllocator

Definition at line 18 of file eevee_shadow_page_allocate.bsl.hh.

◆ Statistics

using eevee::shadow::Statistics = eevee::shadow::Statistics

Definition at line 19 of file eevee_shadow_page_allocate.bsl.hh.

◆ TileMaps

using eevee::shadow::TileMaps = eevee::shadow::TileMaps

Definition at line 20 of file eevee_shadow_page_allocate.bsl.hh.

Function Documentation

◆ allocate()

void eevee::shadow::allocate ( PageAllocator & allocator,
TileMaps & tilemaps,
Statistics & stats,
const uint3 global_id,
const uint local_tile )

◆ comp_main()

◆ defrag()

void eevee::shadow::defrag ( PageAllocator & allocator,
Commands & cmds,
Statistics & stats )

Definition at line 38 of file eevee_shadow_page_defrag.bsl.hh.

References defrag(), and resource_table.

Referenced by defrag().

◆ free()

void eevee::shadow::free ( PageAllocator & allocator,
TileMaps & tilemaps,
const uint3 global_id,
const uint local_tile )

◆ mask()

void eevee::shadow::mask ( PageMask & srt,
TileMaps & tilemaps,
const uint3 global_id,
const uint local_tile_index )

◆ page_clear_comp()

void eevee::shadow::page_clear_comp ( PageClear & srt,
const uint3 global_id )

Virtual shadow-mapping: Page Clear.

Equivalent to a frame-buffer depth clear but only for pages pushed to the clear_page_buf.

Definition at line 24 of file eevee_shadow_page_clear.bsl.hh.

References floatBitsToUint, FLT_MAX, global_invocation_id, imageStoreFast, page_clear_comp(), and resource_table.

Referenced by page_clear_comp().

◆ rendermap_finalize_main()

void eevee::shadow::rendermap_finalize_main ( RendermapFinalize & srt,
const uint3 global_id )

Virtual shadow-mapping: Tile-map to render-map conversion.

For each shadow view, copy page atlas location to the indirection table before render.

Definition at line 227 of file eevee_shadow_tilemap_finalize.bsl.hh.

References all(), atomicAdd(), equal, global_invocation_id, lessThan, packUvec4x8(), rendermap_finalize_main(), resource_table, shadow_render_page_index_get(), shadow_tile_offset(), shadow_viewport_size_get(), tile, tile_index, int2::x, and int2::y.

Referenced by rendermap_finalize_main().

◆ shadow_tile_offset_lds()

int eevee::shadow::shadow_tile_offset_lds ( int2 tile,
int lod )

Definition at line 27 of file eevee_shadow_page_mask.bsl.hh.

References shadow_tile_offset(), shadow_tile_offset_lds(), and tile.

Referenced by mask(), and shadow_tile_offset_lds().

◆ tag_propagate()

void eevee::shadow::tag_propagate ( Tiles & tiles,
TileMaps & tilemaps,
const uint3 global_id )

◆ tag_update_frag()

void eevee::shadow::tag_update_frag ( Tiles & tiles,
TileMaps & tilemaps,
const float4 frag_coord,
const VertOut & v_out )

◆ tag_update_vert()

void eevee::shadow::tag_update_vert ( TagUpdate & srt,
TileMaps & tilemaps,
const int inst_per_tilemap_id,
const VertIn & v_in,
VertOut & v_out,
float4 & out_position )

◆ thread_mask()

bool eevee::shadow::thread_mask ( int2 tile_co,
int lod )

Definition at line 34 of file eevee_shadow_page_mask.bsl.hh.

References all(), lessThan, and thread_mask().

Referenced by mask(), and thread_mask().

◆ tilemap_bounds_clear()

void eevee::shadow::tilemap_bounds_clear ( TilemapBoundsInit & srt,
const uint3 global_id )

◆ tilemap_bounds_min_max()

◆ tilemap_finalize_main()

void eevee::shadow::tilemap_finalize_main ( TilemapFinalize & srt,
const uint3 global_id,
const uint local_index )

Virtual shadow-mapping: Tile-map to texture conversion.

For all visible light tile-maps, copy page coordinate to a texture. This avoids one level of indirection when evaluating shadows and allows to use a sampler instead of a SSBO bind.

Definition at line 61 of file eevee_shadow_tilemap_finalize.bsl.hh.

References all(), atomicAdd(), atomicMax(), atomicMin(), barrier(), equal, float, global_invocation_id, imageStoreFast, inverse, local_invocation_index, M_SQRT1_3, max, projection_orthographic(), projection_perspective(), resource_table, shadow_tile_coord_in_atlas(), shadow_tile_offset(), shadow_viewport_size_get(), ShadowSamplingTilePacked, ShadowTileDataPacked, tile, tile_index, tilemap_finalize_main(), viewport_index, viewport_select(), float2::x, int2::x, float2::y, and int2::y.

Referenced by tilemap_finalize_main().

◆ tilemap_init_main()

◆ viewport_select()

int eevee::shadow::viewport_select ( int2 rect_size)

Select the smallest viewport that can contain the given rect of tiles to render. Returns the viewport index.

Definition at line 22 of file eevee_shadow_tilemap_finalize.bsl.hh.

References findMSB, max, rect_size(), and viewport_select().

Referenced by tilemap_finalize_main(), and viewport_select().

Variable Documentation

◆ page_allocate

PipelineCompute eevee::shadow::page_allocate(allocate) ( allocate )

◆ page_clear

PipelineCompute eevee::shadow::page_clear(page_clear_comp) ( page_clear_comp )

◆ page_defrag

PipelineCompute eevee::shadow::page_defrag(defrag) ( defrag )

◆ page_free

PipelineCompute eevee::shadow::page_free(free) ( free )

◆ page_mask

PipelineCompute eevee::shadow::page_mask(mask) ( mask )

◆ SHADOW_TILE_AMENDED

uint eevee::shadow::SHADOW_TILE_AMENDED = SHADOW_IS_RENDERED
staticconstexpr

Definition at line 23 of file eevee_shadow_page_mask.bsl.hh.

Referenced by mask().

◆ SHADOW_TILE_MASKED

uint eevee::shadow::SHADOW_TILE_MASKED = SHADOW_IS_ALLOCATED
staticconstexpr

Definition at line 25 of file eevee_shadow_page_mask.bsl.hh.

Referenced by mask().

◆ tag_update

◆ tag_update_propagate

PipelineCompute eevee::shadow::tag_update_propagate(tag_propagate) ( tag_propagate )

◆ tag_usage_opaque

PipelineCompute eevee::shadow::tag_usage_opaque(usage::tag_usage_opaque) ( usage::tag_usage_opaque )

◆ tag_usage_surfels

PipelineCompute eevee::shadow::tag_usage_surfels(usage::tag_usage_surfel) ( usage::tag_usage_surfel )

◆ tag_usage_transparent

◆ tag_usage_volume

PipelineCompute eevee::shadow::tag_usage_volume(usage::tag_usage_volume) ( usage::tag_usage_volume )

◆ tilemap_bounds

◆ tilemap_bounds_init

PipelineCompute eevee::shadow::tilemap_bounds_init(tilemap_bounds_clear) ( tilemap_bounds_clear )

◆ tilemap_finalize

◆ tilemap_init

PipelineCompute eevee::shadow::tilemap_init(tilemap_init_main) ( tilemap_init_main )

◆ tilemap_rendermap

◆ view_visibility