5#include "testing/testing.h"
22using namespace blender::eevee;
37 int tile_lod0 = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 5;
38 int tile_lod1 = tile_lod0 +
square_i(SHADOW_TILEMAP_RES);
42 tilemap.
tiles_index = tiles_index * SHADOW_TILEDATA_PER_TILEMAP;
46 tilemaps_data.
append(tilemap);
55 tile.do_update =
true;
56 tiles_data[tile_lod0] = shadow_tile_pack(
tile);
60 tile.do_update =
false;
61 tiles_data[tile_lod1] = shadow_tile_pack(
tile);
71 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
72 pass.
bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
74 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data_);
85 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_lod0]).page,
uint3(1, 2, 0));
86 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_lod0]).is_used,
false);
87 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_lod0]).do_update,
true);
88 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_lod1]).page,
uint3(3, 2, 4));
89 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_lod1]).is_used,
false);
90 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_lod1]).do_update,
true);
108 auto tile_co_to_page = [](
int2 co) {
109 int page = co.x + co.y * SHADOW_TILEMAP_RES;
110 return uint3((page % SHADOW_PAGE_PER_ROW),
111 (page / SHADOW_PAGE_PER_ROW) % SHADOW_PAGE_PER_COL,
112 (page / SHADOW_PAGE_PER_LAYER));
122 tilemaps_clip[0] = clip;
133 tilemaps_data.
append(tilemap);
142 tile.is_allocated =
true;
143 tile.is_rendered =
true;
144 tile.do_update =
true;
146 tiles_data[
x +
y * SHADOW_TILEMAP_RES] = shadow_tile_pack(
tile);
158 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
159 pass.
bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
161 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
168 tilemaps_data.
read();
172 EXPECT_EQ(shadow_tile_unpack(tiles_data[0]).page,
173 tile_co_to_page(
int2(SHADOW_TILEMAP_RES - 1, 2)));
174 EXPECT_EQ(shadow_tile_unpack(tiles_data[0]).do_update,
true);
175 EXPECT_EQ(shadow_tile_unpack(tiles_data[0]).is_rendered,
false);
176 EXPECT_EQ(shadow_tile_unpack(tiles_data[0]).is_allocated,
true);
177 EXPECT_EQ(shadow_tile_unpack(tiles_data[1]).page, tile_co_to_page(
int2(0, 2)));
178 EXPECT_EQ(shadow_tile_unpack(tiles_data[1]).do_update,
false);
179 EXPECT_EQ(shadow_tile_unpack(tiles_data[1]).is_rendered,
false);
180 EXPECT_EQ(shadow_tile_unpack(tiles_data[1]).is_allocated,
true);
181 EXPECT_EQ(shadow_tile_unpack(tiles_data[0 + SHADOW_TILEMAP_RES * 2]).page,
182 tile_co_to_page(
int2(SHADOW_TILEMAP_RES - 1, 4)));
183 EXPECT_EQ(shadow_tile_unpack(tiles_data[0 + SHADOW_TILEMAP_RES * 2]).do_update,
true);
184 EXPECT_EQ(shadow_tile_unpack(tiles_data[0 + SHADOW_TILEMAP_RES * 2]).is_rendered,
false);
185 EXPECT_EQ(shadow_tile_unpack(tiles_data[0 + SHADOW_TILEMAP_RES * 2]).is_allocated,
true);
186 EXPECT_EQ(shadow_tile_unpack(tiles_data[1 + SHADOW_TILEMAP_RES * 2]).page,
187 tile_co_to_page(
int2(0, 4)));
188 EXPECT_EQ(shadow_tile_unpack(tiles_data[1 + SHADOW_TILEMAP_RES * 2]).do_update,
false);
189 EXPECT_EQ(shadow_tile_unpack(tiles_data[1 + SHADOW_TILEMAP_RES * 2]).is_rendered,
false);
190 EXPECT_EQ(shadow_tile_unpack(tiles_data[1 + SHADOW_TILEMAP_RES * 2]).is_allocated,
true);
240 tilemaps_data.
append(tilemap);
245 tilemaps_data.
append(tilemap);
252 "eevee_shadow_tag_update_propagate");
263 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
266 pass.
bind_ssbo(
"resource_ids_buf", past_casters_updated);
267 pass.
draw(box_batch, past_casters_updated.
size() * tilemaps_data.
size());
269 pass.
bind_ssbo(
"resource_ids_buf", curr_casters_updated);
270 pass.
draw(box_batch, curr_casters_updated.
size() * tilemaps_data.
size());
274 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
283 manager.
submit(pass, view);
289 "--------------------------------"
290 "--------------------------------"
291 "--------------------------------"
292 "--------------------------------"
293 "--------------------------------"
294 "--------------------------------"
295 "--------------------------------"
296 "--------------------------------"
297 "--------------------------------"
298 "--------------------------------"
299 "--------------------------------"
300 "--------------------------------"
301 "--------------------------------"
302 "--------------------------------"
303 "--------------------------------"
304 "--------------------------------"
305 "--------------------------------"
306 "--------------------------------"
307 "--------------------------------"
308 "xxxxx--------------xxxxxxxxxx---"
309 "xxxxx--------------xxxxxxxxxx---"
310 "xxxxx--------------xxxxxxxxxx---"
311 "xxxxx--------------xxxxxxxxxx---"
312 "xxxxx--------------xxxxxxxxxx---"
313 "xxxxx--------------xxxxxxxxxx---"
314 "xxxxx--------------xxxxxxxxxx---"
315 "xxxxx--------------xxxxxxxxxx---"
316 "xxxxx--------------xxxxxxxxxx---"
317 "xxxxx--------------xxxxxxxxxx---"
318 "--------------------------------"
319 "--------------------------------"
320 "--------------------------------";
356 const uint lod0_len = SHADOW_TILEMAP_LOD0_LEN;
357 const uint lod1_len = SHADOW_TILEMAP_LOD1_LEN;
358 const uint lod2_len = SHADOW_TILEMAP_LOD2_LEN;
359 const uint lod3_len = SHADOW_TILEMAP_LOD3_LEN;
360 const uint lod4_len = SHADOW_TILEMAP_LOD4_LEN;
361 const uint lod5_len = SHADOW_TILEMAP_LOD5_LEN;
363 auto stringify_result = [&](
uint start,
uint len) -> std::string {
366 result += (shadow_tile_unpack(tiles_data[i]).do_update) ?
"x" :
"-";
371 EXPECT_EQ(stringify_result(0, lod0_len), expected_lod0);
372 EXPECT_EQ(stringify_result(lod0_len, lod1_len), expected_lod1);
373 EXPECT_EQ(stringify_result(lod0_len + lod1_len, lod2_len), expected_lod2);
374 EXPECT_EQ(stringify_result(lod0_len + lod1_len + lod2_len, lod3_len), expected_lod3);
375 EXPECT_EQ(stringify_result(lod0_len + lod1_len + lod2_len + lod3_len, lod4_len), expected_lod4);
376 EXPECT_EQ(stringify_result(lod0_len + lod1_len + lod2_len + lod3_len + lod4_len, lod5_len),
400 int tile_orphaned_cached = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 5;
401 int tile_orphaned_allocated = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 6;
402 int tile_used_cached = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 260;
403 int tile_used_allocated = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 32;
404 int tile_used_unallocated = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 64;
405 int tile_unused_cached = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 9;
406 int tile_unused_allocated = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 8;
407 int page_free_count = SHADOW_MAX_PAGE - 6;
411 (i / SHADOW_PAGE_PER_ROW) % SHADOW_PAGE_PER_COL,
412 (i / SHADOW_PAGE_PER_LAYER));
413 pages_free_data[i] = shadow_page_pack(page);
425 pages_cached_data[i] =
uint2(-1, -1);
427 pages_cached_data[0] =
uint2(0, tile_orphaned_cached);
428 pages_cached_data[1] =
uint2(1, tile_used_cached);
438 tile.is_used =
false;
439 tile.do_update =
true;
441 tile.is_cached =
true;
442 tile.is_allocated =
false;
443 tiles_data[tile_orphaned_cached] = shadow_tile_pack(
tile);
445 tile.is_cached =
false;
446 tile.is_allocated =
true;
447 tiles_data[tile_orphaned_allocated] = shadow_tile_pack(
tile);
450 tile.do_update =
false;
453 tile.is_cached =
true;
454 tile.is_allocated =
false;
455 tiles_data[tile_used_cached] = shadow_tile_pack(
tile);
457 tile.is_cached =
false;
458 tile.is_allocated =
true;
459 tiles_data[tile_used_allocated] = shadow_tile_pack(
tile);
461 tile.is_cached =
false;
462 tile.is_allocated =
false;
463 tiles_data[tile_used_unallocated] = shadow_tile_pack(
tile);
465 tile.is_used =
false;
466 tile.is_cached =
true;
467 tile.is_allocated =
false;
468 tiles_data[tile_unused_cached] = shadow_tile_pack(
tile);
470 tile.is_cached =
false;
471 tile.is_allocated =
true;
472 tiles_data[tile_unused_allocated] = shadow_tile_pack(
tile);
478 tilemap.
tiles_index = tiles_index * SHADOW_TILEDATA_PER_TILEMAP;
479 tilemaps_data.
append(tilemap);
487 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
489 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
490 pass.
bind_ssbo(
"pages_free_buf", pages_free_data);
491 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
499 pages_infos_data.
read();
501 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_orphaned_cached]).is_cached,
false);
502 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_orphaned_cached]).is_allocated,
false);
503 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_orphaned_allocated]).is_cached,
false);
504 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_orphaned_allocated]).is_allocated,
false);
505 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_used_cached]).is_cached,
false);
506 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_used_cached]).is_allocated,
true);
507 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_used_allocated]).is_cached,
false);
508 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_used_allocated]).is_allocated,
true);
509 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_used_unallocated]).is_cached,
false);
510 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_used_unallocated]).is_allocated,
false);
511 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_unused_cached]).is_cached,
true);
512 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_unused_cached]).is_allocated,
false);
513 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_unused_allocated]).is_cached,
true);
514 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_unused_allocated]).is_allocated,
false);
540 int descriptor_offset,
545 uint2 page = {i % SHADOW_PAGE_PER_ROW, i / SHADOW_PAGE_PER_ROW};
546 pages_free_data[i] = page.x | (page.y << 16u);
553 int free_count = SHADOW_MAX_PAGE;
557 pages_cached_data[i] =
uint2(-1, -1);
560 int cached_index = descriptor_offset;
562 int inserted_count = 0;
564 tile.is_cached =
true;
568 tile.cache_index = cached_index++ % SHADOW_MAX_PAGE;
573 pages_cached_data[cached_index++ % SHADOW_MAX_PAGE] =
uint2(-1, -1);
577 tile.cache_index = (cached_index + inserted_count++) % SHADOW_MAX_PAGE;
586 pages_infos_data.page_alloc_count = allocation_count;
587 pages_infos_data.page_cached_next = cached_index + inserted_count;
588 pages_infos_data.page_free_count = free_count;
589 pages_infos_data.page_cached_start = descriptor_offset;
590 pages_infos_data.page_cached_end = cached_index;
592 tiles_data.push_update();
593 pages_infos_data.push_update();
594 pages_free_data.push_update();
595 pages_cached_data.push_update();
602 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
603 pass.
bind_ssbo(
"pages_free_buf", pages_free_data);
604 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
605 pass.
bind_ssbo(
"clear_dispatch_buf", clear_dispatch_buf);
606 pass.
bind_ssbo(
"tile_draw_buf", tile_draw_buf);
607 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
615 pages_cached_data.read();
616 pages_infos_data.read();
619 int expect_cached_len = 0;
621 if (pages_cached_data[i % SHADOW_MAX_PAGE].
y != -1) {
631 allocation_count =
min_ii(allocation_count, SHADOW_MAX_PAGE);
633 int additional_pages =
max_ii(0, allocation_count - free_count);
634 int expected_free_count =
max_ii(free_count, allocation_count);
635 int expected_start = descriptor_offset + hole_count + additional_pages;
636 int result_cached_len = pages_infos_data.page_cached_end - pages_infos_data.page_cached_start;
638 if (expected_start > SHADOW_MAX_PAGE) {
639 expected_start -= SHADOW_MAX_PAGE;
642 EXPECT_EQ(expected_free_count, pages_infos_data.page_free_count);
643 EXPECT_EQ(expected_start, pages_infos_data.page_cached_start);
644 EXPECT_EQ(expect_cached_len, result_cached_len);
645 EXPECT_EQ(pages_infos_data.page_cached_end, pages_infos_data.page_cached_next);
658 TestDefrag(0, 47,
"ccfcffccfcfciiiii",
"fffffcccccccccccc");
659 TestDefrag(10, SHADOW_MAX_PAGE - 5,
"ccfcffccfcfciiiii",
"fffffcccccccccccc");
660 TestDefrag(SHADOW_MAX_PAGE - 8, 30,
"ccfcffccfcfciiiii",
"fffffffffcccccccc");
661 TestDefrag(SHADOW_MAX_PAGE - 4, 30,
"ccfcffccfcfciiiii",
"fffffffffffffcccc");
663 TestDefrag(SHADOW_MAX_PAGE + 4, 30,
"ccfcffccfcfciiiii",
"fffffffffffffffff");
687 uint2 page = {i % SHADOW_PAGE_PER_ROW, i / SHADOW_PAGE_PER_ROW};
688 pages_free_data[i] = page.x | (page.y << 16u);
690 pages_free_data.push_update();
691 pages_cached_data.push_update();
693 pages_infos_data.page_free_count = page_free_count;
694 pages_infos_data.page_alloc_count = 1;
695 pages_infos_data.page_cached_next = 0u;
696 pages_infos_data.page_cached_start = 0u;
697 pages_infos_data.page_cached_end = 0u;
698 pages_infos_data.push_update();
700 statistics_buf.view_needed_count = 0;
701 statistics_buf.push_update();
703 int tile_allocated = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 5;
704 int tile_free = tiles_index * SHADOW_TILEDATA_PER_TILEMAP + 6;
710 tile.do_update =
false;
712 tile.is_cached =
false;
713 tile.is_allocated =
false;
714 tiles_data[tile_free] = shadow_tile_pack(
tile);
716 tile.is_cached =
false;
717 tile.is_allocated =
true;
718 tiles_data[tile_allocated] = shadow_tile_pack(
tile);
720 tiles_data.push_update();
724 tilemap.
tiles_index = tiles_index * SHADOW_TILEDATA_PER_TILEMAP;
725 tilemaps_data.append(tilemap);
726 tilemaps_data.push_update();
733 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
735 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
736 pass.
bind_ssbo(
"pages_free_buf", pages_free_data);
737 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
738 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
746 pages_infos_data.read();
748 bool alloc_success = page_free_count >= 1;
750 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_free]).do_update, alloc_success);
751 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_free]).is_allocated, alloc_success);
752 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_allocated]).do_update,
false);
753 EXPECT_EQ(shadow_tile_unpack(tiles_data[tile_allocated]).is_allocated,
true);
754 EXPECT_EQ(pages_infos_data.page_free_count, page_free_count - 1);
781 GTEST_SKIP() <<
"Device does not support multi viewport.";
795 const uint lod0_len = SHADOW_TILEMAP_LOD0_LEN;
796 const uint lod1_len = SHADOW_TILEMAP_LOD1_LEN;
797 const uint lod2_len = SHADOW_TILEMAP_LOD2_LEN;
798 const uint lod3_len = SHADOW_TILEMAP_LOD3_LEN;
799 const uint lod4_len = SHADOW_TILEMAP_LOD4_LEN;
801 const uint lod0_ofs = 0;
802 const uint lod1_ofs = lod0_len;
803 const uint lod2_ofs = lod1_ofs + lod1_len;
804 const uint lod3_ofs = lod2_ofs + lod2_len;
805 const uint lod4_ofs = lod3_ofs + lod3_len;
806 const uint lod5_ofs = lod4_ofs + lod4_len;
808 for (
auto i :
IndexRange(SHADOW_TILEDATA_PER_TILEMAP)) {
815 tile.is_allocated =
true;
818 tile.do_update =
false;
819 tiles_data[lod0_ofs] = shadow_tile_pack(
tile);
822 tile.do_update =
false;
823 tiles_data[lod1_ofs] = shadow_tile_pack(
tile);
826 tile.do_update =
true;
827 tiles_data[lod2_ofs] = shadow_tile_pack(
tile);
830 tile.do_update =
true;
831 tiles_data[lod3_ofs] = shadow_tile_pack(
tile);
834 tile.do_update =
true;
835 tiles_data[lod4_ofs] = shadow_tile_pack(
tile);
838 tile.do_update =
true;
839 tiles_data[lod5_ofs] = shadow_tile_pack(
tile);
842 tile.do_update =
true;
843 tiles_data[lod0_ofs + 31] = shadow_tile_pack(
tile);
846 tile.do_update =
true;
847 tiles_data[lod3_ofs + 8] = shadow_tile_pack(
tile);
850 tile.do_update =
true;
851 tiles_data[lod0_ofs + 32 * 16 - 8] = shadow_tile_pack(
tile);
864 tilemaps_data.
append(tilemap);
872 tilemaps_clip[0] = clip;
888 Texture tilemap_tx = {
"tilemap_tx"};
889 tilemap_tx.
ensure_2d(gpu::TextureFormat::UINT_32,
890 int2(SHADOW_TILEMAP_RES),
909 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
911 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
912 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
913 pass.
bind_ssbo(
"view_infos_buf", shadow_multi_view_buf);
914 pass.
bind_ssbo(
"render_view_buf", render_views_buf);
915 pass.
bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
923 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
924 pass.
bind_ssbo(
"render_view_buf", render_views_buf);
926 pass.
bind_ssbo(
"clear_dispatch_buf", clear_dispatch_buf);
927 pass.
bind_ssbo(
"tile_draw_buf", tile_draw_buf);
928 pass.
bind_ssbo(
"dst_coord_buf", &dst_coord_buf);
929 pass.
bind_ssbo(
"src_coord_buf", &src_coord_buf);
930 pass.
bind_ssbo(
"render_map_buf", &render_map_buf);
939 shadow_multi_view_buf.
read();
946 EXPECT_EQ(shadow_multi_view_buf[0].winmat,
948 EXPECT_EQ(shadow_multi_view_buf[1].winmat,
950 EXPECT_EQ(shadow_multi_view_buf[2].winmat,
952 EXPECT_EQ(shadow_multi_view_buf[3].winmat,
954 EXPECT_EQ(shadow_multi_view_buf[4].winmat,
965 result += std::to_string(
tile.page.x +
tile.page.y * SHADOW_PAGE_PER_ROW);
969 MEM_SAFE_DELETE(pixels);
973 "12334444555555556666666666666667"
974 "22334444555555556666666666666666"
975 "33334444555555556666666666666666"
976 "33334444555555556666666666666666"
977 "44444444555555556666666666666666"
978 "44444444555555556666666666666666"
979 "44444444555555556666666666666666"
980 "44444444555555556666666666666666"
981 "55555555555555556666666666666666"
982 "55555555555555556666666666666666"
983 "55555555555555556666666666666666"
984 "55555555555555556666666666666666"
985 "55555555555555556666666666666666"
986 "55555555555555556666666666666666"
987 "55555555555555556666666666666666"
988 "55555555555555556666666696666666"
989 "88888888666666666666666666666666"
990 "88888888666666666666666666666666"
991 "88888888666666666666666666666666"
992 "88888888666666666666666666666666"
993 "88888888666666666666666666666666"
994 "88888888666666666666666666666666"
995 "88888888666666666666666666666666"
996 "88888888666666666666666666666666"
997 "66666666666666666666666666666666"
998 "66666666666666666666666666666666"
999 "66666666666666666666666666666666"
1000 "66666666666666666666666666666666"
1001 "66666666666666666666666666666666"
1002 "66666666666666666666666666666666"
1003 "66666666666666666666666666666666"
1004 "66666666666666666666666666666666";
1012 for (
auto x :
data) {
1013 result += (
x == 0u) ?
'x' : ((
x == 0xFFFFFFFFu) ?
'-' :
'0' + (
x % 10));
1020 "6-------------------------------"
1021 "--------------------------------"
1022 "--------------------------------"
1023 "--------------------------------"
1024 "--------------------------------"
1025 "--------------------------------"
1026 "--------------------------------"
1027 "--------------------------------"
1028 "--------------------------------"
1029 "--------------------------------"
1030 "--------------------------------"
1031 "--------------------------------"
1032 "--------------------------------"
1033 "--------------------------------"
1034 "--------------------------------"
1035 "--------------------------------"
1036 "--------------------------------"
1037 "--------------------------------"
1038 "--------------------------------"
1039 "--------------------------------"
1040 "--------------------------------"
1041 "--------------------------------"
1042 "--------------------------------"
1043 "--------------------------------"
1044 "--------------------------------"
1045 "--------------------------------"
1046 "--------------------------------"
1047 "--------------------------------"
1048 "--------------------------------"
1049 "--------------------------------"
1050 "--------------------------------"
1051 "--------------------------------";
1054 "5-------------------------------"
1055 "--------------------------------"
1056 "--------------------------------"
1057 "--------------------------------"
1058 "--------------------------------"
1059 "--------------------------------"
1060 "--------------------------------"
1061 "--------------------------------"
1062 "--------------------------------"
1063 "--------------------------------"
1064 "--------------------------------"
1065 "--------------------------------"
1066 "--------------------------------"
1067 "--------------------------------"
1068 "--------------------------------"
1069 "--------------------------------"
1070 "--------------------------------"
1071 "--------------------------------"
1072 "--------------------------------"
1073 "--------------------------------"
1074 "--------------------------------"
1075 "--------------------------------"
1076 "--------------------------------"
1077 "--------------------------------"
1078 "--------------------------------"
1079 "--------------------------------"
1080 "--------------------------------"
1081 "--------------------------------"
1082 "--------------------------------"
1083 "--------------------------------"
1084 "--------------------------------"
1085 "--------------------------------";
1088 "4-------------------------------"
1089 "--------------------------------"
1090 "8-------------------------------"
1091 "--------------------------------"
1092 "--------------------------------"
1093 "--------------------------------"
1094 "--------------------------------"
1095 "--------------------------------"
1096 "--------------------------------"
1097 "--------------------------------"
1098 "--------------------------------"
1099 "--------------------------------"
1100 "--------------------------------"
1101 "--------------------------------"
1102 "--------------------------------"
1103 "--------------------------------"
1104 "--------------------------------"
1105 "--------------------------------"
1106 "--------------------------------"
1107 "--------------------------------"
1108 "--------------------------------"
1109 "--------------------------------"
1110 "--------------------------------"
1111 "--------------------------------"
1112 "--------------------------------"
1113 "--------------------------------"
1114 "--------------------------------"
1115 "--------------------------------"
1116 "--------------------------------"
1117 "--------------------------------"
1118 "--------------------------------"
1119 "--------------------------------";
1122 "3-------------------------------"
1123 "--------------------------------"
1124 "--------------------------------"
1125 "--------------------------------"
1126 "--------------------------------"
1127 "--------------------------------"
1128 "--------------------------------"
1129 "--------------------------------"
1130 "--------------------------------"
1131 "--------------------------------"
1132 "--------------------------------"
1133 "--------------------------------"
1134 "--------------------------------"
1135 "--------------------------------"
1136 "--------------------------------"
1137 "--------------------------------"
1138 "--------------------------------"
1139 "--------------------------------"
1140 "--------------------------------"
1141 "--------------------------------"
1142 "--------------------------------"
1143 "--------------------------------"
1144 "--------------------------------"
1145 "--------------------------------"
1146 "--------------------------------"
1147 "--------------------------------"
1148 "--------------------------------"
1149 "--------------------------------"
1150 "--------------------------------"
1151 "--------------------------------"
1152 "--------------------------------"
1153 "--------------------------------";
1156 "-------7------------------------"
1157 "--------------------------------"
1158 "--------------------------------"
1159 "--------------------------------"
1160 "--------------------------------"
1161 "--------------------------------"
1162 "--------------------------------"
1163 "--------------------------------"
1164 "--------------------------------"
1165 "--------------------------------"
1166 "--------------------------------"
1167 "--------------------------------"
1168 "--------------------------------"
1169 "--------------------------------"
1170 "--------------------------------"
1171 "9-------------------------------"
1172 "--------------------------------"
1173 "--------------------------------"
1174 "--------------------------------"
1175 "--------------------------------"
1176 "--------------------------------"
1177 "--------------------------------"
1178 "--------------------------------"
1179 "--------------------------------"
1180 "--------------------------------"
1181 "--------------------------------"
1182 "--------------------------------"
1183 "--------------------------------"
1184 "--------------------------------"
1185 "--------------------------------"
1186 "--------------------------------"
1187 "--------------------------------";
1189 render_map_buf.
read();
1192 SHADOW_TILEMAP_LOD0_LEN)),
1195 SHADOW_TILEMAP_LOD0_LEN)),
1198 SHADOW_TILEMAP_LOD0_LEN)),
1201 SHADOW_TILEMAP_LOD0_LEN)),
1204 SHADOW_TILEMAP_LOD0_LEN)),
1208 pages_infos_data.
read();
1211 statistics_buf.
read();
1225 Vector<uint> test_values{0x00000000u, 0x00000001u, 0x0000000Fu, 0x000000FFu, 0xABCDEF01u,
1226 0xAAAAAAAAu, 0xBBBBBBBBu, 0xCCCCCCCCu, 0xDDDDDDDDu, 0xEEEEEEEEu,
1227 0xFFFFFFFFu, 0xDEADBEEFu, 0x8BADF00Du, 0xABADCAFEu, 0x0D15EA5Eu,
1228 0xFEE1DEADu, 0xDEADC0DEu, 0xC00010FFu, 0xBBADBEEFu, 0xBAAAAAADu};
1230 for (
auto value : test_values) {
1232 shadow_page_unpack(shadow_page_pack(shadow_page_unpack(value))));
1234 EXPECT_EQ(shadow_lod_offset_unpack(value),
1235 shadow_lod_offset_unpack(shadow_lod_offset_pack(shadow_lod_offset_unpack(value))));
1238 ShadowTileData result_tile = shadow_tile_unpack(shadow_tile_pack(expected_tile));
1249 shadow_sampling_tile_pack(expected_sampling_tile));
1262 Vector<uint32_t> tilemap_data(SHADOW_TILEMAP_RES * SHADOW_TILEMAP_RES * SHADOW_TILEMAP_PER_ROW);
1263 tilemap_data.
fill(0);
1265 auto pixel_get = [&](
int x,
int y,
int tilemap_index) ->
uint32_t & {
1267 return tilemap_data[
y * SHADOW_TILEMAP_RES * SHADOW_TILEMAP_PER_ROW +
x +
1268 tilemap_index * SHADOW_TILEMAP_RES];
1273 tile.is_valid =
true;
1275 pixel_get(16, 16, 2) = shadow_sampling_tile_pack(
tile);
1277 pixel_get(17, 16, 2) = shadow_sampling_tile_pack(
tile);
1279 pixel_get(20, 20, 1) = shadow_sampling_tile_pack(
tile);
1281 pixel_get(17, 16, 0) = shadow_sampling_tile_pack(
tile);
1283 Texture tilemap_tx = {
"tilemap_tx"};
1286 int2 tilemap_res(SHADOW_TILEMAP_RES * SHADOW_TILEMAP_PER_ROW, SHADOW_TILEMAP_RES);
1287 tilemap_tx.
ensure_2d(gpu::TextureFormat::UINT_32, tilemap_res, usage);
1289 tilemap_tx,
GPU_DATA_UINT, tilemap_data.
data(), 0, 0, 0, tilemap_res.x, tilemap_res.y, 0);
1294 light.sun.clipmap_lod_min = 0;
1295 light.sun.clipmap_lod_max = 2;
1297 light.sun.clipmap_base_offset_neg =
int2(0, 1 << 0);
1299 light.sun.clipmap_base_offset_pos =
int2(1 << 1, 0);
1303 culling_light_buf[0] = light;
1322 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
1327 pass.
bind_ssbo(
"light_buf_write", culling_light_buf);
1336 manager.
submit(pass, view);
1341 auto stringify_tilemap = [&](
int tilemap_index) -> std::string {
1346 int tile_ofs =
y * SHADOW_TILEMAP_RES * SHADOW_TILEMAP_PER_ROW +
x +
1347 tilemap_index * SHADOW_TILEMAP_RES;
1349 result += std::to_string(
tile.page.x +
tile.page.y * SHADOW_PAGE_PER_ROW);
1350 if (
x + 1 == SHADOW_TILEMAP_RES / 2) {
1355 if (
y + 1 == SHADOW_TILEMAP_RES / 2) {
1362 auto stringify_lod = [&](
int tilemap_index) -> std::string {
1367 int tile_ofs =
y * SHADOW_TILEMAP_RES * SHADOW_TILEMAP_PER_ROW +
x +
1368 tilemap_index * SHADOW_TILEMAP_RES;
1371 if (
x + 1 == SHADOW_TILEMAP_RES / 2) {
1376 if (
y + 1 == SHADOW_TILEMAP_RES / 2) {
1383 auto stringify_offset = [&](
int tilemap_index) -> std::string {
1388 int tile_ofs =
y * SHADOW_TILEMAP_RES * SHADOW_TILEMAP_PER_ROW +
x +
1389 tilemap_index * SHADOW_TILEMAP_RES;
1392 if (
x + 1 == SHADOW_TILEMAP_RES / 2) {
1397 if (
y + 1 == SHADOW_TILEMAP_RES / 2) {
1407 "0000000000000000 0000000000000000\n"
1408 "0000000000000000 0000000000000000\n"
1409 "0000000000000000 0000000000000000\n"
1410 "0000000000000000 0000000000000000\n"
1411 "0000000000000000 0000000000000000\n"
1412 "0000000000000000 0000000000000000\n"
1413 "0000000000000000 0000000000000000\n"
1414 "0000000000000000 0000000000000000\n"
1415 "0000000000000000 0000000000000000\n"
1416 "0000000000000000 0000000000000000\n"
1417 "0000000000000000 0000000000000000\n"
1418 "0000000000000000 0000000000000000\n"
1419 "0000000000000000 0000000000000000\n"
1420 "0000000000000000 0000000000000000\n"
1421 "0000000000000000 0000000000000000\n"
1422 "0000000000000000 0000000000000000\n"
1424 "0000000000000000 1200000000000000\n"
1425 "0000000000000000 0000000000000000\n"
1426 "0000000000000000 0000000000000000\n"
1427 "0000000000000000 0000000000000000\n"
1428 "0000000000000000 0000000000000000\n"
1429 "0000000000000000 0000000000000000\n"
1430 "0000000000000000 0000000000000000\n"
1431 "0000000000000000 0000000000000000\n"
1432 "0000000000000000 0000000000000000\n"
1433 "0000000000000000 0000000000000000\n"
1434 "0000000000000000 0000000000000000\n"
1435 "0000000000000000 0000000000000000\n"
1436 "0000000000000000 0000000000000000\n"
1437 "0000000000000000 0000000000000000\n"
1438 "0000000000000000 0000000000000000\n"
1439 "0000000000000000 0000000000000000\n";
1442 "0000000000000000 0000000000000000\n"
1443 "0000000000000000 0000000000000000\n"
1444 "0000000000000000 0000000000000000\n"
1445 "0000000000000000 0000000000000000\n"
1446 "0000000000000000 0000000000000000\n"
1447 "0000000000000000 0000000000000000\n"
1448 "0000000000000000 0000000000000000\n"
1449 "0000000000000000 0000000000000000\n"
1450 "0000000000000000 0000000000000000\n"
1451 "0000000000000000 0000000000000000\n"
1452 "0000000000000000 0000000000000000\n"
1453 "0000000000000000 0000000000000000\n"
1454 "0000000000000000 0000000000000000\n"
1455 "0000000000000000 0000000000000000\n"
1456 "0000000000000000 0000000000000000\n"
1457 "0000000000000000 0000000000000000\n"
1459 "0000000000000001 1220000000000000\n"
1460 "0000000000000001 1220000000000000\n"
1461 "0000000000000000 0000000000000000\n"
1462 "0000000000000000 0000000000000000\n"
1463 "0000000000000000 0000300000000000\n"
1464 "0000000000000000 0000000000000000\n"
1465 "0000000000000000 0000000000000000\n"
1466 "0000000000000000 0000000000000000\n"
1467 "0000000000000000 0000000000000000\n"
1468 "0000000000000000 0000000000000000\n"
1469 "0000000000000000 0000000000000000\n"
1470 "0000000000000000 0000000000000000\n"
1471 "0000000000000000 0000000000000000\n"
1472 "0000000000000000 0000000000000000\n"
1473 "0000000000000000 0000000000000000\n"
1474 "0000000000000000 0000000000000000\n";
1477 "0000000000000000 0000000000000000\n"
1478 "0000000000000000 0000000000000000\n"
1479 "0000000000000000 0000000000000000\n"
1480 "0000000000000000 0000000000000000\n"
1481 "0000000000000000 0000000000000000\n"
1482 "0000000000000000 0000000000000000\n"
1483 "0000000000000000 0000000000000000\n"
1484 "0000000000000000 0000000000000000\n"
1485 "0000000000000000 0000000000000000\n"
1486 "0000000000000000 0000000000000000\n"
1487 "0000000000000000 0000000000000000\n"
1488 "0000000000000000 0000000000000000\n"
1489 "0000000000000000 0000000000000000\n"
1490 "0000000000000000 0000000000000000\n"
1491 "0000000000000000 0000000000000000\n"
1492 "0000000000000000 0000000000000000\n"
1494 "0000000000000000 0400000000000000\n"
1495 "0000000000000011 1122220000000000\n"
1496 "0000000000000011 1122220000000000\n"
1497 "0000000000000011 1122220000000000\n"
1498 "0000000000000011 1122220000000000\n"
1499 "0000000000000000 0000000000000000\n"
1500 "0000000000000000 0000000000000000\n"
1501 "0000000000000000 0000000000000000\n"
1502 "0000000000000000 0000000000000000\n"
1503 "0000000000000000 0000000033000000\n"
1504 "0000000000000000 0000000033000000\n"
1505 "0000000000000000 0000000000000000\n"
1506 "0000000000000000 0000000000000000\n"
1507 "0000000000000000 0000000000000000\n"
1508 "0000000000000000 0000000000000000\n"
1509 "0000000000000000 0000000000000000\n";
1511 EXPECT_EQ(expected_pages_lod2, stringify_tilemap(2));
1512 EXPECT_EQ(expected_pages_lod1, stringify_tilemap(1));
1513 EXPECT_EQ(expected_pages_lod0, stringify_tilemap(0));
1516 "0000000000000000 0000000000000000\n"
1517 "0000000000000000 0000000000000000\n"
1518 "0000000000000000 0000000000000000\n"
1519 "0000000000000000 0000000000000000\n"
1520 "0000000000000000 0000000000000000\n"
1521 "0000000000000000 0000000000000000\n"
1522 "0000000000000000 0000000000000000\n"
1523 "0000000000000000 0000000000000000\n"
1524 "0000000000000000 0000000000000000\n"
1525 "0000000000000000 0000000000000000\n"
1526 "0000000000000000 0000000000000000\n"
1527 "0000000000000000 0000000000000000\n"
1528 "0000000000000000 0000000000000000\n"
1529 "0000000000000000 0000000000000000\n"
1530 "0000000000000000 0000000000000000\n"
1531 "0000000000000000 0000000000000000\n"
1533 "0000000000000000 0000000000000000\n"
1534 "0000000000000022 2222220000000000\n"
1535 "0000000000000022 2222220000000000\n"
1536 "0000000000000022 2222220000000000\n"
1537 "0000000000000022 2222220000000000\n"
1538 "0000000000000000 0000000000000000\n"
1539 "0000000000000000 0000000000000000\n"
1540 "0000000000000000 0000000000000000\n"
1541 "0000000000000000 0000000000000000\n"
1542 "0000000000000000 0000000011000000\n"
1543 "0000000000000000 0000000011000000\n"
1544 "0000000000000000 0000000000000000\n"
1545 "0000000000000000 0000000000000000\n"
1546 "0000000000000000 0000000000000000\n"
1547 "0000000000000000 0000000000000000\n"
1548 "0000000000000000 0000000000000000\n";
1550 EXPECT_EQ(expected_lod_lod0, stringify_lod(0));
1554 "0000000000000000 0000000000000000\n"
1555 "0000000000000000 0000000000000000\n"
1556 "0000000000000000 0000000000000000\n"
1557 "0000000000000000 0000000000000000\n"
1558 "0000000000000000 0000000000000000\n"
1559 "0000000000000000 0000000000000000\n"
1560 "0000000000000000 0000000000000000\n"
1561 "0000000000000000 0000000000000000\n"
1562 "0000000000000000 0000000000000000\n"
1563 "0000000000000000 0000000000000000\n"
1564 "0000000000000000 0000000000000000\n"
1565 "0000000000000000 0000000000000000\n"
1566 "0000000000000000 0000000000000000\n"
1567 "0000000000000000 0000000000000000\n"
1568 "0000000000000000 0000000000000000\n"
1569 "0000000000000000 0000000000000000\n"
1571 "0000000000000000 0000000000000000\n"
1572 "0000000000000055 5555550000000000\n"
1573 "0000000000000055 5555550000000000\n"
1574 "0000000000000055 5555550000000000\n"
1575 "0000000000000055 5555550000000000\n"
1576 "0000000000000000 0000000000000000\n"
1577 "0000000000000000 0000000000000000\n"
1578 "0000000000000000 0000000000000000\n"
1579 "0000000000000000 0000000000000000\n"
1580 "0000000000000000 0000000011000000\n"
1581 "0000000000000000 0000000011000000\n"
1582 "0000000000000000 0000000000000000\n"
1583 "0000000000000000 0000000000000000\n"
1584 "0000000000000000 0000000000000000\n"
1585 "0000000000000000 0000000000000000\n"
1586 "0000000000000000 0000000000000000\n";
1588 EXPECT_EQ(expected_offset_lod0, stringify_offset(0));
1589 MEM_SAFE_DELETE(pixels);
1609 tilemaps_data.
append(tilemap);
1612 const uint lod0_len = SHADOW_TILEMAP_LOD0_LEN;
1613 const uint lod1_len = SHADOW_TILEMAP_LOD1_LEN;
1614 const uint lod2_len = SHADOW_TILEMAP_LOD2_LEN;
1615 const uint lod3_len = SHADOW_TILEMAP_LOD3_LEN;
1616 const uint lod4_len = SHADOW_TILEMAP_LOD4_LEN;
1617 const uint lod5_len = SHADOW_TILEMAP_LOD5_LEN;
1619 const uint lod0_ofs = 0;
1620 const uint lod1_ofs = lod0_ofs + lod0_len;
1621 const uint lod2_ofs = lod1_ofs + lod1_len;
1622 const uint lod3_ofs = lod2_ofs + lod2_len;
1623 const uint lod4_ofs = lod3_ofs + lod3_len;
1624 const uint lod5_ofs = lod4_ofs + lod4_len;
1629 for (
auto i :
IndexRange(SHADOW_TILEDATA_PER_TILEMAP)) {
1630 tile.is_used =
true;
1631 tile.do_update =
true;
1632 tiles_data[i] = shadow_tile_pack(
tile);
1637 tile.is_used =
false;
1638 tile.do_update =
false;
1639 tiles_data[i] = shadow_tile_pack(
tile);
1643 for (
auto y :
IndexRange((SHADOW_TILEMAP_RES / 2))) {
1644 for (
auto x :
IndexRange((SHADOW_TILEMAP_RES / 2) + 1)) {
1645 tile.is_used =
true;
1646 tile.do_update =
true;
1647 tiles_data[
x +
y * SHADOW_TILEMAP_RES] = shadow_tile_pack(
tile);
1653 tile.is_used =
true;
1654 tile.do_update =
true;
1655 tiles_data[
x] = shadow_tile_pack(
tile);
1660 for (
auto y :
IndexRange((SHADOW_TILEMAP_RES / 8))) {
1661 for (
auto x :
IndexRange((SHADOW_TILEMAP_RES / 8))) {
1662 tile.is_used =
false;
1663 tile.do_update =
false;
1664 tiles_data[
x +
y * (SHADOW_TILEMAP_RES / 2) + lod0_len] = shadow_tile_pack(
tile);
1671 int x = SHADOW_TILEMAP_RES / 4;
1672 int y = SHADOW_TILEMAP_RES / 4;
1673 tile.is_used =
false;
1674 tile.do_update =
false;
1675 tiles_data[
x +
y * (SHADOW_TILEMAP_RES / 2) + lod0_len] = shadow_tile_pack(
tile);
1687 pass.
push_constant(
"max_view_per_tilemap", max_view_per_tilemap);
1688 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
1689 pass.
bind_ssbo(
"tiles_buf", tiles_data);
1700 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
1701 "xxxxxxxxxxxxxxxxx---------------"
1702 "xxxxxxxxxxxxxxxxx---------------"
1703 "xxxxxxxxxxxxxxxxx---------------"
1704 "xxxxxxxxxxxxxxxxx---------------"
1705 "xxxxxxxxxxxxxxxxx---------------"
1706 "xxxxxxxxxxxxxxxxx---------------"
1707 "xxxxxxxxxxxxxxxxx---------------"
1708 "xxxxxxxxxxxxxxxxx---------------"
1709 "xxxxxxxxxxxxxxxxx---------------"
1710 "xxxxxxxxxxxxxxxxx---------------"
1711 "xxxxxxxxxxxxxxxxx---------------"
1712 "xxxxxxxxxxxxxxxxx---------------"
1713 "xxxxxxxxxxxxxxxxx---------------"
1714 "xxxxxxxxxxxxxxxxx---------------"
1715 "xxxxxxxxxxxxxxxxx---------------"
1716 "--------------------------------"
1717 "--------------------------------"
1718 "--------------------------------"
1719 "--------------------------------"
1720 "--------------------------------"
1721 "--------------------------------"
1722 "--------------------------------"
1723 "--------------------------------"
1724 "--------------------------------"
1725 "--------------------------------"
1726 "--------------------------------"
1727 "--------------------------------"
1728 "--------------------------------"
1729 "--------------------------------"
1730 "--------------------------------"
1731 "--------------------------------";
1794 auto stringify_result = [&](
uint start,
uint len) -> std::string {
1797 result += (shadow_tile_unpack(tiles_data[i]).is_used) ?
"x" :
"-";
1802 auto empty_result = [&](
uint len) -> std::string {
1810 if (max_view_per_tilemap >= 3) {
1811 EXPECT_EQ(stringify_result(lod0_ofs, lod0_len), expected_lod0);
1814 EXPECT_EQ(stringify_result(lod0_ofs, lod0_len), empty_result(lod0_len));
1817 if (max_view_per_tilemap > 2) {
1818 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), expected_lod1);
1820 else if (max_view_per_tilemap == 2) {
1821 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), expected_lod1_collapsed);
1824 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), empty_result(lod1_len));
1827 if (max_view_per_tilemap > 1) {
1828 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), expected_lod2);
1830 else if (max_view_per_tilemap == 1) {
1831 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), expected_lod2_collapsed);
1834 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), empty_result(lod2_len));
1836 EXPECT_EQ(stringify_result(lod3_ofs, lod3_len), expected_lod3);
1837 EXPECT_EQ(stringify_result(lod4_ofs, lod4_len), expected_lod4);
1838 EXPECT_EQ(stringify_result(lod5_ofs, lod5_len), expected_lod5);
1878 surfel.
normal = {0.0f, 0.0f, 1.0f};
1882 surfel.
position = {1.1f, 0.1f, 0.1f};
1883 surfel_buf.
append(surfel);
1885 surfel.
position = {1.1f, 0.2f, 0.5f};
1886 surfel_buf.
append(surfel);
1888 surfel.
position = {1.1f, 0.3f, 0.3f};
1889 surfel_buf.
append(surfel);
1891 surfel.
position = {1.2f, 0.4f, 0.2f};
1892 surfel_buf.
append(surfel);
1894 surfel.
position = {1.0f, 1.0f, 0.5f};
1895 surfel_buf.
append(surfel);
1897 surfel.
position = {0.1f, 1.1f, 0.5f};
1898 surfel_buf.
append(surfel);
1900 surfel.
position = {0.2f, 1.1f, 0.5f};
1901 surfel_buf.
append(surfel);
1939 View view = {
"RayProjectionView"};
1950 pass.
bind_ssbo(
"list_counter_buf", list_counter_buf);
1951 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1952 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1953 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1958 pass.
bind_ssbo(
"list_counter_buf", list_counter_buf);
1959 pass.
bind_ssbo(
"list_range_buf", list_range_buf);
1960 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1961 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1962 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1967 pass.
bind_ssbo(
"list_counter_buf", list_counter_buf);
1968 pass.
bind_ssbo(
"list_range_buf", list_range_buf);
1969 pass.
bind_ssbo(
"list_item_distance_buf", list_item_distance_buf);
1970 pass.
bind_ssbo(
"list_item_surfel_id_buf", list_item_surfel_id_buf);
1971 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1972 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1973 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1978 pass.
bind_ssbo(
"list_range_buf", list_range_buf);
1979 pass.
bind_ssbo(
"list_item_surfel_id_buf", list_item_surfel_id_buf);
1980 pass.
bind_ssbo(
"list_item_distance_buf", list_item_distance_buf);
1981 pass.
bind_ssbo(
"sorted_surfel_id_buf", sorted_surfel_id_buf);
1982 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1983 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1984 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1989 pass.
bind_ssbo(
"list_start_buf", list_start_buf);
1990 pass.
bind_ssbo(
"list_range_buf", list_range_buf);
1991 pass.
bind_ssbo(
"sorted_surfel_id_buf", sorted_surfel_id_buf);
1992 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1993 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1994 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1999 manager.
submit(pass, view);
2001 list_start_buf.
read();
2005 Vector<int> expect_link_next = {-1, +2, +3, +0, -1, -1, -1};
2006 Vector<int> expect_link_prev = {+3, -1, +1, +2, -1, -1, -1};
2010 link_next.
append(surfel.next);
2011 link_prev.
append(surfel.prev);
2015 EXPECT_EQ_SPAN<int>(expect_list_start, list_start_buf);
2016 EXPECT_EQ_SPAN<int>(expect_link_next, link_next);
2017 EXPECT_EQ_SPAN<int>(expect_link_prev, link_prev);
2050 const float eps = 3e-3f;
2051 EXPECT_NEAR_ARRAY_ND(brdf_ggx_lut.
data(), brdf_ggx_gen.data(), brdf_ggx_gen.size(), 3,
eps);
2052 EXPECT_NEAR_ARRAY_ND(btdf_ggx_lut.
data(), btdf_ggx_gen.data(), btdf_ggx_gen.size(), 1,
eps);
2053 EXPECT_NEAR_ARRAY_ND(bsdf_ggx_lut.
data(), bsdf_ggx_gen.data(), bsdf_ggx_gen.size(), 3,
eps);
2054 EXPECT_NEAR_ARRAY_ND(burley_gen.data(), burley_sss_lut.
data(), burley_sss_lut.
size(), 1,
eps);
2055 EXPECT_NEAR_ARRAY_ND(rand_walk_gen.data(), rand_walk_lut.
data(), rand_walk_lut.
size(), 1,
eps);
#define GPU_BATCH_DISCARD_SAFE(batch)
#define GPU_FRAMEBUFFER_FREE_SAFE(fb)
constexpr IndexRange()=default
constexpr const T * data() const
constexpr int64_t size() const
void append(const T &value)
void fill(const T &value) const
void begin_sync(Object *object_active=nullptr)
SwapChain< ObjectBoundsBuf, 2 > bounds_buf
void submit(PassSimple &pass, View &view)
ResourceHandleRange resource_handle(const ObjectRef &ref, float inflate_bounds=0.0f)
void resize(int64_t new_size)
void append(const T &value)
TestAlloc(int page_free_count)
TestDefrag(int allocation_count, int descriptor_offset, StringRefNull descriptor, StringRefNull expect)
bool ensure_2d(gpu::TextureFormat format, int2 extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
void clear(float4 values)
T * read(eGPUDataFormat format, int miplvl=0)
void sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id=0)
void framebuffer_set(gpu::FrameBuffer **framebuffer)
void shader_set(gpu::Shader *shader)
void bind_image(const char *name, gpu::Texture *image)
void dispatch(int group_len)
void barrier(GPUBarrier type)
void push_constant(const char *name, const float &data)
void bind_ssbo(const char *name, gpu::StorageBuf *buffer)
void draw(gpu::Batch *batch, uint instance_len=-1, uint vertex_len=-1, uint vertex_first=-1, ResourceIDRange res_id={}, uint custom_id=0)
Precompute(draw::Manager &manager, PrecomputeType type, int3 table_extent)
#define DRAW_TEST(test_name)
#define LIGHT_ZBIN_BUF_SLOT
#define LIGHT_TILE_BUF_SLOT
#define LIGHT_CULL_BUF_SLOT
float4x4 from_loc_rot_scale(float3 location, EulerXYZ rotation, float3 scale)
const ccl_global KernelWorkTile * tile
ccl_device_inline dual1 len(const ccl_private dual< T > &a)
detail::Pass< command::DrawCommandBuf > PassSimple
static void test_eevee_shadow_free()
static void test_eevee_surfel_list()
static void test_eevee_shadow_tilemap_amend()
static void test_eevee_lut_gen()
static void test_eevee_shadow_defrag()
static void test_eevee_shadow_finalize()
static void test_eevee_shadow_tag_update()
static void test_eevee_shadow_shift()
static void test_eevee_shadow_alloc()
static void test_eevee_shadow_page_mask()
static void test_eevee_shadow_page_mask_ex(int max_view_per_tilemap)
static void test_eevee_shadow_shift_clear()
static void test_eevee_shadow_tile_packing()
const float burley_sss_profile[64][1]
const float brdf_ggx[64][64][3]
const float random_walk_sss_profile[64][1]
const float btdf_ggx[16][64][64][1]
const float bsdf_ggx[16][64][64][3]
draw::StorageArrayBuffer< LightData, LIGHT_CHUNK > LightDataBuf
draw::StorageBuffer< ShadowPagesInfoData > ShadowPagesInfoDataBuf
draw::StorageArrayBuffer< ShadowTileDataPacked, SHADOW_MAX_TILE, true > ShadowTileDataBuf
draw::StorageArrayBuffer< ShadowTileMapClip, SHADOW_MAX_TILEMAP, true > ShadowTileMapClipBuf
draw::StorageArrayBuffer< uint, CULLING_ZBIN_COUNT, true > LightCullingZbinBuf
draw::StorageArrayBuffer< uint2, SHADOW_MAX_PAGE, true > ShadowPageCacheBuf
draw::StorageArrayBuffer< uint, LIGHT_CHUNK, true > LightCullingTileBuf
draw::StorageArrayBuffer< ShadowRenderView, SHADOW_VIEW_MAX, true > ShadowRenderViewBuf
@ LUT_GGX_BTDF_IOR_GT_ONE
@ LUT_RANDOM_WALK_SSS_PROFILE
draw::StorageBuffer< LightCullingData > LightCullingDataBuf
draw::StorageBuffer< SurfelListInfoData > SurfelListInfoBuf
draw::StorageBuffer< CaptureInfoData > CaptureInfoBuf
draw::StorageBuffer< ShadowStatistics > ShadowStatisticsBuf
draw::StorageVectorBuffer< ShadowTileMapData, SHADOW_MAX_TILEMAP > ShadowTileMapDataBuf
@ SHADOW_PROJECTION_CLIPMAP
@ SHADOW_PROJECTION_CUBEFACE
draw::StorageVectorBuffer< uint, SHADOW_MAX_PAGE > ShadowPageHeapBuf
MatBase< T, 4, 4 > orthographic(T left, T right, T bottom, T top, T near_clip, T far_clip)
Create an orthographic projection matrix using OpenGL coordinate convention: Maps each axis range to ...
MatBase< T, 4, 4 > perspective(T left, T right, T bottom, T top, T near_clip, T far_clip)
Create a perspective projection matrix using OpenGL coordinate convention: Maps each axis range to [-...
VecBase< uint32_t, 2 > uint2
VecBase< float, 1 > float1
MINLINE int square_i(int a)
BLI_INLINE float fb(float length, float L)
VecBase< uint32_t, 4 > uint4
gpu::Shader * GPU_shader_create_from_info_name(const char *info_name)
gpu::Batch * GPU_batch_unit_cube() ATTR_WARN_UNUSED_RESULT
MINLINE int max_ii(int a, int b)
VecBase< uint32_t, 3 > uint3
MatBase< float, 4, 4 > float4x4
void GPU_storagebuf_clear(gpu::StorageBuf *ssbo, uint32_t clear_value)
void GPU_texture_update_sub(gpu::Texture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth, uint unpack_row_length=0)
VecBase< int32_t, 2 > int2
VecBase< int32_t, 3 > int3
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_HOST_READ
void GPU_memory_barrier(GPUBarrier barrier)
BMesh const char void * data
@ GPU_BARRIER_BUFFER_UPDATE
@ GPU_BARRIER_SHADER_STORAGE
@ GPU_BARRIER_TEXTURE_UPDATE
gpu::FrameBuffer * GPU_framebuffer_create(const char *name)
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
void GPU_framebuffer_default_size(gpu::FrameBuffer *fb, int width, int height)
bool GPU_multi_viewport_support()
MINLINE uint ceil_to_multiple_u(uint a, uint b)
void GPU_shader_free(gpu::Shader *shader)
VecBase< float, 3 > float3
MINLINE int min_ii(int a, int b)
static Quaternion identity()
static MatBase identity()
enum eShadowProjectionType projection_type
void sync_orthographic(const float4x4 &object_mat_, int2 origin_offset, int clipmap_level, eShadowProjectionType projection_type_, uint2 shadow_set_membership_=~uint2(0))
void sync_cubeface(eLightType light_type_, const float4x4 &object_mat, float near, float far, eCubeFace face, uint2 shadow_set_membership_=~uint2(0))