5#include "testing/testing.h"
17using namespace blender::eevee;
41 tilemaps_data.
append(tilemap);
50 tile.do_update =
true;
55 tile.do_update =
false;
65 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
66 pass.
bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
68 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data_);
102 auto tile_co_to_page = [](
int2 co) {
116 tilemaps_clip[0] = clip;
127 tilemaps_data.
append(tilemap);
136 tile.is_allocated =
true;
137 tile.is_rendered =
true;
138 tile.do_update =
true;
151 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
152 pass.
bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
154 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
161 tilemaps_data.
read();
180 tile_co_to_page(
int2(0, 4)));
233 tilemaps_data.
append(tilemap);
238 tilemaps_data.
append(tilemap);
247 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
250 pass.
bind_ssbo(
"resource_ids_buf", past_casters_updated);
253 pass.
bind_ssbo(
"resource_ids_buf", curr_casters_updated);
267 "--------------------------------"
268 "--------------------------------"
269 "--------------------------------"
270 "--------------------------------"
271 "--------------------------------"
272 "--------------------------------"
273 "--------------------------------"
274 "--------------------------------"
275 "--------------------------------"
276 "--------------------------------"
277 "--------------------------------"
278 "--------------------------------"
279 "--------------------------------"
280 "--------------------------------"
281 "--------------------------------"
282 "--------------------------------"
283 "--------------------------------"
284 "--------------------------------"
285 "--------------------------------"
286 "--------------------------------"
287 "xxxx----------------xxxxxxxx----"
288 "xxxx----------------xxxxxxxx----"
289 "xxxx----------------xxxxxxxx----"
290 "xxxx----------------xxxxxxxx----"
291 "xxxx----------------xxxxxxxx----"
292 "xxxx----------------xxxxxxxx----"
293 "xxxx----------------xxxxxxxx----"
294 "xxxx----------------xxxxxxxx----"
295 "--------------------------------"
296 "--------------------------------"
297 "--------------------------------"
298 "--------------------------------";
341 auto stringify_result = [&](
uint start,
uint len) -> std::string {
349 EXPECT_EQ(stringify_result(0, lod0_len), expected_lod0);
350 EXPECT_EQ(stringify_result(lod0_len, lod1_len), expected_lod1);
351 EXPECT_EQ(stringify_result(lod0_len + lod1_len, lod2_len), expected_lod2);
352 EXPECT_EQ(stringify_result(lod0_len + lod1_len + lod2_len, lod3_len), expected_lod3);
353 EXPECT_EQ(stringify_result(lod0_len + lod1_len + lod2_len + lod3_len, lod4_len), expected_lod4);
354 EXPECT_EQ(stringify_result(lod0_len + lod1_len + lod2_len + lod3_len + lod4_len, lod5_len),
400 pages_cached_data[
i] =
uint2(-1, -1);
402 pages_cached_data[0] =
uint2(0, tile_orphaned_cached);
403 pages_cached_data[1] =
uint2(1, tile_used_cached);
413 tile.is_used =
false;
414 tile.do_update =
true;
416 tile.is_cached =
true;
417 tile.is_allocated =
false;
420 tile.is_cached =
false;
421 tile.is_allocated =
true;
425 tile.do_update =
false;
428 tile.is_cached =
true;
429 tile.is_allocated =
false;
432 tile.is_cached =
false;
433 tile.is_allocated =
true;
436 tile.is_cached =
false;
437 tile.is_allocated =
false;
440 tile.is_used =
false;
441 tile.is_cached =
true;
442 tile.is_allocated =
false;
445 tile.is_cached =
false;
446 tile.is_allocated =
true;
454 tilemaps_data.
append(tilemap);
462 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
464 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
465 pass.
bind_ssbo(
"pages_free_buf", pages_free_data);
466 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
474 pages_infos_data.
read();
515 int descriptor_offset,
521 pages_free_data[
i] = page.x | (page.y << 16u);
532 pages_cached_data[
i] =
uint2(-1, -1);
535 int cached_index = descriptor_offset;
537 int inserted_count = 0;
539 tile.is_cached =
true;
561 pages_infos_data.page_alloc_count = allocation_count;
562 pages_infos_data.page_cached_next = cached_index + inserted_count;
563 pages_infos_data.page_free_count = free_count;
564 pages_infos_data.page_cached_start = descriptor_offset;
565 pages_infos_data.page_cached_end = cached_index;
567 tiles_data.push_update();
568 pages_infos_data.push_update();
569 pages_free_data.push_update();
570 pages_cached_data.push_update();
577 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
578 pass.
bind_ssbo(
"pages_free_buf", pages_free_data);
579 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
580 pass.
bind_ssbo(
"clear_dispatch_buf", clear_dispatch_buf);
581 pass.
bind_ssbo(
"tile_draw_buf", tile_draw_buf);
582 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
590 pages_cached_data.read();
591 pages_infos_data.read();
594 int expect_cached_len = 0;
608 int additional_pages =
max_ii(0, allocation_count - free_count);
609 int expected_free_count =
max_ii(free_count, allocation_count);
610 int expected_start = descriptor_offset + hole_count + additional_pages;
611 int result_cached_len = pages_infos_data.page_cached_end - pages_infos_data.page_cached_start;
617 EXPECT_EQ(expected_free_count, pages_infos_data.page_free_count);
618 EXPECT_EQ(expected_start, pages_infos_data.page_cached_start);
619 EXPECT_EQ(expect_cached_len, result_cached_len);
620 EXPECT_EQ(pages_infos_data.page_cached_end, pages_infos_data.page_cached_next);
633 TestDefrag(0, 47,
"ccfcffccfcfciiiii",
"fffffcccccccccccc");
663 pages_free_data[
i] = page.x | (page.y << 16u);
665 pages_free_data.push_update();
666 pages_cached_data.push_update();
668 pages_infos_data.page_free_count = page_free_count;
669 pages_infos_data.page_alloc_count = 1;
670 pages_infos_data.page_cached_next = 0u;
671 pages_infos_data.page_cached_start = 0u;
672 pages_infos_data.page_cached_end = 0u;
673 pages_infos_data.push_update();
675 statistics_buf.view_needed_count = 0;
676 statistics_buf.push_update();
685 tile.do_update =
false;
687 tile.is_cached =
false;
688 tile.is_allocated =
false;
691 tile.is_cached =
false;
692 tile.is_allocated =
true;
695 tiles_data.push_update();
700 tilemaps_data.append(tilemap);
701 tilemaps_data.push_update();
708 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
710 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
711 pass.
bind_ssbo(
"pages_free_buf", pages_free_data);
712 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
713 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
721 pages_infos_data.read();
723 bool alloc_success = page_free_count >= 1;
729 EXPECT_EQ(pages_infos_data.page_free_count, page_free_count - 1);
766 const uint lod0_ofs = 0;
767 const uint lod1_ofs = lod0_len;
768 const uint lod2_ofs = lod1_ofs + lod1_len;
769 const uint lod3_ofs = lod2_ofs + lod2_len;
770 const uint lod4_ofs = lod3_ofs + lod3_len;
771 const uint lod5_ofs = lod4_ofs + lod4_len;
780 tile.is_allocated =
true;
783 tile.do_update =
false;
787 tile.do_update =
false;
791 tile.do_update =
true;
795 tile.do_update =
true;
799 tile.do_update =
true;
803 tile.do_update =
true;
807 tile.do_update =
true;
811 tile.do_update =
true;
815 tile.do_update =
true;
829 tilemaps_data.
append(tilemap);
837 tilemaps_clip[0] = clip;
853 Texture tilemap_tx = {
"tilemap_tx"};
873 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
875 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
876 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
877 pass.
bind_ssbo(
"view_infos_buf", shadow_multi_view_buf);
878 pass.
bind_ssbo(
"render_view_buf", render_views_buf);
879 pass.
bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
886 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
887 pass.
bind_ssbo(
"render_view_buf", render_views_buf);
889 pass.
bind_ssbo(
"clear_dispatch_buf", clear_dispatch_buf);
890 pass.
bind_ssbo(
"tile_draw_buf", tile_draw_buf);
891 pass.
bind_ssbo(
"dst_coord_buf", &dst_coord_buf);
892 pass.
bind_ssbo(
"src_coord_buf", &src_coord_buf);
893 pass.
bind_ssbo(
"render_map_buf", &render_map_buf);
902 shadow_multi_view_buf.
read();
909 EXPECT_EQ(shadow_multi_view_buf[0].winmat,
911 EXPECT_EQ(shadow_multi_view_buf[1].winmat,
913 EXPECT_EQ(shadow_multi_view_buf[2].winmat,
915 EXPECT_EQ(shadow_multi_view_buf[3].winmat,
917 EXPECT_EQ(shadow_multi_view_buf[4].winmat,
936 "12334444555555556666666666666667"
937 "22334444555555556666666666666666"
938 "33334444555555556666666666666666"
939 "33334444555555556666666666666666"
940 "44444444555555556666666666666666"
941 "44444444555555556666666666666666"
942 "44444444555555556666666666666666"
943 "44444444555555556666666666666666"
944 "55555555555555556666666666666666"
945 "55555555555555556666666666666666"
946 "55555555555555556666666666666666"
947 "55555555555555556666666666666666"
948 "55555555555555556666666666666666"
949 "55555555555555556666666666666666"
950 "55555555555555556666666666666666"
951 "55555555555555556666666696666666"
952 "88888888666666666666666666666666"
953 "88888888666666666666666666666666"
954 "88888888666666666666666666666666"
955 "88888888666666666666666666666666"
956 "88888888666666666666666666666666"
957 "88888888666666666666666666666666"
958 "88888888666666666666666666666666"
959 "88888888666666666666666666666666"
960 "66666666666666666666666666666666"
961 "66666666666666666666666666666666"
962 "66666666666666666666666666666666"
963 "66666666666666666666666666666666"
964 "66666666666666666666666666666666"
965 "66666666666666666666666666666666"
966 "66666666666666666666666666666666"
967 "66666666666666666666666666666666";
975 for (
auto x :
data) {
976 result += (
x == 0u) ?
'-' : ((
x == 0xFFFFFFFFu) ?
'x' :
'0' + (
x % 10));
983 "6-------------------------------"
984 "--------------------------------"
985 "--------------------------------"
986 "--------------------------------"
987 "--------------------------------"
988 "--------------------------------"
989 "--------------------------------"
990 "--------------------------------"
991 "--------------------------------"
992 "--------------------------------"
993 "--------------------------------"
994 "--------------------------------"
995 "--------------------------------"
996 "--------------------------------"
997 "--------------------------------"
998 "--------------------------------"
999 "--------------------------------"
1000 "--------------------------------"
1001 "--------------------------------"
1002 "--------------------------------"
1003 "--------------------------------"
1004 "--------------------------------"
1005 "--------------------------------"
1006 "--------------------------------"
1007 "--------------------------------"
1008 "--------------------------------"
1009 "--------------------------------"
1010 "--------------------------------"
1011 "--------------------------------"
1012 "--------------------------------"
1013 "--------------------------------"
1014 "--------------------------------";
1017 "5-------------------------------"
1018 "--------------------------------"
1019 "--------------------------------"
1020 "--------------------------------"
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 "--------------------------------";
1051 "4xxx----------------------------"
1052 "xxxx----------------------------"
1053 "8xxx----------------------------"
1054 "xxxx----------------------------"
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 "--------------------------------";
1085 "3-------------------------------"
1086 "--------------------------------"
1087 "--------------------------------"
1088 "--------------------------------"
1089 "--------------------------------"
1090 "--------------------------------"
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 "--------------------------------";
1119 "xxxxxxx7xxxxxxxx----------------"
1120 "xxxxxxxxxxxxxxxx----------------"
1121 "xxxxxxxxxxxxxxxx----------------"
1122 "xxxxxxxxxxxxxxxx----------------"
1123 "xxxxxxxxxxxxxxxx----------------"
1124 "xxxxxxxxxxxxxxxx----------------"
1125 "xxxxxxxxxxxxxxxx----------------"
1126 "xxxxxxxxxxxxxxxx----------------"
1127 "xxxxxxxxxxxxxxxx----------------"
1128 "xxxxxxxxxxxxxxxx----------------"
1129 "xxxxxxxxxxxxxxxx----------------"
1130 "xxxxxxxxxxxxxxxx----------------"
1131 "xxxxxxxxxxxxxxxx----------------"
1132 "xxxxxxxxxxxxxxxx----------------"
1133 "xxxxxxxxxxxxxxxx----------------"
1134 "9xxxxxxxxxxxxxxx----------------"
1135 "--------------------------------"
1136 "--------------------------------"
1137 "--------------------------------"
1138 "--------------------------------"
1139 "--------------------------------"
1140 "--------------------------------"
1141 "--------------------------------"
1142 "--------------------------------"
1143 "--------------------------------"
1144 "--------------------------------"
1145 "--------------------------------"
1146 "--------------------------------"
1147 "--------------------------------"
1148 "--------------------------------"
1149 "--------------------------------"
1150 "--------------------------------";
1152 render_map_buf.
read();
1171 pages_infos_data.
read();
1174 statistics_buf.
read();
1188 Vector<uint> test_values{0x00000000u, 0x00000001u, 0x0000000Fu, 0x000000FFu, 0xABCDEF01u,
1189 0xAAAAAAAAu, 0xBBBBBBBBu, 0xCCCCCCCCu, 0xDDDDDDDDu, 0xEEEEEEEEu,
1190 0xFFFFFFFFu, 0xDEADBEEFu, 0x8BADF00Du, 0xABADCAFEu, 0x0D15EA5Eu,
1191 0xFEE1DEADu, 0xDEADC0DEu, 0xC00010FFu, 0xBBADBEEFu, 0xBAAAAAADu};
1193 for (
auto value : test_values) {
1227 tilemap_data.
fill(0);
1229 auto pixel_get = [&](
int x,
int y,
int tilemap_index) -> uint32_t & {
1237 tile.is_valid =
true;
1247 Texture tilemap_tx = {
"tilemap_tx"};
1253 tilemap_tx,
GPU_DATA_UINT, tilemap_data.
data(), 0, 0, 0, tilemap_res.x, tilemap_res.y, 0);
1258 light.sun.clipmap_lod_min = 0;
1259 light.sun.clipmap_lod_max = 2;
1261 light.sun.clipmap_base_offset_neg =
int2(0, 1 << 0);
1263 light.sun.clipmap_base_offset_pos =
int2(1 << 1, 0);
1264 light.tilemap_index = 0;
1267 culling_light_buf[0] = light;
1286 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
1304 auto stringify_tilemap = [&](
int tilemap_index) -> std::string {
1325 auto stringify_lod = [&](
int tilemap_index) -> std::string {
1346 auto stringify_offset = [&](
int tilemap_index) -> std::string {
1370 "0000000000000000 0000000000000000\n"
1371 "0000000000000000 0000000000000000\n"
1372 "0000000000000000 0000000000000000\n"
1373 "0000000000000000 0000000000000000\n"
1374 "0000000000000000 0000000000000000\n"
1375 "0000000000000000 0000000000000000\n"
1376 "0000000000000000 0000000000000000\n"
1377 "0000000000000000 0000000000000000\n"
1378 "0000000000000000 0000000000000000\n"
1379 "0000000000000000 0000000000000000\n"
1380 "0000000000000000 0000000000000000\n"
1381 "0000000000000000 0000000000000000\n"
1382 "0000000000000000 0000000000000000\n"
1383 "0000000000000000 0000000000000000\n"
1384 "0000000000000000 0000000000000000\n"
1385 "0000000000000000 0000000000000000\n"
1387 "0000000000000000 1200000000000000\n"
1388 "0000000000000000 0000000000000000\n"
1389 "0000000000000000 0000000000000000\n"
1390 "0000000000000000 0000000000000000\n"
1391 "0000000000000000 0000000000000000\n"
1392 "0000000000000000 0000000000000000\n"
1393 "0000000000000000 0000000000000000\n"
1394 "0000000000000000 0000000000000000\n"
1395 "0000000000000000 0000000000000000\n"
1396 "0000000000000000 0000000000000000\n"
1397 "0000000000000000 0000000000000000\n"
1398 "0000000000000000 0000000000000000\n"
1399 "0000000000000000 0000000000000000\n"
1400 "0000000000000000 0000000000000000\n"
1401 "0000000000000000 0000000000000000\n"
1402 "0000000000000000 0000000000000000\n";
1405 "0000000000000000 0000000000000000\n"
1406 "0000000000000000 0000000000000000\n"
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"
1422 "0000000000000001 1220000000000000\n"
1423 "0000000000000001 1220000000000000\n"
1424 "0000000000000000 0000000000000000\n"
1425 "0000000000000000 0000000000000000\n"
1426 "0000000000000000 0000300000000000\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";
1440 "0000000000000000 0000000000000000\n"
1441 "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"
1457 "0000000000000000 0400000000000000\n"
1458 "0000000000000011 1122220000000000\n"
1459 "0000000000000011 1122220000000000\n"
1460 "0000000000000011 1122220000000000\n"
1461 "0000000000000011 1122220000000000\n"
1462 "0000000000000000 0000000000000000\n"
1463 "0000000000000000 0000000000000000\n"
1464 "0000000000000000 0000000000000000\n"
1465 "0000000000000000 0000000000000000\n"
1466 "0000000000000000 0000000033000000\n"
1467 "0000000000000000 0000000033000000\n"
1468 "0000000000000000 0000000000000000\n"
1469 "0000000000000000 0000000000000000\n"
1470 "0000000000000000 0000000000000000\n"
1471 "0000000000000000 0000000000000000\n"
1472 "0000000000000000 0000000000000000\n";
1474 EXPECT_EQ(expected_pages_lod2, stringify_tilemap(2));
1475 EXPECT_EQ(expected_pages_lod1, stringify_tilemap(1));
1476 EXPECT_EQ(expected_pages_lod0, stringify_tilemap(0));
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"
1493 "0000000000000000 0000000000000000\n"
1494 "0000000000000000 0000000000000000\n"
1496 "0000000000000000 0000000000000000\n"
1497 "0000000000000022 2222220000000000\n"
1498 "0000000000000022 2222220000000000\n"
1499 "0000000000000022 2222220000000000\n"
1500 "0000000000000022 2222220000000000\n"
1501 "0000000000000000 0000000000000000\n"
1502 "0000000000000000 0000000000000000\n"
1503 "0000000000000000 0000000000000000\n"
1504 "0000000000000000 0000000000000000\n"
1505 "0000000000000000 0000000011000000\n"
1506 "0000000000000000 0000000011000000\n"
1507 "0000000000000000 0000000000000000\n"
1508 "0000000000000000 0000000000000000\n"
1509 "0000000000000000 0000000000000000\n"
1510 "0000000000000000 0000000000000000\n"
1511 "0000000000000000 0000000000000000\n";
1513 EXPECT_EQ(expected_lod_lod0, stringify_lod(0));
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"
1532 "0000000000000000 0000000000000000\n"
1534 "0000000000000000 0000000000000000\n"
1535 "0000000000000055 5555550000000000\n"
1536 "0000000000000055 5555550000000000\n"
1537 "0000000000000055 5555550000000000\n"
1538 "0000000000000055 5555550000000000\n"
1539 "0000000000000000 0000000000000000\n"
1540 "0000000000000000 0000000000000000\n"
1541 "0000000000000000 0000000000000000\n"
1542 "0000000000000000 0000000000000000\n"
1543 "0000000000000000 0000000011000000\n"
1544 "0000000000000000 0000000011000000\n"
1545 "0000000000000000 0000000000000000\n"
1546 "0000000000000000 0000000000000000\n"
1547 "0000000000000000 0000000000000000\n"
1548 "0000000000000000 0000000000000000\n"
1549 "0000000000000000 0000000000000000\n";
1551 EXPECT_EQ(expected_offset_lod0, stringify_offset(0));
1572 tilemaps_data.
append(tilemap);
1582 const uint lod0_ofs = 0;
1583 const uint lod1_ofs = lod0_ofs + lod0_len;
1584 const uint lod2_ofs = lod1_ofs + lod1_len;
1585 const uint lod3_ofs = lod2_ofs + lod2_len;
1586 const uint lod4_ofs = lod3_ofs + lod3_len;
1587 const uint lod5_ofs = lod4_ofs + lod4_len;
1593 tile.is_used =
true;
1594 tile.do_update =
true;
1600 tile.is_used =
false;
1601 tile.do_update =
false;
1608 tile.is_used =
true;
1609 tile.do_update =
true;
1616 tile.is_used =
true;
1617 tile.do_update =
true;
1625 tile.is_used =
false;
1626 tile.do_update =
false;
1636 tile.is_used =
false;
1637 tile.do_update =
false;
1650 pass.
push_constant(
"max_view_per_tilemap", max_view_per_tilemap);
1651 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
1652 pass.
bind_ssbo(
"tiles_buf", tiles_data);
1663 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
1664 "xxxxxxxxxxxxxxxxx---------------"
1665 "xxxxxxxxxxxxxxxxx---------------"
1666 "xxxxxxxxxxxxxxxxx---------------"
1667 "xxxxxxxxxxxxxxxxx---------------"
1668 "xxxxxxxxxxxxxxxxx---------------"
1669 "xxxxxxxxxxxxxxxxx---------------"
1670 "xxxxxxxxxxxxxxxxx---------------"
1671 "xxxxxxxxxxxxxxxxx---------------"
1672 "xxxxxxxxxxxxxxxxx---------------"
1673 "xxxxxxxxxxxxxxxxx---------------"
1674 "xxxxxxxxxxxxxxxxx---------------"
1675 "xxxxxxxxxxxxxxxxx---------------"
1676 "xxxxxxxxxxxxxxxxx---------------"
1677 "xxxxxxxxxxxxxxxxx---------------"
1678 "xxxxxxxxxxxxxxxxx---------------"
1679 "--------------------------------"
1680 "--------------------------------"
1681 "--------------------------------"
1682 "--------------------------------"
1683 "--------------------------------"
1684 "--------------------------------"
1685 "--------------------------------"
1686 "--------------------------------"
1687 "--------------------------------"
1688 "--------------------------------"
1689 "--------------------------------"
1690 "--------------------------------"
1691 "--------------------------------"
1692 "--------------------------------"
1693 "--------------------------------"
1694 "--------------------------------";
1757 auto stringify_result = [&](
uint start,
uint len) -> std::string {
1765 auto empty_result = [&](
uint len) -> std::string {
1773 if (max_view_per_tilemap >= 3) {
1774 EXPECT_EQ(stringify_result(lod0_ofs, lod0_len), expected_lod0);
1777 EXPECT_EQ(stringify_result(lod0_ofs, lod0_len), empty_result(lod0_len));
1780 if (max_view_per_tilemap > 2) {
1781 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), expected_lod1);
1783 else if (max_view_per_tilemap == 2) {
1784 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), expected_lod1_collapsed);
1787 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), empty_result(lod1_len));
1790 if (max_view_per_tilemap > 1) {
1791 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), expected_lod2);
1793 else if (max_view_per_tilemap == 1) {
1794 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), expected_lod2_collapsed);
1797 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), empty_result(lod2_len));
1799 EXPECT_EQ(stringify_result(lod3_ofs, lod3_len), expected_lod3);
1800 EXPECT_EQ(stringify_result(lod4_ofs, lod4_len), expected_lod4);
1801 EXPECT_EQ(stringify_result(lod5_ofs, lod5_len), expected_lod5);
1825 GTEST_SKIP() <<
"Result is non-deterministic. To be revisited.";
1841 surfel.
position = {1.1f, 0.1f, 0.1f};
1842 surfel_buf.
append(surfel);
1844 surfel.
position = {1.1f, 0.2f, 0.5f};
1845 surfel_buf.
append(surfel);
1847 surfel.
position = {1.1f, 0.3f, 0.3f};
1848 surfel_buf.
append(surfel);
1850 surfel.
position = {1.2f, 0.4f, 0.2f};
1851 surfel_buf.
append(surfel);
1853 surfel.
position = {1.0f, 1.0f, 0.5f};
1854 surfel_buf.
append(surfel);
1856 surfel.
position = {0.1f, 1.1f, 0.5f};
1857 surfel_buf.
append(surfel);
1885 pass.
bind_ssbo(
"list_start_buf", list_start_buf);
1886 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1887 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1888 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1893 pass.
bind_ssbo(
"list_start_buf", list_start_buf);
1894 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1895 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1902 list_start_buf.
read();
1906 Vector<int> expect_link_next = {-1, +2, +3, +0, -1, -1};
1907 Vector<int> expect_link_prev = {+3, -1, +1, +2, -1, -1};
1911 link_next.
append(surfel.next);
1912 link_prev.
append(surfel.prev);
1923 EXPECT_EQ_ARRAY(expect_list_start.
data(), list_start_buf.
data(), expect_list_start.
size());
1925 EXPECT_EQ_ARRAY(expect_link_next.
data(), link_next.
data(), expect_link_next.
size());
1926 EXPECT_EQ_ARRAY(expect_link_prev.
data(), link_prev.
data(), expect_link_prev.
size());
1956 const float eps = 3e-3f;
1957 EXPECT_NEAR_ARRAY_ND(brdf_ggx_lut.
data(), brdf_ggx_gen.data(), brdf_ggx_gen.size(), 3,
eps);
1958 EXPECT_NEAR_ARRAY_ND(btdf_ggx_lut.
data(), btdf_ggx_gen.data(), btdf_ggx_gen.size(), 1,
eps);
1959 EXPECT_NEAR_ARRAY_ND(bsdf_ggx_lut.
data(), bsdf_ggx_gen.data(), bsdf_ggx_gen.size(), 3,
eps);
1960 EXPECT_NEAR_ARRAY_ND(burley_gen.data(), burley_sss_lut.
data(), burley_sss_lut.
size(), 1,
eps);
1961 EXPECT_NEAR_ARRAY_ND(rand_walk_gen.data(), rand_walk_lut.
data(), rand_walk_lut.
size(), 1,
eps);
EXPECT_EQ(BLI_expr_pylike_eval(expr, nullptr, 0, &result), EXPR_PYLIKE_INVALID)
MINLINE uint ceil_to_multiple_u(uint a, uint b)
MINLINE int min_ii(int a, int b)
MINLINE int square_i(int a)
MINLINE int max_ii(int a, int b)
GPUShader * GPU_shader_create_from_info_name(const char *info_name)
void GPU_shader_free(GPUShader *shader)
void GPU_memory_barrier(eGPUBarrier barrier)
@ GPU_BARRIER_SHADER_STORAGE
@ GPU_BARRIER_BUFFER_UPDATE
@ GPU_BARRIER_TEXTURE_UPDATE
void GPU_storagebuf_clear(GPUStorageBuf *ssbo, uint32_t clear_value)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_HOST_READ
void GPU_texture_update_sub(GPUTexture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
BMesh const char void * data
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)
void clear(float4 values)
T * read(eGPUDataFormat format, int miplvl=0)
bool ensure_2d(eGPUTextureFormat format, int2 extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
void bind_image(const char *name, GPUTexture *image)
void dispatch(int group_len)
void barrier(eGPUBarrier type)
void push_constant(const char *name, const float &data)
void bind_ssbo(const char *name, GPUStorageBuf *buffer)
void shader_set(GPUShader *shader)
#define DRAW_TEST(test_name)
#define SHADOW_TILEMAP_LOD2_LEN
#define SHADOW_TILEMAP_RES
#define SHADOW_TILEMAP_LOD4_LEN
#define SHADOW_TILEMAP_PER_ROW
#define SHADOW_TILEMAP_LOD1_LEN
#define SHADOW_PAGE_PER_ROW
#define SHADOW_TILEMAP_LOD0_LEN
#define LIGHT_ZBIN_BUF_SLOT
#define SHADOW_TILEDATA_PER_TILEMAP
#define SHADOW_PAGE_PER_COL
#define SHADOW_PAGE_PER_LAYER
#define LIGHT_TILE_BUF_SLOT
#define SHADOW_TILEMAP_LOD5_LEN
#define LIGHT_CULL_BUF_SLOT
#define SHADOW_TILEMAP_LOD3_LEN
const ccl_global KernelWorkTile * tile
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
static ShadowTileDataPacked shadow_tile_pack(ShadowTileData tile)
static ShadowSamplingTilePacked shadow_sampling_tile_pack(ShadowSamplingTile tile)
draw::StorageBuffer< SurfelListInfoData > SurfelListInfoBuf
static ShadowTileData shadow_tile_unpack(ShadowTileDataPacked data)
static uint2 shadow_lod_offset_unpack(uint data)
static uint3 shadow_page_unpack(uint data)
draw::StorageBuffer< CaptureInfoData > CaptureInfoBuf
static uint shadow_page_pack(uint3 page)
static uint shadow_lod_offset_pack(uint2 ofs)
draw::StorageBuffer< ShadowStatistics > ShadowStatisticsBuf
draw::StorageVectorBuffer< ShadowTileMapData, SHADOW_MAX_TILEMAP > ShadowTileMapDataBuf
@ SHADOW_PROJECTION_CLIPMAP
@ SHADOW_PROJECTION_CUBEFACE
static ShadowSamplingTile shadow_sampling_tile_unpack(ShadowSamplingTilePacked data)
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 [-...
MatT from_loc_rot_scale(const typename MatT::loc_type &location, const RotationT &rotation, const VecBase< typename MatT::base_type, ScaleDim > &scale)
VecBase< uint32_t, 2 > uint2
VecBase< float, 1 > float1
VecBase< uint32_t, 4 > uint4
VecBase< uint32_t, 3 > uint3
MatBase< float, 4, 4 > float4x4
VecBase< int32_t, 2 > int2
VecBase< int32_t, 3 > int3
VecBase< float, 3 > float3
static MatBase identity()
uint resource_index() const
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))
static QuaternionBase identity()