5#include "testing/testing.h"
20using namespace blender::eevee;
44 tilemaps_data.
append(tilemap);
53 tile.do_update =
true;
58 tile.do_update =
false;
68 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
69 pass.
bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
71 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data_);
105 auto tile_co_to_page = [](
int2 co) {
119 tilemaps_clip[0] = clip;
130 tilemaps_data.
append(tilemap);
139 tile.is_allocated =
true;
140 tile.is_rendered =
true;
141 tile.do_update =
true;
154 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
155 pass.
bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
157 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
164 tilemaps_data.
read();
183 tile_co_to_page(
int2(0, 4)));
236 tilemaps_data.
append(tilemap);
241 tilemaps_data.
append(tilemap);
250 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
253 pass.
bind_ssbo(
"resource_ids_buf", past_casters_updated);
256 pass.
bind_ssbo(
"resource_ids_buf", curr_casters_updated);
270 "--------------------------------"
271 "--------------------------------"
272 "--------------------------------"
273 "--------------------------------"
274 "--------------------------------"
275 "--------------------------------"
276 "--------------------------------"
277 "--------------------------------"
278 "--------------------------------"
279 "--------------------------------"
280 "--------------------------------"
281 "--------------------------------"
282 "--------------------------------"
283 "--------------------------------"
284 "--------------------------------"
285 "--------------------------------"
286 "--------------------------------"
287 "--------------------------------"
288 "--------------------------------"
289 "--------------------------------"
290 "xxxx----------------xxxxxxxx----"
291 "xxxx----------------xxxxxxxx----"
292 "xxxx----------------xxxxxxxx----"
293 "xxxx----------------xxxxxxxx----"
294 "xxxx----------------xxxxxxxx----"
295 "xxxx----------------xxxxxxxx----"
296 "xxxx----------------xxxxxxxx----"
297 "xxxx----------------xxxxxxxx----"
298 "--------------------------------"
299 "--------------------------------"
300 "--------------------------------"
301 "--------------------------------";
344 auto stringify_result = [&](
uint start,
uint len) -> std::string {
352 EXPECT_EQ(stringify_result(0, lod0_len), expected_lod0);
353 EXPECT_EQ(stringify_result(lod0_len, lod1_len), expected_lod1);
354 EXPECT_EQ(stringify_result(lod0_len + lod1_len, lod2_len), expected_lod2);
355 EXPECT_EQ(stringify_result(lod0_len + lod1_len + lod2_len, lod3_len), expected_lod3);
356 EXPECT_EQ(stringify_result(lod0_len + lod1_len + lod2_len + lod3_len, lod4_len), expected_lod4);
357 EXPECT_EQ(stringify_result(lod0_len + lod1_len + lod2_len + lod3_len + lod4_len, lod5_len),
403 pages_cached_data[
i] =
uint2(-1, -1);
405 pages_cached_data[0] =
uint2(0, tile_orphaned_cached);
406 pages_cached_data[1] =
uint2(1, tile_used_cached);
416 tile.is_used =
false;
417 tile.do_update =
true;
419 tile.is_cached =
true;
420 tile.is_allocated =
false;
423 tile.is_cached =
false;
424 tile.is_allocated =
true;
428 tile.do_update =
false;
431 tile.is_cached =
true;
432 tile.is_allocated =
false;
435 tile.is_cached =
false;
436 tile.is_allocated =
true;
439 tile.is_cached =
false;
440 tile.is_allocated =
false;
443 tile.is_used =
false;
444 tile.is_cached =
true;
445 tile.is_allocated =
false;
448 tile.is_cached =
false;
449 tile.is_allocated =
true;
457 tilemaps_data.
append(tilemap);
465 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
467 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
468 pass.
bind_ssbo(
"pages_free_buf", pages_free_data);
469 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
477 pages_infos_data.
read();
518 int descriptor_offset,
524 pages_free_data[
i] = page.x | (page.y << 16u);
535 pages_cached_data[
i] =
uint2(-1, -1);
538 int cached_index = descriptor_offset;
540 int inserted_count = 0;
542 tile.is_cached =
true;
564 pages_infos_data.page_alloc_count = allocation_count;
565 pages_infos_data.page_cached_next = cached_index + inserted_count;
566 pages_infos_data.page_free_count = free_count;
567 pages_infos_data.page_cached_start = descriptor_offset;
568 pages_infos_data.page_cached_end = cached_index;
570 tiles_data.push_update();
571 pages_infos_data.push_update();
572 pages_free_data.push_update();
573 pages_cached_data.push_update();
580 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
581 pass.
bind_ssbo(
"pages_free_buf", pages_free_data);
582 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
583 pass.
bind_ssbo(
"clear_dispatch_buf", clear_dispatch_buf);
584 pass.
bind_ssbo(
"tile_draw_buf", tile_draw_buf);
585 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
593 pages_cached_data.read();
594 pages_infos_data.read();
597 int expect_cached_len = 0;
611 int additional_pages =
max_ii(0, allocation_count - free_count);
612 int expected_free_count =
max_ii(free_count, allocation_count);
613 int expected_start = descriptor_offset + hole_count + additional_pages;
614 int result_cached_len = pages_infos_data.page_cached_end - pages_infos_data.page_cached_start;
620 EXPECT_EQ(expected_free_count, pages_infos_data.page_free_count);
621 EXPECT_EQ(expected_start, pages_infos_data.page_cached_start);
622 EXPECT_EQ(expect_cached_len, result_cached_len);
623 EXPECT_EQ(pages_infos_data.page_cached_end, pages_infos_data.page_cached_next);
636 TestDefrag(0, 47,
"ccfcffccfcfciiiii",
"fffffcccccccccccc");
666 pages_free_data[
i] = page.x | (page.y << 16u);
668 pages_free_data.push_update();
669 pages_cached_data.push_update();
671 pages_infos_data.page_free_count = page_free_count;
672 pages_infos_data.page_alloc_count = 1;
673 pages_infos_data.page_cached_next = 0u;
674 pages_infos_data.page_cached_start = 0u;
675 pages_infos_data.page_cached_end = 0u;
676 pages_infos_data.push_update();
678 statistics_buf.view_needed_count = 0;
679 statistics_buf.push_update();
688 tile.do_update =
false;
690 tile.is_cached =
false;
691 tile.is_allocated =
false;
694 tile.is_cached =
false;
695 tile.is_allocated =
true;
698 tiles_data.push_update();
703 tilemaps_data.append(tilemap);
704 tilemaps_data.push_update();
711 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
713 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
714 pass.
bind_ssbo(
"pages_free_buf", pages_free_data);
715 pass.
bind_ssbo(
"pages_cached_buf", pages_cached_data);
716 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
724 pages_infos_data.read();
726 bool alloc_success = page_free_count >= 1;
732 EXPECT_EQ(pages_infos_data.page_free_count, page_free_count - 1);
769 const uint lod0_ofs = 0;
770 const uint lod1_ofs = lod0_len;
771 const uint lod2_ofs = lod1_ofs + lod1_len;
772 const uint lod3_ofs = lod2_ofs + lod2_len;
773 const uint lod4_ofs = lod3_ofs + lod3_len;
774 const uint lod5_ofs = lod4_ofs + lod4_len;
783 tile.is_allocated =
true;
786 tile.do_update =
false;
790 tile.do_update =
false;
794 tile.do_update =
true;
798 tile.do_update =
true;
802 tile.do_update =
true;
806 tile.do_update =
true;
810 tile.do_update =
true;
814 tile.do_update =
true;
818 tile.do_update =
true;
832 tilemaps_data.
append(tilemap);
840 tilemaps_clip[0] = clip;
856 Texture tilemap_tx = {
"tilemap_tx"};
857 tilemap_tx.
ensure_2d(blender::gpu::TextureFormat::UINT_32,
876 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
878 pass.
bind_ssbo(
"pages_infos_buf", pages_infos_data);
879 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
880 pass.
bind_ssbo(
"view_infos_buf", shadow_multi_view_buf);
881 pass.
bind_ssbo(
"render_view_buf", render_views_buf);
882 pass.
bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
889 pass.
bind_ssbo(
"statistics_buf", statistics_buf);
890 pass.
bind_ssbo(
"render_view_buf", render_views_buf);
892 pass.
bind_ssbo(
"clear_dispatch_buf", clear_dispatch_buf);
893 pass.
bind_ssbo(
"tile_draw_buf", tile_draw_buf);
894 pass.
bind_ssbo(
"dst_coord_buf", &dst_coord_buf);
895 pass.
bind_ssbo(
"src_coord_buf", &src_coord_buf);
896 pass.
bind_ssbo(
"render_map_buf", &render_map_buf);
905 shadow_multi_view_buf.
read();
912 EXPECT_EQ(shadow_multi_view_buf[0].winmat,
914 EXPECT_EQ(shadow_multi_view_buf[1].winmat,
916 EXPECT_EQ(shadow_multi_view_buf[2].winmat,
918 EXPECT_EQ(shadow_multi_view_buf[3].winmat,
920 EXPECT_EQ(shadow_multi_view_buf[4].winmat,
939 "12334444555555556666666666666667"
940 "22334444555555556666666666666666"
941 "33334444555555556666666666666666"
942 "33334444555555556666666666666666"
943 "44444444555555556666666666666666"
944 "44444444555555556666666666666666"
945 "44444444555555556666666666666666"
946 "44444444555555556666666666666666"
947 "55555555555555556666666666666666"
948 "55555555555555556666666666666666"
949 "55555555555555556666666666666666"
950 "55555555555555556666666666666666"
951 "55555555555555556666666666666666"
952 "55555555555555556666666666666666"
953 "55555555555555556666666666666666"
954 "55555555555555556666666696666666"
955 "88888888666666666666666666666666"
956 "88888888666666666666666666666666"
957 "88888888666666666666666666666666"
958 "88888888666666666666666666666666"
959 "88888888666666666666666666666666"
960 "88888888666666666666666666666666"
961 "88888888666666666666666666666666"
962 "88888888666666666666666666666666"
963 "66666666666666666666666666666666"
964 "66666666666666666666666666666666"
965 "66666666666666666666666666666666"
966 "66666666666666666666666666666666"
967 "66666666666666666666666666666666"
968 "66666666666666666666666666666666"
969 "66666666666666666666666666666666"
970 "66666666666666666666666666666666";
978 for (
auto x :
data) {
979 result += (
x == 0u) ?
'-' : ((
x == 0xFFFFFFFFu) ?
'x' :
'0' + (
x % 10));
986 "6-------------------------------"
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 "--------------------------------"
1015 "--------------------------------"
1016 "--------------------------------"
1017 "--------------------------------";
1020 "5-------------------------------"
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 "4xxx----------------------------"
1055 "xxxx----------------------------"
1056 "8xxx----------------------------"
1057 "xxxx----------------------------"
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 "3-------------------------------"
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 "--------------------------------"
1117 "--------------------------------"
1118 "--------------------------------"
1119 "--------------------------------";
1122 "xxxxxxx7xxxxxxxx----------------"
1123 "xxxxxxxxxxxxxxxx----------------"
1124 "xxxxxxxxxxxxxxxx----------------"
1125 "xxxxxxxxxxxxxxxx----------------"
1126 "xxxxxxxxxxxxxxxx----------------"
1127 "xxxxxxxxxxxxxxxx----------------"
1128 "xxxxxxxxxxxxxxxx----------------"
1129 "xxxxxxxxxxxxxxxx----------------"
1130 "xxxxxxxxxxxxxxxx----------------"
1131 "xxxxxxxxxxxxxxxx----------------"
1132 "xxxxxxxxxxxxxxxx----------------"
1133 "xxxxxxxxxxxxxxxx----------------"
1134 "xxxxxxxxxxxxxxxx----------------"
1135 "xxxxxxxxxxxxxxxx----------------"
1136 "xxxxxxxxxxxxxxxx----------------"
1137 "9xxxxxxxxxxxxxxx----------------"
1138 "--------------------------------"
1139 "--------------------------------"
1140 "--------------------------------"
1141 "--------------------------------"
1142 "--------------------------------"
1143 "--------------------------------"
1144 "--------------------------------"
1145 "--------------------------------"
1146 "--------------------------------"
1147 "--------------------------------"
1148 "--------------------------------"
1149 "--------------------------------"
1150 "--------------------------------"
1151 "--------------------------------"
1152 "--------------------------------"
1153 "--------------------------------";
1155 render_map_buf.
read();
1174 pages_infos_data.
read();
1177 statistics_buf.
read();
1191 Vector<uint> test_values{0x00000000u, 0x00000001u, 0x0000000Fu, 0x000000FFu, 0xABCDEF01u,
1192 0xAAAAAAAAu, 0xBBBBBBBBu, 0xCCCCCCCCu, 0xDDDDDDDDu, 0xEEEEEEEEu,
1193 0xFFFFFFFFu, 0xDEADBEEFu, 0x8BADF00Du, 0xABADCAFEu, 0x0D15EA5Eu,
1194 0xFEE1DEADu, 0xDEADC0DEu, 0xC00010FFu, 0xBBADBEEFu, 0xBAAAAAADu};
1196 for (
auto value : test_values) {
1230 tilemap_data.
fill(0);
1232 auto pixel_get = [&](
int x,
int y,
int tilemap_index) -> uint32_t & {
1240 tile.is_valid =
true;
1250 Texture tilemap_tx = {
"tilemap_tx"};
1254 tilemap_tx.
ensure_2d(blender::gpu::TextureFormat::UINT_32, tilemap_res, usage);
1256 tilemap_tx,
GPU_DATA_UINT, tilemap_data.
data(), 0, 0, 0, tilemap_res.x, tilemap_res.y, 0);
1261 light.sun.clipmap_lod_min = 0;
1262 light.sun.clipmap_lod_max = 2;
1264 light.sun.clipmap_base_offset_neg =
int2(0, 1 << 0);
1266 light.sun.clipmap_base_offset_pos =
int2(1 << 1, 0);
1267 light.tilemap_index = 0;
1270 culling_light_buf[0] = light;
1289 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
1307 auto stringify_tilemap = [&](
int tilemap_index) -> std::string {
1328 auto stringify_lod = [&](
int tilemap_index) -> std::string {
1349 auto stringify_offset = [&](
int tilemap_index) -> std::string {
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"
1386 "0000000000000000 0000000000000000\n"
1387 "0000000000000000 0000000000000000\n"
1388 "0000000000000000 0000000000000000\n"
1390 "0000000000000000 1200000000000000\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"
1403 "0000000000000000 0000000000000000\n"
1404 "0000000000000000 0000000000000000\n"
1405 "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"
1423 "0000000000000000 0000000000000000\n"
1425 "0000000000000001 1220000000000000\n"
1426 "0000000000000001 1220000000000000\n"
1427 "0000000000000000 0000000000000000\n"
1428 "0000000000000000 0000000000000000\n"
1429 "0000000000000000 0000300000000000\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"
1440 "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"
1458 "0000000000000000 0000000000000000\n"
1460 "0000000000000000 0400000000000000\n"
1461 "0000000000000011 1122220000000000\n"
1462 "0000000000000011 1122220000000000\n"
1463 "0000000000000011 1122220000000000\n"
1464 "0000000000000011 1122220000000000\n"
1465 "0000000000000000 0000000000000000\n"
1466 "0000000000000000 0000000000000000\n"
1467 "0000000000000000 0000000000000000\n"
1468 "0000000000000000 0000000000000000\n"
1469 "0000000000000000 0000000033000000\n"
1470 "0000000000000000 0000000033000000\n"
1471 "0000000000000000 0000000000000000\n"
1472 "0000000000000000 0000000000000000\n"
1473 "0000000000000000 0000000000000000\n"
1474 "0000000000000000 0000000000000000\n"
1475 "0000000000000000 0000000000000000\n";
1477 EXPECT_EQ(expected_pages_lod2, stringify_tilemap(2));
1478 EXPECT_EQ(expected_pages_lod1, stringify_tilemap(1));
1479 EXPECT_EQ(expected_pages_lod0, stringify_tilemap(0));
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"
1495 "0000000000000000 0000000000000000\n"
1496 "0000000000000000 0000000000000000\n"
1497 "0000000000000000 0000000000000000\n"
1499 "0000000000000000 0000000000000000\n"
1500 "0000000000000022 2222220000000000\n"
1501 "0000000000000022 2222220000000000\n"
1502 "0000000000000022 2222220000000000\n"
1503 "0000000000000022 2222220000000000\n"
1504 "0000000000000000 0000000000000000\n"
1505 "0000000000000000 0000000000000000\n"
1506 "0000000000000000 0000000000000000\n"
1507 "0000000000000000 0000000000000000\n"
1508 "0000000000000000 0000000011000000\n"
1509 "0000000000000000 0000000011000000\n"
1510 "0000000000000000 0000000000000000\n"
1511 "0000000000000000 0000000000000000\n"
1512 "0000000000000000 0000000000000000\n"
1513 "0000000000000000 0000000000000000\n"
1514 "0000000000000000 0000000000000000\n";
1516 EXPECT_EQ(expected_lod_lod0, stringify_lod(0));
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"
1533 "0000000000000000 0000000000000000\n"
1534 "0000000000000000 0000000000000000\n"
1535 "0000000000000000 0000000000000000\n"
1537 "0000000000000000 0000000000000000\n"
1538 "0000000000000055 5555550000000000\n"
1539 "0000000000000055 5555550000000000\n"
1540 "0000000000000055 5555550000000000\n"
1541 "0000000000000055 5555550000000000\n"
1542 "0000000000000000 0000000000000000\n"
1543 "0000000000000000 0000000000000000\n"
1544 "0000000000000000 0000000000000000\n"
1545 "0000000000000000 0000000000000000\n"
1546 "0000000000000000 0000000011000000\n"
1547 "0000000000000000 0000000011000000\n"
1548 "0000000000000000 0000000000000000\n"
1549 "0000000000000000 0000000000000000\n"
1550 "0000000000000000 0000000000000000\n"
1551 "0000000000000000 0000000000000000\n"
1552 "0000000000000000 0000000000000000\n";
1554 EXPECT_EQ(expected_offset_lod0, stringify_offset(0));
1575 tilemaps_data.
append(tilemap);
1585 const uint lod0_ofs = 0;
1586 const uint lod1_ofs = lod0_ofs + lod0_len;
1587 const uint lod2_ofs = lod1_ofs + lod1_len;
1588 const uint lod3_ofs = lod2_ofs + lod2_len;
1589 const uint lod4_ofs = lod3_ofs + lod3_len;
1590 const uint lod5_ofs = lod4_ofs + lod4_len;
1596 tile.is_used =
true;
1597 tile.do_update =
true;
1603 tile.is_used =
false;
1604 tile.do_update =
false;
1611 tile.is_used =
true;
1612 tile.do_update =
true;
1619 tile.is_used =
true;
1620 tile.do_update =
true;
1628 tile.is_used =
false;
1629 tile.do_update =
false;
1639 tile.is_used =
false;
1640 tile.do_update =
false;
1653 pass.
push_constant(
"max_view_per_tilemap", max_view_per_tilemap);
1654 pass.
bind_ssbo(
"tilemaps_buf", tilemaps_data);
1655 pass.
bind_ssbo(
"tiles_buf", tiles_data);
1666 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
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 "xxxxxxxxxxxxxxxxx---------------"
1680 "xxxxxxxxxxxxxxxxx---------------"
1681 "xxxxxxxxxxxxxxxxx---------------"
1682 "--------------------------------"
1683 "--------------------------------"
1684 "--------------------------------"
1685 "--------------------------------"
1686 "--------------------------------"
1687 "--------------------------------"
1688 "--------------------------------"
1689 "--------------------------------"
1690 "--------------------------------"
1691 "--------------------------------"
1692 "--------------------------------"
1693 "--------------------------------"
1694 "--------------------------------"
1695 "--------------------------------"
1696 "--------------------------------"
1697 "--------------------------------";
1760 auto stringify_result = [&](
uint start,
uint len) -> std::string {
1768 auto empty_result = [&](
uint len) -> std::string {
1776 if (max_view_per_tilemap >= 3) {
1777 EXPECT_EQ(stringify_result(lod0_ofs, lod0_len), expected_lod0);
1780 EXPECT_EQ(stringify_result(lod0_ofs, lod0_len), empty_result(lod0_len));
1783 if (max_view_per_tilemap > 2) {
1784 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), expected_lod1);
1786 else if (max_view_per_tilemap == 2) {
1787 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), expected_lod1_collapsed);
1790 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), empty_result(lod1_len));
1793 if (max_view_per_tilemap > 1) {
1794 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), expected_lod2);
1796 else if (max_view_per_tilemap == 1) {
1797 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), expected_lod2_collapsed);
1800 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), empty_result(lod2_len));
1802 EXPECT_EQ(stringify_result(lod3_ofs, lod3_len), expected_lod3);
1803 EXPECT_EQ(stringify_result(lod4_ofs, lod4_len), expected_lod4);
1804 EXPECT_EQ(stringify_result(lod5_ofs, lod5_len), expected_lod5);
1844 surfel.
normal = {0.0f, 0.0f, 1.0f};
1848 surfel.
position = {1.1f, 0.1f, 0.1f};
1849 surfel_buf.
append(surfel);
1851 surfel.
position = {1.1f, 0.2f, 0.5f};
1852 surfel_buf.
append(surfel);
1854 surfel.
position = {1.1f, 0.3f, 0.3f};
1855 surfel_buf.
append(surfel);
1857 surfel.
position = {1.2f, 0.4f, 0.2f};
1858 surfel_buf.
append(surfel);
1860 surfel.
position = {1.0f, 1.0f, 0.5f};
1861 surfel_buf.
append(surfel);
1863 surfel.
position = {0.1f, 1.1f, 0.5f};
1864 surfel_buf.
append(surfel);
1866 surfel.
position = {0.2f, 1.1f, 0.5f};
1867 surfel_buf.
append(surfel);
1916 pass.
bind_ssbo(
"list_counter_buf", list_counter_buf);
1917 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1918 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1919 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1924 pass.
bind_ssbo(
"list_counter_buf", list_counter_buf);
1925 pass.
bind_ssbo(
"list_range_buf", list_range_buf);
1926 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1927 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1928 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1933 pass.
bind_ssbo(
"list_counter_buf", list_counter_buf);
1934 pass.
bind_ssbo(
"list_range_buf", list_range_buf);
1935 pass.
bind_ssbo(
"list_item_distance_buf", list_item_distance_buf);
1936 pass.
bind_ssbo(
"list_item_surfel_id_buf", list_item_surfel_id_buf);
1937 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1938 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1939 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1944 pass.
bind_ssbo(
"list_range_buf", list_range_buf);
1945 pass.
bind_ssbo(
"list_item_surfel_id_buf", list_item_surfel_id_buf);
1946 pass.
bind_ssbo(
"list_item_distance_buf", list_item_distance_buf);
1947 pass.
bind_ssbo(
"sorted_surfel_id_buf", sorted_surfel_id_buf);
1948 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1949 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1950 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1955 pass.
bind_ssbo(
"list_start_buf", list_start_buf);
1956 pass.
bind_ssbo(
"list_range_buf", list_range_buf);
1957 pass.
bind_ssbo(
"sorted_surfel_id_buf", sorted_surfel_id_buf);
1958 pass.
bind_ssbo(
"list_info_buf", list_info_buf);
1959 pass.
bind_ssbo(
"surfel_buf", surfel_buf);
1960 pass.
bind_ssbo(
"capture_info_buf", capture_info_buf);
1967 list_start_buf.
read();
1971 Vector<int> expect_link_next = {-1, +2, +3, +0, -1, -1, -1};
1972 Vector<int> expect_link_prev = {+3, -1, +1, +2, -1, -1, -1};
1976 link_next.
append(surfel.next);
1977 link_prev.
append(surfel.prev);
1981 EXPECT_EQ_SPAN<int>(expect_list_start, list_start_buf);
1982 EXPECT_EQ_SPAN<int>(expect_link_next, link_next);
1983 EXPECT_EQ_SPAN<int>(expect_link_prev, link_prev);
2016 const float eps = 3e-3f;
2017 EXPECT_NEAR_ARRAY_ND(brdf_ggx_lut.
data(), brdf_ggx_gen.data(), brdf_ggx_gen.size(), 3,
eps);
2018 EXPECT_NEAR_ARRAY_ND(btdf_ggx_lut.
data(), btdf_ggx_gen.data(), btdf_ggx_gen.size(), 1,
eps);
2019 EXPECT_NEAR_ARRAY_ND(bsdf_ggx_lut.
data(), bsdf_ggx_gen.data(), bsdf_ggx_gen.size(), 3,
eps);
2020 EXPECT_NEAR_ARRAY_ND(burley_gen.data(), burley_sss_lut.
data(), burley_sss_lut.
size(), 1,
eps);
2021 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)
void GPU_shader_free(blender::gpu::Shader *shader)
blender::gpu::Shader * GPU_shader_create_from_info_name(const char *info_name)
@ GPU_BARRIER_SHADER_STORAGE
@ GPU_BARRIER_BUFFER_UPDATE
@ GPU_BARRIER_TEXTURE_UPDATE
void GPU_memory_barrier(GPUBarrier barrier)
void GPU_storagebuf_clear(blender::gpu::StorageBuf *ssbo, uint32_t clear_value)
void GPU_texture_update_sub(blender::gpu::Texture *texture, eGPUDataFormat data_format, const void *pixels, int offset_x, int offset_y, int offset_z, int width, int height, int depth)
@ GPU_TEXTURE_USAGE_SHADER_READ
@ GPU_TEXTURE_USAGE_SHADER_WRITE
@ GPU_TEXTURE_USAGE_HOST_READ
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)
uint resource_index() const
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(blender::gpu::TextureFormat format, int2 extent, eGPUTextureUsage usage=GPU_TEXTURE_USAGE_GENERAL, const float *data=nullptr, int mip_len=1)
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)
#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()
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()