EEVEE-Next: Shadow: Fix shader compilation

Some platforms do not support `bool` type as
shared variables, and no component reference
for atomics.
This commit is contained in:
Clément Foucault
2023-08-25 10:49:40 +02:00
parent e20a284cb9
commit 2eb447b00f
2 changed files with 19 additions and 12 deletions

View File

@@ -15,8 +15,10 @@
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_shadow_tilemap_lib.glsl)
shared ivec2 rect_min;
shared ivec2 rect_max;
shared int rect_min_x;
shared int rect_min_y;
shared int rect_max_x;
shared int rect_max_y;
shared int view_index;
/**
@@ -68,8 +70,10 @@ void main()
/* Compute update area. */
if (all(equal(gl_LocalInvocationID, uvec3(0)))) {
rect_min = ivec2(SHADOW_TILEMAP_RES);
rect_max = ivec2(0);
rect_min_x = SHADOW_TILEMAP_RES;
rect_min_y = SHADOW_TILEMAP_RES;
rect_max_x = 0;
rect_max_y = 0;
view_index = -1;
}
@@ -78,14 +82,17 @@ void main()
bool lod_valid_thread = all(equal(tile_co, tile_co_lod << lod));
bool do_page_render = tile.is_used && tile.do_update && lod_valid_thread;
if (do_page_render) {
atomicMin(rect_min.x, tile_co_lod.x);
atomicMin(rect_min.y, tile_co_lod.y);
atomicMax(rect_max.x, tile_co_lod.x + 1);
atomicMax(rect_max.y, tile_co_lod.y + 1);
atomicMin(rect_min_x, tile_co_lod.x);
atomicMin(rect_min_y, tile_co_lod.y);
atomicMax(rect_max_x, tile_co_lod.x + 1);
atomicMax(rect_max_y, tile_co_lod.y + 1);
}
barrier();
ivec2 rect_min = ivec2(rect_min_x, rect_min_y);
ivec2 rect_max = ivec2(rect_max_x, rect_max_y);
int viewport_index = viewport_select(rect_max - rect_min);
ivec2 viewport_size = viewport_size_get(viewport_index);

View File

@@ -14,7 +14,7 @@
#pragma BLENDER_REQUIRE(common_math_lib.glsl)
#pragma BLENDER_REQUIRE(eevee_shadow_tilemap_lib.glsl)
shared bool directional_range_changed;
shared int directional_range_changed;
ShadowTileDataPacked init_tile_data(ShadowTileDataPacked tile, bool do_update)
{
@@ -39,7 +39,7 @@ void main()
/* Reset shift to not tag for update more than once per sync cycle. */
tilemaps_buf[tilemap_index].grid_shift = ivec2(0);
directional_range_changed = false;
directional_range_changed = 0;
int clip_index = tilemap.clip_data_index;
if (clip_index == -1) {
@@ -51,7 +51,7 @@ void main()
float clip_far_new = orderedIntBitsToFloat(clip_data.clip_far);
bool near_changed = clip_near_new != clip_data.clip_near_stored;
bool far_changed = clip_far_new != clip_data.clip_far_stored;
directional_range_changed = near_changed || far_changed;
directional_range_changed = int(near_changed || far_changed);
/* NOTE(fclem): This assumes clip near/far are computed each time the initial phase runs. */
tilemaps_clip_buf[clip_index].clip_near_stored = clip_near_new;
tilemaps_clip_buf[clip_index].clip_far_stored = clip_far_new;
@@ -78,7 +78,7 @@ void main()
bool do_update = !in_range_inclusive(tile_shifted, ivec2(0), ivec2(SHADOW_TILEMAP_RES - 1));
/* TODO(fclem): Might be better to resize the depth stored instead of a full render update. */
if (directional_range_changed) {
if (directional_range_changed != 0) {
do_update = true;
}