5#include "testing/testing.h"
49 tilemaps_data.
append(tilemap);
58 tile.do_update =
true;
63 tile.do_update =
false;
73 pass.bind_ssbo(
"tilemaps_buf", tilemaps_data);
74 pass.bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
75 pass.bind_ssbo(
"tiles_buf", tiles_data);
76 pass.bind_ssbo(
"pages_cached_buf", pages_cached_data_);
77 pass.dispatch(
int3(1, 1, tilemaps_data.
size()));
108 auto tile_co_to_page = [](
int2 co) {
118 clip.clip_far_stored = 1.0;
119 clip.clip_near = 0x00000000;
120 clip.clip_far = 0x3F800000;
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;
145 tile.page = tile_co_to_page(
int2(x, y));
157 pass.bind_ssbo(
"tilemaps_buf", tilemaps_data);
158 pass.bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
159 pass.bind_ssbo(
"tiles_buf", tiles_data);
160 pass.bind_ssbo(
"pages_cached_buf", pages_cached_data);
161 pass.dispatch(
int3(1, 1, tilemaps_data.
size()));
167 tilemaps_data.
read();
186 tile_co_to_page(
int2(0, 4)));
237 tilemaps_data.
append(tilemap);
242 tilemaps_data.
append(tilemap);
251 pass.bind_ssbo(
"tilemaps_buf", tilemaps_data);
252 pass.bind_ssbo(
"tiles_buf", tiles_data);
253 pass.bind_ssbo(
"bounds_buf", &manager.
bounds_buf.previous());
254 pass.bind_ssbo(
"resource_ids_buf", past_casters_updated);
255 pass.dispatch(
int3(past_casters_updated.
size(), 1, tilemaps_data.
size()));
256 pass.bind_ssbo(
"bounds_buf", &manager.
bounds_buf.current());
257 pass.bind_ssbo(
"resource_ids_buf", curr_casters_updated);
258 pass.dispatch(
int3(curr_casters_updated.
size(), 1, tilemaps_data.
size()));
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 {
342 std::string result =
"";
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),
398 pages_cached_data[i] =
uint2(-1, -1);
400 pages_cached_data[0] =
uint2(0, tile_orphaned_cached);
401 pages_cached_data[1] =
uint2(1, tile_used_cached);
411 tile.is_used =
false;
412 tile.do_update =
true;
414 tile.is_cached =
true;
415 tile.is_allocated =
false;
418 tile.is_cached =
false;
419 tile.is_allocated =
true;
423 tile.do_update =
false;
426 tile.is_cached =
true;
427 tile.is_allocated =
false;
430 tile.is_cached =
false;
431 tile.is_allocated =
true;
434 tile.is_cached =
false;
435 tile.is_allocated =
false;
438 tile.is_used =
false;
439 tile.is_cached =
true;
440 tile.is_allocated =
false;
443 tile.is_cached =
false;
444 tile.is_allocated =
true;
452 tilemaps_data.
append(tilemap);
460 pass.bind_ssbo(
"tilemaps_buf", tilemaps_data);
461 pass.bind_ssbo(
"tiles_buf", tiles_data);
462 pass.bind_ssbo(
"pages_infos_buf", pages_infos_data);
463 pass.bind_ssbo(
"pages_free_buf", pages_free_data);
464 pass.bind_ssbo(
"pages_cached_buf", pages_cached_data);
465 pass.dispatch(
int3(1, 1, tilemaps_data.
size()));
472 pages_infos_data.
read();
511 int descriptor_offset,
517 pages_free_data[i] = page.x | (page.y << 16u);
528 pages_cached_data[i] =
uint2(-1, -1);
531 int cached_index = descriptor_offset;
533 int inserted_count = 0;
535 tile.is_cached =
true;
572 pass.bind_ssbo(
"tiles_buf", tiles_data);
573 pass.bind_ssbo(
"pages_infos_buf", pages_infos_data);
574 pass.bind_ssbo(
"pages_free_buf", pages_free_data);
575 pass.bind_ssbo(
"pages_cached_buf", pages_cached_data);
576 pass.bind_ssbo(
"clear_dispatch_buf", clear_dispatch_buf);
577 pass.bind_ssbo(
"tile_draw_buf", tile_draw_buf);
578 pass.bind_ssbo(
"statistics_buf", statistics_buf);
579 pass.dispatch(
int3(1, 1, 1));
586 pages_cached_data.
read();
587 pages_infos_data.
read();
589 std::string result =
"";
590 int expect_cached_len = 0;
604 int additional_pages =
max_ii(0, allocation_count - free_count);
605 int expected_free_count =
max_ii(free_count, allocation_count);
606 int expected_start = descriptor_offset + hole_count + additional_pages;
615 EXPECT_EQ(expect_cached_len, result_cached_len);
627 TestDefrag(0, 47,
"ccfcffccfcfciiiii",
"fffffcccccccccccc");
657 pages_free_data[i] = page.x | (page.y << 16u);
679 tile.do_update =
false;
681 tile.is_cached =
false;
682 tile.is_allocated =
false;
685 tile.is_cached =
false;
686 tile.is_allocated =
true;
694 tilemaps_data.
append(tilemap);
702 pass.bind_ssbo(
"tilemaps_buf", tilemaps_data);
703 pass.bind_ssbo(
"tiles_buf", tiles_data);
704 pass.bind_ssbo(
"pages_infos_buf", pages_infos_data);
705 pass.bind_ssbo(
"pages_free_buf", pages_free_data);
706 pass.bind_ssbo(
"pages_cached_buf", pages_cached_data);
707 pass.bind_ssbo(
"statistics_buf", statistics_buf);
708 pass.dispatch(
int3(1, 1, tilemaps_data.
size()));
715 pages_infos_data.
read();
717 bool alloc_success = page_free_count >= 1;
758 const uint lod0_ofs = 0;
759 const uint lod1_ofs = lod0_len;
760 const uint lod2_ofs = lod1_ofs + lod1_len;
761 const uint lod3_ofs = lod2_ofs + lod2_len;
762 const uint lod4_ofs = lod3_ofs + lod3_len;
763 const uint lod5_ofs = lod4_ofs + lod4_len;
772 tile.is_allocated =
true;
775 tile.do_update =
false;
779 tile.do_update =
false;
783 tile.do_update =
true;
787 tile.do_update =
true;
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;
821 tilemaps_data.
append(tilemap);
828 clip.clip_near_stored = 1.0f;
829 tilemaps_clip[0] = clip;
845 Texture tilemap_tx = {
"tilemap_tx"};
865 pass.bind_ssbo(
"tilemaps_buf", tilemaps_data);
866 pass.bind_ssbo(
"tiles_buf", tiles_data);
867 pass.bind_ssbo(
"pages_infos_buf", pages_infos_data);
868 pass.bind_ssbo(
"statistics_buf", statistics_buf);
869 pass.bind_ssbo(
"view_infos_buf", shadow_multi_view_buf);
870 pass.bind_ssbo(
"render_view_buf", render_views_buf);
871 pass.bind_ssbo(
"tilemaps_clip_buf", tilemaps_clip);
872 pass.bind_image(
"tilemaps_img", tilemap_tx);
873 pass.dispatch(
int3(1, 1, tilemaps_data.
size()));
877 pass.shader_set(sh2);
878 pass.bind_ssbo(
"statistics_buf", statistics_buf);
879 pass.bind_ssbo(
"render_view_buf", render_views_buf);
880 pass.bind_ssbo(
"tiles_buf", tiles_data);
881 pass.bind_ssbo(
"clear_dispatch_buf", clear_dispatch_buf);
882 pass.bind_ssbo(
"tile_draw_buf", tile_draw_buf);
883 pass.bind_ssbo(
"dst_coord_buf", &dst_coord_buf);
884 pass.bind_ssbo(
"src_coord_buf", &src_coord_buf);
885 pass.bind_ssbo(
"render_map_buf", &render_map_buf);
894 shadow_multi_view_buf.
read();
901 EXPECT_EQ(shadow_multi_view_buf[0].winmat,
903 EXPECT_EQ(shadow_multi_view_buf[1].winmat,
905 EXPECT_EQ(shadow_multi_view_buf[2].winmat,
907 EXPECT_EQ(shadow_multi_view_buf[3].winmat,
909 EXPECT_EQ(shadow_multi_view_buf[4].winmat,
916 std::string result =
"";
928 "12334444555555556666666666666667"
929 "22334444555555556666666666666666"
930 "33334444555555556666666666666666"
931 "33334444555555556666666666666666"
932 "44444444555555556666666666666666"
933 "44444444555555556666666666666666"
934 "44444444555555556666666666666666"
935 "44444444555555556666666666666666"
936 "55555555555555556666666666666666"
937 "55555555555555556666666666666666"
938 "55555555555555556666666666666666"
939 "55555555555555556666666666666666"
940 "55555555555555556666666666666666"
941 "55555555555555556666666666666666"
942 "55555555555555556666666666666666"
943 "55555555555555556666666696666666"
944 "88888888666666666666666666666666"
945 "88888888666666666666666666666666"
946 "88888888666666666666666666666666"
947 "88888888666666666666666666666666"
948 "88888888666666666666666666666666"
949 "88888888666666666666666666666666"
950 "88888888666666666666666666666666"
951 "88888888666666666666666666666666"
952 "66666666666666666666666666666666"
953 "66666666666666666666666666666666"
954 "66666666666666666666666666666666"
955 "66666666666666666666666666666666"
956 "66666666666666666666666666666666"
957 "66666666666666666666666666666666"
958 "66666666666666666666666666666666"
959 "66666666666666666666666666666666";
966 std::string result =
"";
967 for (
auto x :
data) {
968 result += (x == 0u) ?
'-' : ((x == 0xFFFFFFFFu) ?
'x' :
'0' + (x % 10));
975 "6-------------------------------"
976 "--------------------------------"
977 "--------------------------------"
978 "--------------------------------"
979 "--------------------------------"
980 "--------------------------------"
981 "--------------------------------"
982 "--------------------------------"
983 "--------------------------------"
984 "--------------------------------"
985 "--------------------------------"
986 "--------------------------------"
987 "--------------------------------"
988 "--------------------------------"
989 "--------------------------------"
990 "--------------------------------"
991 "--------------------------------"
992 "--------------------------------"
993 "--------------------------------"
994 "--------------------------------"
995 "--------------------------------"
996 "--------------------------------"
997 "--------------------------------"
998 "--------------------------------"
999 "--------------------------------"
1000 "--------------------------------"
1001 "--------------------------------"
1002 "--------------------------------"
1003 "--------------------------------"
1004 "--------------------------------"
1005 "--------------------------------"
1006 "--------------------------------";
1009 "5-------------------------------"
1010 "--------------------------------"
1011 "--------------------------------"
1012 "--------------------------------"
1013 "--------------------------------"
1014 "--------------------------------"
1015 "--------------------------------"
1016 "--------------------------------"
1017 "--------------------------------"
1018 "--------------------------------"
1019 "--------------------------------"
1020 "--------------------------------"
1021 "--------------------------------"
1022 "--------------------------------"
1023 "--------------------------------"
1024 "--------------------------------"
1025 "--------------------------------"
1026 "--------------------------------"
1027 "--------------------------------"
1028 "--------------------------------"
1029 "--------------------------------"
1030 "--------------------------------"
1031 "--------------------------------"
1032 "--------------------------------"
1033 "--------------------------------"
1034 "--------------------------------"
1035 "--------------------------------"
1036 "--------------------------------"
1037 "--------------------------------"
1038 "--------------------------------"
1039 "--------------------------------"
1040 "--------------------------------";
1043 "4xxx----------------------------"
1044 "xxxx----------------------------"
1045 "8xxx----------------------------"
1046 "xxxx----------------------------"
1047 "--------------------------------"
1048 "--------------------------------"
1049 "--------------------------------"
1050 "--------------------------------"
1051 "--------------------------------"
1052 "--------------------------------"
1053 "--------------------------------"
1054 "--------------------------------"
1055 "--------------------------------"
1056 "--------------------------------"
1057 "--------------------------------"
1058 "--------------------------------"
1059 "--------------------------------"
1060 "--------------------------------"
1061 "--------------------------------"
1062 "--------------------------------"
1063 "--------------------------------"
1064 "--------------------------------"
1065 "--------------------------------"
1066 "--------------------------------"
1067 "--------------------------------"
1068 "--------------------------------"
1069 "--------------------------------"
1070 "--------------------------------"
1071 "--------------------------------"
1072 "--------------------------------"
1073 "--------------------------------"
1074 "--------------------------------";
1077 "3-------------------------------"
1078 "--------------------------------"
1079 "--------------------------------"
1080 "--------------------------------"
1081 "--------------------------------"
1082 "--------------------------------"
1083 "--------------------------------"
1084 "--------------------------------"
1085 "--------------------------------"
1086 "--------------------------------"
1087 "--------------------------------"
1088 "--------------------------------"
1089 "--------------------------------"
1090 "--------------------------------"
1091 "--------------------------------"
1092 "--------------------------------"
1093 "--------------------------------"
1094 "--------------------------------"
1095 "--------------------------------"
1096 "--------------------------------"
1097 "--------------------------------"
1098 "--------------------------------"
1099 "--------------------------------"
1100 "--------------------------------"
1101 "--------------------------------"
1102 "--------------------------------"
1103 "--------------------------------"
1104 "--------------------------------"
1105 "--------------------------------"
1106 "--------------------------------"
1107 "--------------------------------"
1108 "--------------------------------";
1111 "xxxxxxx7xxxxxxxx----------------"
1112 "xxxxxxxxxxxxxxxx----------------"
1113 "xxxxxxxxxxxxxxxx----------------"
1114 "xxxxxxxxxxxxxxxx----------------"
1115 "xxxxxxxxxxxxxxxx----------------"
1116 "xxxxxxxxxxxxxxxx----------------"
1117 "xxxxxxxxxxxxxxxx----------------"
1118 "xxxxxxxxxxxxxxxx----------------"
1119 "xxxxxxxxxxxxxxxx----------------"
1120 "xxxxxxxxxxxxxxxx----------------"
1121 "xxxxxxxxxxxxxxxx----------------"
1122 "xxxxxxxxxxxxxxxx----------------"
1123 "xxxxxxxxxxxxxxxx----------------"
1124 "xxxxxxxxxxxxxxxx----------------"
1125 "xxxxxxxxxxxxxxxx----------------"
1126 "9xxxxxxxxxxxxxxx----------------"
1127 "--------------------------------"
1128 "--------------------------------"
1129 "--------------------------------"
1130 "--------------------------------"
1131 "--------------------------------"
1132 "--------------------------------"
1133 "--------------------------------"
1134 "--------------------------------"
1135 "--------------------------------"
1136 "--------------------------------"
1137 "--------------------------------"
1138 "--------------------------------"
1139 "--------------------------------"
1140 "--------------------------------"
1141 "--------------------------------"
1142 "--------------------------------";
1144 render_map_buf.
read();
1163 pages_infos_data.
read();
1166 statistics_buf.
read();
1178 Vector<uint> test_values{0x00000000u, 0x00000001u, 0x0000000Fu, 0x000000FFu, 0xABCDEF01u,
1179 0xAAAAAAAAu, 0xBBBBBBBBu, 0xCCCCCCCCu, 0xDDDDDDDDu, 0xEEEEEEEEu,
1180 0xFFFFFFFFu, 0xDEADBEEFu, 0x8BADF00Du, 0xABADCAFEu, 0x0D15EA5Eu,
1181 0xFEE1DEADu, 0xDEADC0DEu, 0xC00010FFu, 0xBBADBEEFu, 0xBAAAAAADu};
1183 for (
auto value : test_values) {
1217 tilemap_data.
fill(0);
1219 auto pixel_get = [&](
int x,
int y,
int tilemap_index) ->
uint32_t & {
1227 tile.is_valid =
true;
1237 Texture tilemap_tx = {
"tilemap_tx"};
1243 tilemap_tx,
GPU_DATA_UINT, tilemap_data.
data(), 0, 0, 0, tilemap_res.x, tilemap_res.y, 0);
1248 light.sun.clipmap_lod_min = 0;
1249 light.sun.clipmap_lod_max = 2;
1251 light.sun.clipmap_base_offset_neg =
int2(0, 1 << 0);
1253 light.sun.clipmap_base_offset_pos =
int2(1 << 1, 0);
1254 light.tilemap_index = 0;
1257 culling_light_buf[0] = light;
1273 pass.shader_set(sh);
1274 pass.bind_image(
"tilemaps_img", tilemap_tx);
1279 pass.dispatch(
int3(1));
1288 auto stringify_tilemap = [&](
int tilemap_index) -> std::string {
1289 std::string result =
"";
1309 auto stringify_lod = [&](
int tilemap_index) -> std::string {
1310 std::string result =
"";
1317 result += std::to_string(
tile.lod);
1330 auto stringify_offset = [&](
int tilemap_index) -> std::string {
1331 std::string result =
"";
1338 result += std::to_string(
tile.lod_offset.
x +
tile.lod_offset.
y);
1354 "0000000000000000 0000000000000000\n"
1355 "0000000000000000 0000000000000000\n"
1356 "0000000000000000 0000000000000000\n"
1357 "0000000000000000 0000000000000000\n"
1358 "0000000000000000 0000000000000000\n"
1359 "0000000000000000 0000000000000000\n"
1360 "0000000000000000 0000000000000000\n"
1361 "0000000000000000 0000000000000000\n"
1362 "0000000000000000 0000000000000000\n"
1363 "0000000000000000 0000000000000000\n"
1364 "0000000000000000 0000000000000000\n"
1365 "0000000000000000 0000000000000000\n"
1366 "0000000000000000 0000000000000000\n"
1367 "0000000000000000 0000000000000000\n"
1368 "0000000000000000 0000000000000000\n"
1369 "0000000000000000 0000000000000000\n"
1371 "0000000000000000 1200000000000000\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"
1386 "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"
1403 "0000000000000000 0000000000000000\n"
1404 "0000000000000000 0000000000000000\n"
1406 "0000000000000001 1220000000000000\n"
1407 "0000000000000001 1220000000000000\n"
1408 "0000000000000000 0000000000000000\n"
1409 "0000000000000000 0000000000000000\n"
1410 "0000000000000000 0000300000000000\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";
1424 "0000000000000000 0000000000000000\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"
1441 "0000000000000000 0400000000000000\n"
1442 "0000000000000011 1122220000000000\n"
1443 "0000000000000011 1122220000000000\n"
1444 "0000000000000011 1122220000000000\n"
1445 "0000000000000011 1122220000000000\n"
1446 "0000000000000000 0000000000000000\n"
1447 "0000000000000000 0000000000000000\n"
1448 "0000000000000000 0000000000000000\n"
1449 "0000000000000000 0000000000000000\n"
1450 "0000000000000000 0000000033000000\n"
1451 "0000000000000000 0000000033000000\n"
1452 "0000000000000000 0000000000000000\n"
1453 "0000000000000000 0000000000000000\n"
1454 "0000000000000000 0000000000000000\n"
1455 "0000000000000000 0000000000000000\n"
1456 "0000000000000000 0000000000000000\n";
1458 EXPECT_EQ(expected_pages_lod2, stringify_tilemap(2));
1459 EXPECT_EQ(expected_pages_lod1, stringify_tilemap(1));
1460 EXPECT_EQ(expected_pages_lod0, stringify_tilemap(0));
1463 "0000000000000000 0000000000000000\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"
1475 "0000000000000000 0000000000000000\n"
1476 "0000000000000000 0000000000000000\n"
1477 "0000000000000000 0000000000000000\n"
1478 "0000000000000000 0000000000000000\n"
1480 "0000000000000000 0000000000000000\n"
1481 "0000000000000022 2222220000000000\n"
1482 "0000000000000022 2222220000000000\n"
1483 "0000000000000022 2222220000000000\n"
1484 "0000000000000022 2222220000000000\n"
1485 "0000000000000000 0000000000000000\n"
1486 "0000000000000000 0000000000000000\n"
1487 "0000000000000000 0000000000000000\n"
1488 "0000000000000000 0000000000000000\n"
1489 "0000000000000000 0000000011000000\n"
1490 "0000000000000000 0000000011000000\n"
1491 "0000000000000000 0000000000000000\n"
1492 "0000000000000000 0000000000000000\n"
1493 "0000000000000000 0000000000000000\n"
1494 "0000000000000000 0000000000000000\n"
1495 "0000000000000000 0000000000000000\n";
1497 EXPECT_EQ(expected_lod_lod0, stringify_lod(0));
1501 "0000000000000000 0000000000000000\n"
1502 "0000000000000000 0000000000000000\n"
1503 "0000000000000000 0000000000000000\n"
1504 "0000000000000000 0000000000000000\n"
1505 "0000000000000000 0000000000000000\n"
1506 "0000000000000000 0000000000000000\n"
1507 "0000000000000000 0000000000000000\n"
1508 "0000000000000000 0000000000000000\n"
1509 "0000000000000000 0000000000000000\n"
1510 "0000000000000000 0000000000000000\n"
1511 "0000000000000000 0000000000000000\n"
1512 "0000000000000000 0000000000000000\n"
1513 "0000000000000000 0000000000000000\n"
1514 "0000000000000000 0000000000000000\n"
1515 "0000000000000000 0000000000000000\n"
1516 "0000000000000000 0000000000000000\n"
1518 "0000000000000000 0000000000000000\n"
1519 "0000000000000055 5555550000000000\n"
1520 "0000000000000055 5555550000000000\n"
1521 "0000000000000055 5555550000000000\n"
1522 "0000000000000055 5555550000000000\n"
1523 "0000000000000000 0000000000000000\n"
1524 "0000000000000000 0000000000000000\n"
1525 "0000000000000000 0000000000000000\n"
1526 "0000000000000000 0000000000000000\n"
1527 "0000000000000000 0000000011000000\n"
1528 "0000000000000000 0000000011000000\n"
1529 "0000000000000000 0000000000000000\n"
1530 "0000000000000000 0000000000000000\n"
1531 "0000000000000000 0000000000000000\n"
1532 "0000000000000000 0000000000000000\n"
1533 "0000000000000000 0000000000000000\n";
1535 EXPECT_EQ(expected_offset_lod0, stringify_offset(0));
1554 tilemaps_data.
append(tilemap);
1564 const uint lod0_ofs = 0;
1565 const uint lod1_ofs = lod0_ofs + lod0_len;
1566 const uint lod2_ofs = lod1_ofs + lod1_len;
1567 const uint lod3_ofs = lod2_ofs + lod2_len;
1568 const uint lod4_ofs = lod3_ofs + lod3_len;
1569 const uint lod5_ofs = lod4_ofs + lod4_len;
1575 tile.is_used =
true;
1576 tile.do_update =
true;
1582 tile.is_used =
false;
1583 tile.do_update =
false;
1590 tile.is_used =
true;
1591 tile.do_update =
true;
1598 tile.is_used =
true;
1599 tile.do_update =
true;
1607 tile.is_used =
false;
1608 tile.do_update =
false;
1618 tile.is_used =
false;
1619 tile.do_update =
false;
1631 pass.shader_set(sh);
1632 pass.push_constant(
"max_view_per_tilemap", max_view_per_tilemap);
1633 pass.bind_ssbo(
"tilemaps_buf", tilemaps_data);
1634 pass.bind_ssbo(
"tiles_buf", tiles_data);
1635 pass.dispatch(
int3(1, 1, tilemaps_data.
size()));
1645 "xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
1646 "xxxxxxxxxxxxxxxxx---------------"
1647 "xxxxxxxxxxxxxxxxx---------------"
1648 "xxxxxxxxxxxxxxxxx---------------"
1649 "xxxxxxxxxxxxxxxxx---------------"
1650 "xxxxxxxxxxxxxxxxx---------------"
1651 "xxxxxxxxxxxxxxxxx---------------"
1652 "xxxxxxxxxxxxxxxxx---------------"
1653 "xxxxxxxxxxxxxxxxx---------------"
1654 "xxxxxxxxxxxxxxxxx---------------"
1655 "xxxxxxxxxxxxxxxxx---------------"
1656 "xxxxxxxxxxxxxxxxx---------------"
1657 "xxxxxxxxxxxxxxxxx---------------"
1658 "xxxxxxxxxxxxxxxxx---------------"
1659 "xxxxxxxxxxxxxxxxx---------------"
1660 "xxxxxxxxxxxxxxxxx---------------"
1661 "--------------------------------"
1662 "--------------------------------"
1663 "--------------------------------"
1664 "--------------------------------"
1665 "--------------------------------"
1666 "--------------------------------"
1667 "--------------------------------"
1668 "--------------------------------"
1669 "--------------------------------"
1670 "--------------------------------"
1671 "--------------------------------"
1672 "--------------------------------"
1673 "--------------------------------"
1674 "--------------------------------"
1675 "--------------------------------"
1676 "--------------------------------";
1739 auto stringify_result = [&](
uint start,
uint len) -> std::string {
1740 std::string result =
"";
1747 auto empty_result = [&](
uint len) -> std::string {
1748 std::string result =
"";
1755 if (max_view_per_tilemap >= 3) {
1756 EXPECT_EQ(stringify_result(lod0_ofs, lod0_len), expected_lod0);
1759 EXPECT_EQ(stringify_result(lod0_ofs, lod0_len), empty_result(lod0_len));
1762 if (max_view_per_tilemap > 2) {
1763 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), expected_lod1);
1765 else if (max_view_per_tilemap == 2) {
1766 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), expected_lod1_collapsed);
1769 EXPECT_EQ(stringify_result(lod1_ofs, lod1_len), empty_result(lod1_len));
1772 if (max_view_per_tilemap > 1) {
1773 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), expected_lod2);
1775 else if (max_view_per_tilemap == 1) {
1776 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), expected_lod2_collapsed);
1779 EXPECT_EQ(stringify_result(lod2_ofs, lod2_len), empty_result(lod2_len));
1781 EXPECT_EQ(stringify_result(lod3_ofs, lod3_len), expected_lod3);
1782 EXPECT_EQ(stringify_result(lod4_ofs, lod4_len), expected_lod4);
1783 EXPECT_EQ(stringify_result(lod5_ofs, lod5_len), expected_lod5);
1819 surfel.
position = {1.1f, 0.1f, 0.1f};
1820 surfel_buf.
append(surfel);
1822 surfel.
position = {1.1f, 0.2f, 0.5f};
1823 surfel_buf.
append(surfel);
1825 surfel.
position = {1.1f, 0.3f, 0.3f};
1826 surfel_buf.
append(surfel);
1828 surfel.
position = {1.2f, 0.4f, 0.2f};
1829 surfel_buf.
append(surfel);
1831 surfel.
position = {1.0f, 1.0f, 0.5f};
1832 surfel_buf.
append(surfel);
1834 surfel.
position = {0.1f, 1.1f, 0.5f};
1835 surfel_buf.
append(surfel);
1855 View view = {
"RayProjectionView"};
1862 pass.shader_set(sh_build);
1863 pass.bind_ssbo(
"list_start_buf", list_start_buf);
1864 pass.bind_ssbo(
"surfel_buf", surfel_buf);
1866 pass.bind_ssbo(
"list_info_buf", list_info_buf);
1867 pass.dispatch(
int3(1, 1, 1));
1870 pass.shader_set(sh_sort);
1871 pass.bind_ssbo(
"list_start_buf", list_start_buf);
1872 pass.bind_ssbo(
"surfel_buf", surfel_buf);
1873 pass.bind_ssbo(
"list_info_buf", list_info_buf);
1874 pass.dispatch(
int3(1, 1, 1));
1878 manager.
submit(pass, view);
1880 list_start_buf.
read();
1884 Vector<int> expect_link_next = {-1, +2, +3, +0, -1, -1};
1885 Vector<int> expect_link_prev = {+3, -1, +1, +2, -1, -1};
1889 link_next.
append(surfel.next);
1890 link_prev.
append(surfel.prev);
1901 EXPECT_EQ_ARRAY(expect_list_start.
data(), list_start_buf.
data(), expect_list_start.
size());
1903 EXPECT_EQ_ARRAY(expect_link_next.
data(), link_next.
data(), expect_link_next.
size());
1904 EXPECT_EQ_ARRAY(expect_link_prev.
data(), link_prev.
data(), expect_link_prev.
size());
1932 const float eps = 3e-3f;
1933 EXPECT_NEAR_ARRAY_ND(brdf_ggx_lut.
data(), brdf_ggx_gen.data(), brdf_ggx_gen.size(), 3,
eps);
1934 EXPECT_NEAR_ARRAY_ND(btdf_ggx_lut.
data(), btdf_ggx_gen.data(), btdf_ggx_gen.size(), 1,
eps);
1935 EXPECT_NEAR_ARRAY_ND(bsdf_ggx_lut.
data(), bsdf_ggx_gen.data(), bsdf_ggx_gen.size(), 3,
eps);
1936 EXPECT_NEAR_ARRAY_ND(burley_gen.data(), burley_sss_lut.
data(), burley_sss_lut.
size(), 1,
eps);
1937 EXPECT_NEAR_ARRAY_ND(rand_walk_gen.data(), rand_walk_lut.
data(), rand_walk_lut.
size(), 1,
eps);
General operations, lookup, etc. for blender objects.
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)
struct GPUShader GPUShader
constexpr const T * data() const
constexpr int64_t size() const
void append(const T &value)
void fill(const T &value) const
SwapChain< ObjectBoundsBuf, 2 > bounds_buf
void submit(PassSimple &pass, View &view)
ResourceHandle 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 sync(const float4x4 &view_mat, const float4x4 &win_mat, int view_id=0)
#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
SHADOW_TILEMAP_RES tiles_buf[] statistics_buf render_view_buf[SHADOW_VIEW_MAX] GPU_R32UI
ccl_global const KernelWorkTile * tile
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]
@ LUT_GGX_BTDF_IOR_GT_ONE
@ LUT_RANDOM_WALK_SSS_PROFILE
static ShadowTileDataPacked shadow_tile_pack(ShadowTileData tile)
static ShadowSamplingTilePacked shadow_sampling_tile_pack(ShadowSamplingTile tile)
static ShadowTileData shadow_tile_unpack(ShadowTileDataPacked data)
static uint2 shadow_lod_offset_unpack(uint data)
static uint3 shadow_page_unpack(uint data)
static uint shadow_page_pack(uint3 page)
static uint shadow_lod_offset_pack(uint2 ofs)
@ SHADOW_PROJECTION_CLIPMAP
@ SHADOW_PROJECTION_CUBEFACE
static ShadowSamplingTile shadow_sampling_tile_unpack(ShadowSamplingTilePacked data)
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< uint32_t, 4 > uint4
VecBase< uint32_t, 3 > uint3
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()