2
3
4
5
10#include "DescriptorSetManager/DescriptorSetManager.h"
11#include "Render/Renderer/RendererPass/RendererPass.h"
12#include "RenderPassStatistics\PipelineStatisticsQuerier.h"
13#include "..\..\..\assets\Shaders\src\Header\ShaderCommon.h"
14#include "Debugger/Aftermath/NsightAftermathGpuCrashTracker.h"
15#include "Debugger/Perf/NsightPerfGPUProfilerReportGenerator.h"
16#include "Debugger/Perf/NsightPerfGPUProfilerOneshotCollection.h"
17#include "Core/Container/BehaveStateList.h"
18#include "..\..\Core\Thread\ThreadModel.h"
19#include "Render/Renderer/RendererCache/RendererCache.h"
20#include "Core/Container/ThreadUnorderedMap.h"
24#include "Render/FrameInfo.h"
25#include "Render/Vulkan/VulkanRenderBackend.h"
26#include "Render/Vulkan/VulkanPipeline.h"
27#include "Render/Vulkan/VulkanUtils.h"
28#include "Render/Vulkan/VulkanBuffer.h"
29#include "Render/Vulkan/VulkanImage.h"
30#include "Render/Vulkan/VulkanDescriptor.h"
31#include "Render/Vulkan/VulkanRenderPass.h"
32#include "Render/Vulkan/VulkanDeviceGeneratedCommandsNV.h"
36#include "World/World/World.h"
37#include "World/Components/MeshComponent.h"
38#include "World/Components/TransformComponent.h"
43#include <unordered_map>
52
53
54
55
63
64
65
66
67
68
69
70
71
74 const std::string& rendererName ,
79 bool isLoadDefaultMaterial =
true
83
84
85
89
90
91
95
96
97
105
106
107
108
116
117
118
119
120
124
125
126
127
131
132
133
134
138
139
143
144
145
146
148 const std::string& materialName ,
149 const std::string& subPassName
153
154
155
156
157
159 const std::string& materialName,
160 const std::string& subPassName ,
165
166
167
168
169
170
175
176
177
178
179
184
185
186
190
191
192
193
197
198
199
204
205
211
212
213
217
218
219
223
224
225
229
230
231
232
233
235 std::shared_ptr<
Material> material ,
236 VkPipelineLayout& layout ,
241
242
246
247
248
249
253
254
255
256
263
264
265
266
267
268
269
271 const std::string& pipelineName ,
272 const std::string& materialName ,
273 VkPipelineLayout& layout ,
285
286
287
288
289
290
295
296
297
298
299
300 template<
typename T,
typename F>
304
305
306
307
308
309 template<
typename T,
typename F>
313
314
315
316
317
318
319 template<
typename T,
typename F>
323
324
325
326
327
328
329
330
331 template<
typename T,
typename F>
335
336
337
338
339
340
341 template<
typename T,
typename F>
345
346
347
348
349
350
351
352
353 template<
typename T,
typename F>
357
358
359
360
364
365
366
367
368
369 void GetDirectionalLight(
FrameInfo& frameInfo, std::array<SpicesShader::DirectionalLight, SpicesShader::DIRECTIONALLIGHT_BUFFER_MAXNUM>& dLightBuffer);
374
375
376
377
378
379 void GetPointLight(
FrameInfo& frameInfo, std::array<SpicesShader::PointLight, SpicesShader::POINTLIGHT_BUFFER_MAXNUM>& pLightBuffer);
388
389
390
396
397
398
399
401 const std::string& rendererPassName ,
406
407
411
412
413
414
415
417 const std::string& subPassName ,
422
423
424
425
430
431
432
433
434
435
438 const std::string& attachmentName ,
444
445
446
447
448
449
452 const std::string& attachmentName ,
458
459
460
461
462
463
466 const std::string& attachmentName ,
472
473
474
475
476
477
479 VkAccessFlags srcAccessMask ,
480 VkAccessFlags dstAccessMask ,
481 VkPipelineStageFlags srcStageMask ,
482 VkPipelineStageFlags dstStageMask
486
487
488
492
493
499
500
504
505
506
510
511
516
517
518
524
525
526
527
529 const std::string& subPassName ,
534
535
539
540
541
542
546
547
548
549
550
551
552
557 VkShaderStageFlags stageFlags
561
562
563
564
565
566
567
572 VkShaderStageFlags stageFlags
576
577
578
579
580
581
582
586 VkShaderStageFlags stageFlags ,
591
592
593
594
595
596
597
602 VkShaderStageFlags stageFlags ,
603 const std::vector<std::string>& textureNames
607
608
609
610
611
612
613
614
619 VkShaderStageFlags stageFlags,
620 const std::vector<std::string>& textureNames
624
625
626
627
628
629
630
631
632
636 VkShaderStageFlags stageFlags ,
637 const std::vector<std::string>& textureNames ,
643
644
645
646
647
648
649
650
651
652
656 VkShaderStageFlags stageFlags ,
657 const std::string& textureName ,
664
665
666
667
668
669
670
674 VkShaderStageFlags stageFlags ,
675 const std::vector<std::string>& textureNames
679
680
681
682
683
684
685
689 VkShaderStageFlags stageFlags ,
690 const std::vector<std::string>& inputAttachmentNames
694
695
696
697
698
699
703 VkShaderStageFlags stageFlags
707
708
709
710
711
717
718
719
723
724
728
729
733
734
735
739
740
741
746
747
748
754
755
756
757
758
766
767
771
772
773
777
778
779
783
784
785
789
790
791
792
794 const std::vector<VkVertexInputBindingDescription>& inputs
798
799
800
801
803 const std::vector<VkVertexInputAttributeDescription>& inputs
807
808
809
813
814
815
819
820
821
822
826
827
828
829
833
834
835
839
840
844
845
849
850
854
855
856
857 void BuildRayTracing(
const std::unordered_map<std::string, uint32_t>& hitGroups);
860
861
862
863
864
870
871
872
876
877
881
882
886
887
892
893
894
900
901
902
903
905 const std::string& subPassName ,
910
911
915
916
917
921
922
923
927
928
929
933
934
935
939
940
941
945
946
947
951
952
958
959
960
964
965
966
970
971
975
976
981
982
983
989
990
991
992
993
994
997 uint32_t currentFrame ,
998 uint32_t currentImage
1002
1003
1007
1008
1009
1013
1014
1015
1016 void Recording(
const std::string& caption)
const;
1019
1020
1024
1025
1026
1027
1031
1032
1033
1034 void Await(std::function<
void(
const VkCommandBuffer& cmdBuffer)> func)
const;
1037
1038
1039
1040 void Wait(std::future<VkCommandBuffer>& futureCmdBuffer)
const;
1043
1044
1045
1046 void Wait(std::vector<std::future<VkCommandBuffer>>& futureCmdBuffers)
const;
1049
1050
1051
1052
1053
1054
1056 const std::string& materialName ,
1062
1063
1064
1065
1066
1067
1069 VkPipeline pipeline ,
1075
1076
1077
1078
1079
1081 const std::string& materialName ,
1086
1087
1088
1092
1093
1097
1098
1099
1100
1101
1102
1104 const DescriptorSetInfo& infos ,
1110
1111
1112
1113
1114
1115
1116
1118 const DescriptorSetInfo& infos ,
1119 const std::string& name ,
1125
1126
1127
1128
1129
1131 const DescriptorSetInfo& infos ,
1136
1137
1138
1139
1140
1141
1143 const DescriptorSetInfo& infos ,
1144 const std::string& name ,
1149
1150
1151
1155
1156
1160
1161
1162
1166
1167
1171
1172
1173
1177
1178
1182
1183
1184
1188
1189
1195
1196
1197
1198
1199
1200 template<
typename T,
typename F>
1204
1205
1206
1207
1208 template<
typename T,
typename F>
1212
1213
1214
1215
1216
1217
1218 template<
typename T,
typename F>
1222
1223
1224
1225
1226
1227
1228 template<
typename T,
typename F>
1234
1235
1236
1237
1238
1239 template<
typename T>
1243
1244
1245
1246
1247 template<
typename T>
1251
1252
1253
1254
1255
1259
1260
1261
1262
1263
1264
1265
1275
1276
1277
1278
1279
1287
1288
1289
1290
1291
1295 const VkAccelerationStructureKHR& accel
1299
1300
1301
1305
1306
1307
1311
1312
1316
1317
1321
1322
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1340 VkAccessFlags srcAccessMask ,
1341 VkAccessFlags dstAccessMask ,
1342 VkPipelineStageFlags srcStageMask ,
1343 VkPipelineStageFlags dstStageMask ,
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1362 VkAccessFlags srcAccessMask ,
1363 VkAccessFlags dstAccessMask ,
1364 VkPipelineStageFlags srcStageMask ,
1365 VkPipelineStageFlags dstStageMask ,
1372
1373
1374
1375
1376
1377
1378
1379
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1404 VkAccessFlags srcAccessMask ,
1405 VkAccessFlags dstAccessMask ,
1406 VkPipelineStageFlags srcStageMask ,
1407 VkPipelineStageFlags dstStageMask ,
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1426 VkAccessFlags srcAccessMask ,
1427 VkAccessFlags dstAccessMask ,
1428 VkPipelineStageFlags srcStageMask ,
1429 VkPipelineStageFlags dstStageMask ,
1436
1437
1438
1439
1440
1441
1442
1443
1454
1455
1456
1457
1458
1459
1460
1470
1471
1472
1473
1474
1475
1476
1478 VkAccessFlags srcAccessMask ,
1479 VkAccessFlags dstAccessMask ,
1480 VkPipelineStageFlags srcStageMask ,
1481 VkPipelineStageFlags dstStageMask ,
1486
1487
1488
1489
1490
1491
1493 VkAccessFlags srcAccessMask ,
1494 VkAccessFlags dstAccessMask ,
1495 VkPipelineStageFlags srcStageMask ,
1496 VkPipelineStageFlags dstStageMask
1504
1505
1506
1512
1513
1514
1518
1519
1520
1521
1525
1526
1527
1528
1532
1533
1537
1538
1542
1543
1547
1548
1553
1554
1555
1556
1562
1563
1564
1565
1566
1567
1568
1571 VulkanRayTracing* rayTracing ,
1572 uint32_t currentFrame ,
1573 uint32_t currentImage
1577
1578
1582
1583
1584
1588
1589
1593
1594
1598
1599
1600
1604
1605
1606
1607
1608
1609
1611 const std::string& materialName ,
1617
1618
1619
1620
1621
1622
1624 VkPipeline pipeline ,
1630
1631
1632
1633
1634
1636 const std::string& materialName ,
1641
1642
1643
1644
1645
1646
1648 const DescriptorSetInfo& infos ,
1654
1655
1656
1657
1658
1660 const DescriptorSetInfo& infos,
1665
1666
1667
1668
1669
1670
1671
1673 const DescriptorSetInfo& infos ,
1674 const std::string& name ,
1680
1681
1682
1683
1684
1685
1687 const DescriptorSetInfo& infos ,
1688 const std::string& name ,
1693
1694
1698
1699
1700
1701
1702
1703
1705 const VkStridedDeviceAddressRegionKHR* rgenRegion,
1706 const VkStridedDeviceAddressRegionKHR* missRegion,
1707 const VkStridedDeviceAddressRegionKHR* hitRegion,
1708 const VkStridedDeviceAddressRegionKHR* callRegion
1712
1713
1714
1715
1716
1717
1719 const VkStridedDeviceAddressRegionKHR* rgenRegion,
1720 const VkStridedDeviceAddressRegionKHR* missRegion,
1721 const VkStridedDeviceAddressRegionKHR* hitRegion,
1722 const VkStridedDeviceAddressRegionKHR* callRegion
1728
1729
1734
1735
1736
1737
1743
1744
1745
1746
1747
1748
1749
1752 uint32_t currentFrame ,
1753 uint32_t currentImage ,
1754 const std::array<VkCommandBuffer, MaxFrameInFlight>& cmdBuffers
1758
1759
1763
1764
1765
1769
1770
1774
1775
1779
1780
1781
1785
1786
1787
1788
1789
1790
1792 const std::string& materialName ,
1798
1799
1800
1801
1802
1803
1805 const DescriptorSetInfo& infos ,
1811
1812
1813
1814
1815
1816
1817
1819 const DescriptorSetInfo& infos ,
1820 const std::string& name ,
1826
1827
1828
1829
1830
1831 void Dispatch(uint32_t x, uint32_t y, uint32_t z)
const;
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1848 VkAccessFlags srcAccessMask ,
1849 VkAccessFlags dstAccessMask ,
1850 VkPipelineStageFlags srcStageMask ,
1851 VkPipelineStageFlags dstStageMask ,
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1870 VkAccessFlags srcAccessMask ,
1871 VkAccessFlags dstAccessMask ,
1872 VkPipelineStageFlags srcStageMask ,
1873 VkPipelineStageFlags dstStageMask ,
1880
1881
1882
1883
1884
1885
1886
1887
1900
1901
1902
1903
1904
1905
1906
1907
1908
1909
1912 VkAccessFlags srcAccessMask ,
1913 VkAccessFlags dstAccessMask ,
1914 VkPipelineStageFlags srcStageMask ,
1915 VkPipelineStageFlags dstStageMask ,
1922
1923
1924
1925
1926
1927
1928
1929
1930
1931
1934 VkAccessFlags srcAccessMask ,
1935 VkAccessFlags dstAccessMask ,
1936 VkPipelineStageFlags srcStageMask ,
1937 VkPipelineStageFlags dstStageMask ,
1944
1945
1946
1947
1948
1949
1950
1951
1962
1963
1964
1965
1966
1967
1968
1983
1984
1990
1991
1995
1996
2000
2001
2005
2006
2010
2011
2015
2016
2020
2021
2025
2026
2030
2031
2035
2036
2040
2041
2045
2046
2050
2051
2057 template<
typename T>
2063 auto srcPtr = m_DGCData[subPassName];
2066
2067
2068 indirectPtr->SetInputStride(srcPtr->GetInputStrides());
2069 indirectPtr->SetStrides(srcPtr->GetStrides());
2070 indirectPtr->SetCommandLayout(srcPtr->GetCommandLayout());
2071 indirectPtr->SetLayoutTokens(srcPtr->GetLayoutTokens());
2074
2075
2076 m_RenderCache->PushToCaches(srcPtr);
2079
2080
2081 uint32_t nSequences = 0;
2085 std::unordered_map<std::string, uint32_t> pipelineMap;
2087 FrameInfo::Get().m_World->ViewComponent<T>(*view, [&](
const auto& e,
auto& meshComp){
2089 meshComp.GetMesh()->GetPacks().for_each([&](
const auto& k,
const std::shared_ptr<MeshPack>& v) {
2091 if (pipelineMap.find(v->GetMaterial()->GetName()) == pipelineMap.end())
2093 pipelineMap[v->GetMaterial()->GetName()] = pipelineMap.size();
2096 v->SetShaderGroupHandle(pipelineMap[v->GetMaterial()->GetName()]);
2102 indirectPtr->SetSequenceCount(nSequences);
2104 indirectPtr->GetPipelineRef().resize(pipelineMap.size(),
nullptr);
2106 for (
auto& pair : pipelineMap)
2108 indirectPtr->GetPipelineRef()[pair.second] = m_Pipelines.Find(pair.first)->GetPipeline();
2113
2114
2115 std::vector<size_t> offset;
2120 size_t totalSize = 0;
2121 size_t alignSeqIndexMask = m_Device->GetDGCProperties().minSequencesIndexBufferOffsetAlignment - 1;
2122 size_t alignMask = m_Device->GetDGCProperties().minIndirectCommandsBufferOffsetAlignment - 1;
2124 auto& inputStrides = indirectPtr->GetInputStrides();
2126 for (
int i = 0; i < inputStrides.size(); i++)
2128 offset.push_back(totalSize);
2129 totalSize += ((inputStrides[i] * nSequences + alignMask) & (~alignMask));
2136 VK_BUFFER_USAGE_TRANSFER_SRC_BIT,
2137 VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT |
2138 VK_MEMORY_PROPERTY_HOST_COHERENT_BIT
2141 auto& layoutTokens = indirectPtr->GetLayoutTokens();
2144 FrameInfo::Get().m_World->ViewComponent<T>(*view, [&](
const auto& e,
auto& meshComp){
2146 meshComp.GetMesh()->GetPacks().for_each([&](
const auto& k,
const std::shared_ptr<MeshPack>& v) {
2148 for (
int i = 0; i < layoutTokens.size(); i++)
2150 switch (layoutTokens[i].tokenType)
2152 case VK_INDIRECT_COMMANDS_TOKEN_TYPE_SHADER_GROUP_NV:
2154 VkBindShaderGroupIndirectCommandNV shader;
2155 shader.groupIndex = v->GetShaderGroupHandle() + 1;
2156 stagingBuffer.WriteToBuffer(&shader, inputStrides[i], index * inputStrides[i] + offset[i]);
2159 case VK_INDIRECT_COMMANDS_TOKEN_TYPE_VERTEX_BUFFER_NV:
2161 VkBindVertexBufferIndirectCommandNV vbo;
2162 vbo.bufferAddress = v->GetResource().positions.buffer->GetAddress();
2163 vbo.size =
sizeof(v->GetResource().positions.attributes);
2164 vbo.stride =
sizeof(glm::vec3);
2165 stagingBuffer.WriteToBuffer(&vbo, inputStrides[i], index * inputStrides[i] + offset[i]);
2168 case VK_INDIRECT_COMMANDS_TOKEN_TYPE_INDEX_BUFFER_NV:
2170 VkBindIndexBufferIndirectCommandNV ibo;
2171 ibo.bufferAddress = v->GetResource().primitivePoints.buffer->GetAddress();
2172 ibo.size =
sizeof(v->GetResource().primitivePoints.attributes);
2173 ibo.indexType = VK_INDEX_TYPE_UINT32;
2174 stagingBuffer.WriteToBuffer(&ibo, inputStrides[i], index * inputStrides[i] + offset[i]);
2177 case VK_INDIRECT_COMMANDS_TOKEN_TYPE_PUSH_CONSTANT_NV:
2179 VkDeviceAddress push;
2180 push = v->GetMeshDesc().GetBufferAddress();
2181 stagingBuffer.WriteToBuffer(&push, inputStrides[i], index * inputStrides[i] + offset[i]);
2184 case VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_INDEXED_NV:
2186 VkDrawIndexedIndirectCommand drawIndexed;
2187 drawIndexed.firstIndex = 0;
2188 drawIndexed.firstInstance = 0;
2189 drawIndexed.indexCount = v->GetResource().primitivePoints.attributes->size();
2190 drawIndexed.instanceCount = 1;
2191 drawIndexed.vertexOffset = 0;
2192 stagingBuffer.WriteToBuffer(&drawIndexed, inputStrides[i], index* inputStrides[i] + offset[i]);
2195 case VK_INDIRECT_COMMANDS_TOKEN_TYPE_DRAW_TASKS_NV:
2197 VkDrawMeshTasksIndirectCommandNV drawMesh;
2198 drawMesh = v->GetDrawCommand();
2199 stagingBuffer.WriteToBuffer(&drawMesh, inputStrides[i], index * inputStrides[i] + offset[i]);
2203 SPICES_CORE_ERROR(
"Not Supported Token Type.");
2212 stagingBuffer.Flush();
2214 inputBuffer = indirectPtr->CreateInputBuffer(totalSize);
2215 inputBuffer->CopyBuffer(stagingBuffer.Get(), inputBuffer->Get(), totalSize);
2219
2220
2224 std::vector<VkIndirectCommandsStreamNV> inputs;
2225 inputs.resize(offset.size());
2226 for (
int i = 0; i < offset.size(); i++)
2228 inputs[i].buffer = inputBuffer->Get();
2229 inputs[i].offset = offset[i];
2231 indirectPtr->SetInputStreams(inputs);
2235
2236
2240 CreateDGCMaterial(subPassName, indirectPtr.get());
2244
2245
2249 indirectPtr->CreatePreprocessBuffer();
2255 template<
typename T>
2260 auto entities = std::make_shared<std::vector<uint32_t>>();
2262 world->ViewComponent<
MeshComponent>([&](
auto entityID,
auto& tComp) {
2264 entities->push_back(
static_cast<uint32_t>(entityID));
2272 template<
typename F>
2277 return AsyncRHITask(ThreadPoolEnum::RHI, [=](VkCommandBuffer cmdBuffer) {
2279 VkCommandBufferInheritanceInfo inheritanceInfo {};
2280 inheritanceInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO;
2281 inheritanceInfo.renderPass = m_Pass->Get();
2282 inheritanceInfo.subpass = subPass;
2283 inheritanceInfo.framebuffer = m_Pass->GetFramebuffer(FrameInfo::Get().m_ImageIndex);
2284 inheritanceInfo.occlusionQueryEnable = VK_TRUE;
2288 inheritanceInfo.pipelineStatistics =
static_cast<VkQueryPipelineStatisticFlags>(PipelineStatisticEnum::ALL);
2292 VkCommandBufferBeginInfo cmdBufferBeginInfo {};
2293 cmdBufferBeginInfo.sType = VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO;
2294 cmdBufferBeginInfo.flags = VK_COMMAND_BUFFER_USAGE_RENDER_PASS_CONTINUE_BIT;
2295 cmdBufferBeginInfo.pInheritanceInfo = &inheritanceInfo;
2297 VK_CHECK(vkBeginCommandBuffer(cmdBuffer, &cmdBufferBeginInfo))
2301 VK_CHECK(vkEndCommandBuffer(cmdBuffer))
2307 template<
typename T,
typename F>
2313
2314
2315
2316 frameInfo.m_World->ViewComponent<T>([&](
auto e,
auto& tComp) {
2320
2321
2322
2323
2324
2325 func(
static_cast<
int>(e), transComp, tComp);
2331 template<
typename T,
typename F>
2337
2338
2339
2340 frameInfo.m_World->ViewComponent<T>([&](
auto e,
auto& tComp) {
2344
2345
2346
2347
2348
2349
2350 return func(
static_cast<
int>(e), transComp, tComp);
2354 template<
typename T,
typename F>
2360
2361
2362
2363 frameInfo.m_World->ViewComponent<T>(ranges, [&](
auto e,
auto& tComp) {
2364 auto& transComp = frameInfo.m_World->GetRegistry().get<TransformComponent>(e);
2367
2368
2369
2370
2371
2372
2373 func(
static_cast<
int>(e), transComp, tComp);
2379 template<
typename T,
typename F>
2385
2386
2387
2388 frameInfo.m_World->ViewComponent<T>(ranges, floor, ceil, [&](
auto e,
auto& tComp) {
2389 auto& transComp = frameInfo.m_World->GetRegistry().get<TransformComponent>(e);
2392
2393
2394
2395
2396
2397
2398 func(
static_cast<
int>(e), transComp, tComp);
2404 template<
typename T,
typename F>
2410
2411
2412
2413 frameInfo.m_World->ViewComponent<T>(ranges, [&](
auto e,
auto& tComp) {
2414 auto& transComp = frameInfo.m_World->GetRegistry().get<TransformComponent>(e);
2417
2418
2419
2420
2421
2422
2423 return func(
static_cast<
int>(e), transComp, tComp);
2427 template<
typename T,
typename F>
2433
2434
2435
2436 frameInfo.m_World->ViewComponent<T>(ranges, floor, ceil, [&](
auto e,
auto& tComp) {
2437 auto& transComp = frameInfo.m_World->GetRegistry().get<TransformComponent>(e);
2440
2441
2442
2443
2444
2445
2446 return func(
static_cast<
int>(e), transComp, tComp);
2450 template<
typename F>
2458
2459
2460 m_Pass->GetSubPasses()->for_each([&](
const std::string& name,
const std::shared_ptr<RendererSubPass>& subPass) {
2462 const auto& ptr = subPass->GetStatistics();
2464 if (!ptr)
return false;
2466 return func(name, ptr);
2470 template<
typename T,
typename F>
2476
2477
2481
2482
2483
2486 std::stringstream ss;
2487 ss << m_Renderer->m_RendererName <<
"." << m_HandledSubPass->GetName() <<
".Default";
2490
2491
2493 cmdBuffer ? cmdBuffer : m_CommandBuffer,
2494 m_Renderer->m_Pipelines.Find(ss.str())->GetPipelineLayout(),
2495 VK_SHADER_STAGE_ALL,
2502 template<
typename T,
typename F>
2508
2509
2513
2514
2515
2518 std::stringstream ss;
2519 ss << m_Renderer->m_RendererName <<
"." << m_HandledSubPass->GetName() <<
".Default";
2522
2523
2524 m_Renderer->SubmitCmdsParallel(m_CommandBuffer, m_SubPassIndex, [&](
const VkCommandBuffer& cmdBuffer) {
2527 m_Renderer->m_Pipelines[ss.str()]->GetPipelineLayout(),
2528 VK_SHADER_STAGE_ALL,
2536 template<
typename T,
typename F>
2542
2543
2547
2548
2549
2553
2554
2555 m_HandledSubPass->SetBuffer({ set, binding }, &ubo);
2558 template<
typename T,
typename F>
2564
2565
2569
2570
2571
2575
2576
2577 m_HandledSubPass->SetBuffer({ set, binding }, &ssbo);
2580 template<
typename T>
2585 std::stringstream ss;
2586 ss << m_Renderer->m_RendererName <<
"." << m_HandledSubPass->GetName() <<
".Default";
2589
2590
2592 cmdBuffer ? cmdBuffer : m_CommandBuffer,
2593 m_Renderer->m_Pipelines[ss.str()]->GetPipelineLayout(),
2594 VK_SHADER_STAGE_ALL,
2601 template<
typename T>
2606 std::stringstream ss;
2607 ss << m_Renderer->m_RendererName <<
"." << m_HandledSubPass->GetName() <<
".Default";
2610
2611
2612 m_Renderer->SubmitCmdsParallel(m_CommandBuffer, [&](
const VkCommandBuffer& cmdBuffer) {
2615 m_Renderer->m_Pipelines[ss.str()]->GetPipelineLayout(),
2616 VK_SHADER_STAGE_ALL,
2629
2630
2631 m_HandledSubPass->SetBuffer({ set, binding }, data);
2645
2646
2647 m_HandledSubPass->SetBuffer({ set, binding }, data, size, offset);
2658 const String2 m_DescriptorSetId = { m_Renderer->m_Pass->GetName(), m_HandledSubPass->GetName() };
2660 const auto& descriptorSets = DescriptorSetManager::GetByName(m_DescriptorSetId);
2662 descriptorSets.find(set)->second->UpdateDescriptorSet(binding, buffer);
2668 const VkAccelerationStructureKHR& accel
2673 const String2 m_DescriptorSetId = { m_Renderer->m_Pass->GetName(), m_HandledSubPass->GetName() };
2675 const auto& descriptorSets = DescriptorSetManager::GetByName(m_DescriptorSetId);
2677 descriptorSets.find(set)->second->UpdateDescriptorSet(binding, accel);
2680 template<
typename T>
2684 VkShaderStageFlags stageFlags ,
2685 const std::vector<std::string>& textureNames
2691
2692
2693 for (
int i = 0; i < textureNames.size(); i++)
2695 const std::shared_ptr<Texture> texture = ResourcePool<Texture>::Load<T>(textureNames[i], textureNames[i]);
2696 m_ImageInfos[set][binding].push_back(*texture->GetResource<VulkanImage>()->GetImageInfo());
2700
2701
2703 descriptorSet->AddBinding(binding, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, stageFlags, SpicesShader::BINDLESS_TEXTURE_MAXNUM);
2708 template<
typename T>
2712 VkShaderStageFlags stageFlags,
2713 const std::vector<std::string>& textureNames
2719
2720
2721 for (
int i = 0; i < textureNames.size(); i++)
2723 const std::shared_ptr<Texture> texture = ResourcePool<Texture>::Load<T>(textureNames[i], textureNames[i]);
2724 m_ImageInfos[set][binding].push_back(*texture->GetResource<VulkanImage>()->GetImageInfo());
2728
2729
2731 descriptorSet->AddBinding(binding, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, stageFlags,
static_cast<uint32_t>(textureNames.size()));
2736 template<
typename T>
2742
2743
2744 VkAttachmentDescription attachmentDescription{};
2745 attachmentDescription.format = m_Renderer->m_Device->GetSwapChainSupport().format.format;
2746 attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT;
2747 attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
2748 attachmentDescription.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
2749 attachmentDescription.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
2750 attachmentDescription.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
2751 attachmentDescription.initialLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
2752 attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_PRESENT_SRC_KHR;
2755
2756
2757
2758 func(attachmentDescription);
2761
2762
2763 VkClearValue clearValue{};
2764 clearValue.color = { 0.0f, 0.0f, 0.0f, 1.0f };
2767
2768
2769 VkPipelineColorBlendAttachmentState colorBlend{};
2770 colorBlend.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
2771 VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
2772 colorBlend.blendEnable = VK_FALSE;
2773 colorBlend.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
2774 colorBlend.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO;
2775 colorBlend.colorBlendOp = VK_BLEND_OP_ADD;
2776 colorBlend.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
2777 colorBlend.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
2778 colorBlend.alphaBlendOp = VK_BLEND_OP_ADD;
2780 const uint32_t index = m_Renderer->m_Pass->AddAttachment(
"SwapChainImage", attachmentDescription, 1, clearValue);
2783
2784
2785 VkAttachmentReference attachmentRef{};
2786 attachmentRef.attachment = index;
2787 attachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2789 m_HandledRendererSubPass->AddColorAttachmentReference(attachmentRef, colorBlend);
2794 template<
typename T>
2796 const std::string& attachmentName ,
2804
2805
2806 VkAttachmentDescription attachmentDescription{};
2807 attachmentDescription.format = m_Renderer->m_Device->GetSwapChainSupport().format.format;
2808 attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT;
2809 attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
2810 attachmentDescription.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
2811 attachmentDescription.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
2812 attachmentDescription.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
2813 attachmentDescription.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2814 attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2817
2818
2819
2820
2821 bool isEnableBlend =
false;
2822 func(isEnableBlend, attachmentDescription);
2825
2826
2827 VkClearValue clearValue{};
2828 clearValue.color = { 0.0f, 0.0f, 0.0f, 1.0f };
2831
2832
2833 VkPipelineColorBlendAttachmentState colorBlend{};
2834 colorBlend.colorWriteMask = VK_COLOR_COMPONENT_R_BIT | VK_COLOR_COMPONENT_G_BIT |
2835 VK_COLOR_COMPONENT_B_BIT | VK_COLOR_COMPONENT_A_BIT;
2838 colorBlend.blendEnable = VK_FALSE;
2839 colorBlend.srcColorBlendFactor = VK_BLEND_FACTOR_ONE;
2840 colorBlend.dstColorBlendFactor = VK_BLEND_FACTOR_ZERO;
2841 colorBlend.colorBlendOp = VK_BLEND_OP_ADD;
2842 colorBlend.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
2843 colorBlend.dstAlphaBlendFactor = VK_BLEND_FACTOR_ZERO;
2844 colorBlend.alphaBlendOp = VK_BLEND_OP_ADD;
2848 colorBlend.blendEnable = VK_TRUE;
2849 colorBlend.srcColorBlendFactor = VK_BLEND_FACTOR_SRC_ALPHA;
2850 colorBlend.dstColorBlendFactor = VK_BLEND_FACTOR_ONE_MINUS_SRC_ALPHA;
2851 colorBlend.colorBlendOp = VK_BLEND_OP_ADD;
2852 colorBlend.srcAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
2853 colorBlend.dstAlphaBlendFactor = VK_BLEND_FACTOR_ONE;
2854 colorBlend.alphaBlendOp = VK_BLEND_OP_ADD;
2858
2859
2861 Info
.name = attachmentName;
2863 Info.description = attachmentDescription;
2864 Info
.width =
m_Renderer->m_Device->GetSwapChainSupport().surfaceSize.width;
2867 VkImageView& view = m_Renderer->m_RendererResourcePool->AccessResource(Info)->imageView;
2870
2871
2872 uint32_t layers = 1;
2876 layers =
m_Renderer->m_RendererResourcePool->AccessRowResource(Info
.name)->GetLayers();
2885 uint32_t index = m_Renderer->m_Pass->AddAttachment(attachmentName, attachmentDescription, clearValue, layers, view);
2888
2889
2890 VkAttachmentReference attachmentRef{};
2891 attachmentRef.attachment = index;
2892 attachmentRef.layout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2894 m_HandledRendererSubPass->AddColorAttachmentReference(attachmentRef, colorBlend);
2899 template<
typename T>
2901 const std::string& attachmentName ,
2909
2910
2911 VkAttachmentDescription depthAttachment{};
2912 depthAttachment.format = VulkanSwapChain::FindDepthFormat(m_Renderer->m_VulkanState.m_PhysicalDevice);
2913 depthAttachment.samples = VK_SAMPLE_COUNT_1_BIT;
2914 depthAttachment.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
2915 depthAttachment.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
2916 depthAttachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
2917 depthAttachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
2918 depthAttachment.initialLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
2919 depthAttachment.finalLayout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
2922
2923
2924
2925 func(depthAttachment);
2928
2929
2930
2931 VkClearValue clearValue{};
2932 clearValue.depthStencil = { 0.0f, 0 };
2935
2936
2938 Info
.name = attachmentName;
2940 Info.description = depthAttachment;
2941 Info
.width =
m_Renderer->m_Device->GetSwapChainSupport().surfaceSize.width;
2945 const VkImageView& view = m_Renderer->m_RendererResourcePool->AccessResource(Info)->imageView;
2948
2949
2950 uint32_t layers = 1;
2954 layers =
m_Renderer->m_RendererResourcePool->AccessRowResource(Info
.name)->GetLayers();
2963 const uint32_t index = m_Renderer->m_Pass->AddAttachment(attachmentName, depthAttachment, clearValue, layers, view);
2966
2967
2968 VkAttachmentReference depthAttachmentRef{};
2969 depthAttachmentRef.attachment = index;
2970 depthAttachmentRef.layout = VK_IMAGE_LAYOUT_DEPTH_STENCIL_ATTACHMENT_OPTIMAL;
2972 m_HandledRendererSubPass->AddDepthAttachmentReference(depthAttachmentRef);
2977 template<
typename T>
2979 const std::string& attachmentName ,
2987
2988
2989 VkAttachmentDescription attachmentDescription{};
2990 attachmentDescription.format = m_Renderer->m_Device->GetSwapChainSupport().format.format;
2991 attachmentDescription.samples = VK_SAMPLE_COUNT_1_BIT;
2992 attachmentDescription.loadOp = VK_ATTACHMENT_LOAD_OP_LOAD;
2993 attachmentDescription.storeOp = VK_ATTACHMENT_STORE_OP_STORE;
2994 attachmentDescription.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE;
2995 attachmentDescription.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE;
2996 attachmentDescription.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
2997 attachmentDescription.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL;
3000
3001
3002
3003 func(attachmentDescription);
3006
3007
3008 VkClearValue clearValue{};
3009 clearValue.color = { 0.0f, 0.0f, 0.0f, 1.0f };
3012
3013
3015 Info
.name = attachmentName;
3017 Info.description = attachmentDescription;
3018 Info
.width =
m_Renderer->m_Device->GetSwapChainSupport().surfaceSize.width;
3021 const VkImageView& view = m_Renderer->m_RendererResourcePool->AccessResource(Info)->imageView;
3023 const uint32_t index = m_Renderer->m_Pass->AddAttachment(attachmentName, attachmentDescription, clearValue, 1, view);
3026
3027
3028 VkAttachmentReference attachmentRef{};
3029 attachmentRef.attachment = index;
3030 attachmentRef.layout = attachmentDescription.finalLayout;
3032 m_HandledRendererSubPass->AddInputAttachmentReference(attachmentRef);
#define EVENT_CLASS_TYPE(type)
Defines Event type.
#define EVENT_CLASS_CATEGORY(category)
Defines Event category.
static constexpr uint32_t MAX_DIRECTIONALLIGHT_NUM
static constexpr uint32_t MAX_POINTLIGHT_MUN
#define SPICES_PROFILE_ZONEN(...)
#define SPICES_PROFILE_ZONE
#define SPICES_PROFILE_VK_ZONE(cmdbuf, name)
#define SPICES_PROFILE_FRAME
#define VK_CHECK(expr)
Vulkan Check macro. Verify Vulkan API Effectiveness.
virtual ~Application()
Destructor Function.
Application()
Constructor Function.
static void Run()
Run Our World.
Application Class. Our Engine Start here.
uint32_t DescriptorSetCombineFlags
This Class manages all descriptor sets this project.
Entity Class. This class defines the specific behaves of Entity.
This Class is the basic Event Class. Inherit from it and create specific event class.
uint32_t m_PickMaterial
Identify of selected material.
FrameInfo(const FrameInfo &)=delete
Copy Constructor Function.
uint32_t m_FrameIndex
FrameIndex, varying during 0 - (MaxFrameInFlight - 1). Used almost anywhere.
FrameInfo & operator=(const FrameInfo &)=delete
Copy Assignment Operation.
virtual ~FrameInfo()=default
Destructor Function.
static FrameInfo & Get()
Get FrameInfo.
std::shared_ptr< World > m_World
The shared pointer of specific world.
scl::linked_unordered_map< int, std::string > m_PickEntityID
RendererType m_RendererType
The renderer type of current world.
FrameInfo()=default
Constructor Function.
uint32_t m_ImageIndex
ImageIndex, varying during 0 - (MaxFrameInFlight - 1). Used in swapchain index and framebuffer index.
FrameInfo Class. This class defines the FrameInfo data.
static void DrawTreeTitle(const std::string &treeName, std::function< void()> optionFunc, std::function< void()> treeFunc)
Draw a stylized tree title bar.
The ImGuiH Class. This class defines helper function for slate render.
std::shared_ptr< Console > m_Console
The shared pointer of Console.
virtual ~ImguiConsole() override=default
Destructor Function.
bool m_EnableCmdInput
The boolean of enable Cmd Input.
ImguiConsole(const std::string &panelName, FrameInfo &frameInfo, std::shared_ptr< Console > console)
Constructor Function.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
ImGuiTextFilter m_Filter
The Filter of console.
int m_Level
The information level that console show.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
static int TextEditCallbackStub(ImGuiInputTextCallbackData *data)
Input Text Call back function.
The ImguiConsole Class. This class defines how to render a Console.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
ImguiContentBrowser(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
virtual ~ImguiContentBrowser() override=default
Destructor Function.
The ImguiContentBrowser Class. This class defines how to render a Content Browser.
The ImguiCreateEntity Class. This class defines how to render a Create.
The ImguiEdit Class. This class defines how to render a edit menu.
The ImguiFile Class. This class defines how to render a file menu.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
bool OnKeyPressed(KeyPressedEvent &e)
Event Dispatcher target. Registry on Key Resized.
virtual ~ImguiGizmos() override=default
Destructor Function.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
int m_GizmoType
Gizmo Type, Transpose, rotate, scale, universal.
ImguiSlate * m_Owner
The owner, usually is a ImguiViewport class.
bool bEnableGizmo
Is Enable Gizmo.
ImguiGizmos(const std::string &panelName, FrameInfo &frameInfo, ImguiSlate *owner)
Constructor Function.
bool IsOver() const
Is mouse is over gizmo.
The ImguiGizmos Class. This class defines how to render a viewport gizmo.
The ImguiHelp Class. This class defines how to render a Help.
ImguiInfoBar(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function.
scl::linked_unordered_map< std::string, std::shared_ptr< SlateInfoBar > > m_InfoBars
InfoBar instances.
std::shared_ptr< SlateInfoBar > m_SelectedInfoBar
Selected InfoBar.
void Push(std::shared_ptr< SlateInfoBar > instance)
Add a InfoBar instance to this.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
virtual ~ImguiInfoBar() override=default
Destructor Function.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
The ImguiInfoBar Class. This class defines how to render a Operation Panel.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
std::shared_ptr< ImguiCreateEntity > m_Create
std::shared_ptr< ImguiWindow > m_Window
std::shared_ptr< ImguiEdit > m_Edit
The shared pointer of ImguiEdit.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
ImguiMainMenu(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function.
std::shared_ptr< ImguiHelp > m_Help
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
std::shared_ptr< ImguiFile > m_File
The shared pointer of ImguiFile.
virtual ~ImguiMainMenu() override=default
Destructor Function.
The ImguiMainMenu Class. This class defines how to render a main menu.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
ImguiMaterialPanel(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
virtual ~ImguiMaterialPanel() override=default
Destructor Function.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
The ImguiMaterialPanel Class. This class defines how to render a Material Property.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
virtual ~ImguiOperation() override=default
Destructor Function.
ImguiOperation(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
The ImguiOperation Class. This class defines how to render a Operation Panel.
static void DrawComponent(const std::string &name, Entity entity)
Draw Entity Component on Property Panel.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
ImguiProperty(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
virtual ~ImguiProperty() override=default
Destructor Function.
The ImguiProperty Class. This class defines how to render a Property.
bool m_IsHovered
True if Hovered.
ImVec2 & GetPanelSize()
Get Panel Size.
virtual ~ImguiSlate()=default
Destructor Function.
void Begin(float alpha=1.0f, ImGuiWindowFlags flags=0)
Begin a common slate.
void SetWindowState(bool isSlateOn)
Set Slate is render able or not.
void Begin(const std::string &panelName, float alpha=1.0f, ImGuiWindowFlags flags=0)
Begin a common slate with name.
virtual void OnUpdate(TimeStep &ts)=0
This interface is called on SlateSystem Update.
bool IsHovered() const
Get is IsHovered.
ImVec2 m_PanelPos
This slate's position in desktop.
FrameInfo & m_FrameInfo
The FrameData reference.
ImVec2 & GetPanelPos()
Get Panel Pos.
ImGuiWindowFlags m_WindowFlags
Flags of this window slate.
ImVec2 m_PanelSize
This slate's size.
virtual void QueryIsResizedThisFrame(const ImVec2 &thisFrameSize)
Query whether viewport is resized this frame.
bool IsResizedThisFrame() const
Get boolean of whether resized this frame.
virtual void OnEvent(Event &event)=0
This interface is called on global event function pointer execute.
ImguiSlate(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function. Init with Slate's name.
virtual void OnRender()=0
This interface is called on SlateRenderer Render.
void LoadSlateIcon(ImTextureID &id, const std::string &iconFile)
Load a Texture from ResourcePool.
bool m_IsResized
Boolean of whether resized this frame.
std::string m_PanelName
This slate's name.
const std::string & GetName() const
Get this panel Name.
bool IsFocused() const
Get is IsFocused.
bool m_IsFocused
True if Focus.
This Class defines the basic behaves of specific slate. When we add an new Slate, we need inherit fro...
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
virtual void OnRender() override
This interface is called On SlateRenderer Render.
virtual ~ImguiStage() override=default
Destructor Function.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
ImguiStage(const std::string &panelName, FrameInfo &frameInfo)
Constructor Function.
The ImguiStage Class. This class defines how to render a Stage.
uint32_t m_Index
This viewport index.
std::shared_ptr< ImguiViewportToolBar > m_ToolBar
The shared pointer of ImguiGizmos.
std::shared_ptr< ImguiGizmos > m_Gizmos
The shared pointer of ImguiGizmos.
bool OnWindowResizeOver(WindowResizeOverEvent &event) const
Event Dispatcher target. Registry on Windows Resized.
virtual ~ImguiViewport() override=default
Destructor Function.
std::shared_ptr< scl::behave_state_list< void > > m_ToggleStateList
Toggle behave state list.
bool m_IsToggled
True if this slate toggled this frame.
void Toggle() const
Toggle viewport.
bool OnToggleSlate(KeyPressedEvent &event) const
Toggle focused slate.
ImguiViewport(const std::string &panelName, FrameInfo &frameInfo, uint32_t index=0)
Constructor Function.
bool OnSlateResize(SlateResizeEvent &event) const
Event Dispatcher target. Registry on Slate(Viewport) Resized.
virtual void QueryIsResizedThisFrame(const ImVec2 &thisFrameSize) override
Query whether viewport is resized this frame. Clamp min m_panelsize value to 1 here,...
virtual void OnRender() override
This interface is called On SlateRenderer Render.
std::shared_ptr< ImguiFloatingInfo > m_FloatingInfo
The shared pointer of ImguiFloatingInfo.
std::pair< uint32_t, uint32_t > GetMousePosInViewport() const
Get Mouse Position Relative Viewport(Might be negative value).
std::shared_ptr< ImguiGizmos > GetGizmo()
Get Gizmo Shared Pointer.
virtual void OnUpdate(TimeStep &ts) override
This interface is called On SlateSystem Update.
std::shared_ptr< SlateImage > m_ViewportContext
SlateImage of SceneColor.
virtual void OnEvent(Event &event) override
This interface is called On Global Event Function Pointer is called.
The ImguiViewport Class. This class defines how to render a viewport.
The ImguiWindow Class. This class defines how to render a window menu.
This Class is inherited from KeyEvent Class.
static void Init()
Init Log.
static void ShutDown()
Shutdown Log.
Material Class. This class contains a branch of parameter and shader, also descriptor.
virtual std::string ToString() const override
Serialize this Event Class to string.
MeshAddedWorldEvent()=default
Constructor Function.
virtual ~MeshAddedWorldEvent() override=default
Destructor Function.
This Class is inherited from Event Class.
MeshComponent Class. This class defines the specific behaves of MeshComponent.
NativeScriptSystem Class. This class defines the specific behaves of NativeScriptSystem.
Basic interface of Queries.
RenderFrontend(const RenderFrontend &)=delete
RenderFrontend & operator=(const RenderFrontend &)=delete
std::unique_ptr< VulkanRenderBackend > m_RenderBackend
void RenderFrame(TimeStep &ts, FrameInfo &frameInfo)
virtual ~RenderFrontend()=default
void BeginFrame(FrameInfo &frameInfo)
void EndFrame(FrameInfo &frameInfo)
void OnEvent(Event &event)
virtual void OnSystemInitialize() override
This interface defines the behave on specific system initialized. Called when system Pushed to System...
RenderSystem(const std::string &systemName)
Constructor Function. Init class variable. Usually call it.
virtual void OnSystemUpdate(TimeStep &ts) override
This interface defines the behave on specific system updated every frame.
virtual void OnEvent(Event &event) override
This interface defines the behave on global event function pointer is called.
virtual void OnSystemShutDown() override
This interface defines the behave on specific system shutdown. Called when system poped from SystemMa...
virtual ~RenderSystem() override
Destructor Function.
std::unique_ptr< RenderFrontend > m_RenderFrontend
The RenderFrontend shared pointer.
ResourceSystem Class. This class defines the specific behaves of RenderSystem.
Caches of Renderer data. This class treats all stored caches as garbage and actively cleans them up.
This class is a wrapper of VulkanRenderPass. Used during Renderer.
std::unordered_map< std::string, std::unique_ptr< RendererResource > > m_RendererResource
The hashmap of all RendererResource.
RendererResourcePool(const RendererResourcePool &)=delete
Copy Constructor Function.
VkDescriptorImageInfo * AccessResource(const RendererResourceCreateInfo &info=RendererResourceCreateInfo{}, uint32_t mipLevel=0)
Get Resource with specific name, create it if it have not been created.
void OnSlateResize(uint32_t width, uint32_t height) const
Event Called on Slate resize.
RendererResourcePool()=default
Constructor Function.
RendererResourcePool & operator=(const RendererResourcePool &)=delete
Copy Assignment Operation.
std::shared_ptr< VulkanImage > AccessRowResource(const std::string &name)
Get Row Resource with specific name.
virtual ~RendererResourcePool()=default
Destructor Function.
RendererResourcePool Class. This class is a pool of all framebuffer's attachment.
std::unique_ptr< Texture2D > m_Texture
The texture this class Wrapped.
RendererResourceCreateInfo m_Info
The information of this resource.
RendererResource(const RendererResourceCreateInfo &info)
Constructor Function. Init member variables.
std::unique_ptr< Texture2D > & GetTexture()
Get Texture this class wrapped.
bool IsResizeable() const
Get isResizeable variable.
void OnResized(uint32_t width, uint32_t height)
Called On SwapChain Resized. Event received from VulkanRenderBackEnd.
virtual ~RendererResource()=default
Destructor Function.
bool m_IsResizeable
True if this resource can resize.
RendererResource Class. This class is a wrapper of framebuffer attachment.
This Class Combines some data relative to sub pass. Usually as a member variable of RendererPass.
virtual void InternalBarriers(VkBuffer buffer, VkAccessFlags srcAccessMask=VK_ACCESS_SHADER_WRITE_BIT, VkAccessFlags dstAccessMask=VK_ACCESS_SHADER_READ_BIT, VkPipelineStageFlags srcStageMask=VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VkPipelineStageFlags dstStageMask=VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) override
Add a Buffer Barrier from this queue to this queue.
virtual std::shared_ptr< RendererSubPass > & GetStatisticsRendererPass() override
Get RenderPass in statistics. @reutrn Return RenderPass.
ComputeRenderBehaveBuilder(Renderer *renderer, uint32_t currentFrame, uint32_t currentImage, const std::array< VkCommandBuffer, MaxFrameInFlight > &cmdBuffers)
Constructor Function. Bind pipeline and all buffer type descriptor set.
virtual void AddBarriers(VkBuffer buffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex=VulkanRenderBackend::GetState().m_GraphicQueueFamily, uint32_t dstQueueFamilyIndex=VulkanRenderBackend::GetState().m_ComputeQueueFamily, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) override
Add a Buffer Barrier from graphic queue to this compute queue.
virtual void BindDescriptorSet(const DescriptorSetInfo &infos, const std::string &name, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_COMPUTE) override
Binding DescriptorSet with DescriptorSetInfo and name. For Binding a Material DescriptorSet.
virtual void InternalBarriers(VulkanImage *image, VkAccessFlags srcAccessMask=VK_ACCESS_SHADER_WRITE_BIT, VkAccessFlags dstAccessMask=VK_ACCESS_SHADER_READ_BIT, VkPipelineStageFlags srcStageMask=VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VkPipelineStageFlags dstStageMask=VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) override
Add a Image Barrier from this queue to this queue.
void Dispatch(uint32_t x, uint32_t y, uint32_t z) const
Dispatch Compute Shader.
virtual void ReleaseBarriers(VulkanImage *image, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex=VulkanRenderBackend::GetState().m_ComputeQueueFamily, uint32_t dstQueueFamilyIndex=VulkanRenderBackend::GetState().m_GraphicQueueFamily, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) override
Add a Image Barrier from this compute queue to graphic queue.
virtual void InternalBarriers(VkAccessFlags srcAccessMask=VK_ACCESS_SHADER_WRITE_BIT, VkAccessFlags dstAccessMask=VK_ACCESS_SHADER_READ_BIT, VkPipelineStageFlags srcStageMask=VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VkPipelineStageFlags dstStageMask=VK_PIPELINE_STAGE_COMPUTE_SHADER_BIT, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) override
Add a Memory Barrier from this queue to this queue.
virtual void BeginRenderPass() override
Begin this Renderer's RenderPass.
virtual ~ComputeRenderBehaveBuilder() override=default
Destructor Function.
virtual void BindPipeline(const std::string &materialName, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_COMPUTE) override
Bind the pipeline created by CreatePipeline(). Called on RenderBehaveBuilder instanced.
virtual void BindDescriptorSet(const DescriptorSetInfo &infos, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_COMPUTE) override
Binding DescriptorSet with DescriptorSetInfo. For Binding a Renderer DescriptorSet.
virtual void BeginNextSubPass(const std::string &subPassName) override
End a preview sub pass and stat next sub pass.
virtual void AddBarriers(VulkanImage *image, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex=VulkanRenderBackend::GetState().m_GraphicQueueFamily, uint32_t dstQueueFamilyIndex=VulkanRenderBackend::GetState().m_ComputeQueueFamily, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) override
Add a Image Barrier from graphic queue to this compute queue.
virtual void ReleaseBarriers(VkBuffer buffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex=VulkanRenderBackend::GetState().m_ComputeQueueFamily, uint32_t dstQueueFamilyIndex=VulkanRenderBackend::GetState().m_GraphicQueueFamily, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) override
Add a Buffer Barrier from this compute queue to graphic queue.
virtual void EndRenderPass() override
End this Renderer's RenderPass.
This class helps to bind pipeline and bind buffer. Specific for pure Compute Renderer....
Renderer * m_Renderer
Specific Renderer pointer. Passed while this class instanced.
DGCLayoutBuilder & AddDrawMeshTaskInput()
Add Draw Mesh Task Command to Input.
DGCLayoutBuilder & AddVertexBufferInput()
Add Binding Vertex Buffer to Input.
std::string m_SubPassName
Specific SubPass Name. Passed while this class instanced.
DGCLayoutBuilder(const std::string &subPassName, Renderer *renderer)
Constructor Function.
std::vector< VkIndirectCommandsLayoutTokenNV > m_InputInfos
Stores command inputs.
DGCLayoutBuilder & AddShaderGroupInput()
Add Binding Shader Group Command to Input.
DGCLayoutBuilder & AddIndexBufferInput()
Add Binding Index Buffer to Input.
DGCLayoutBuilder & AddDrawIndexedInput()
Add Draw Indexed Command to Input.
void Build() const
Create GDC Layout.
virtual ~DGCLayoutBuilder()=default
Destructor Function.
DGCLayoutBuilder & AddPushConstantInput()
Add Binding PushConstant Command to Input.
std::shared_ptr< VulkanDeviceGeneratedCommandsNV > m_HandledDGCData
Current SubPass DGC Data.
This Class is a helper for Building GDC Layout. Only instanced during CreateDeviceGeneratedCommandsLa...
DescriptorSetBuilder & AddAccelerationStructure(uint32_t set, uint32_t binding, VkShaderStageFlags stageFlags)
Add the Acceleration Structure set binding to descriptor set layout.
DescriptorSetBuilder & AddBindLessTexture(uint32_t set, uint32_t binding, VkShaderStageFlags stageFlags, const std::vector< std::string > &textureNames)
Init the BindLess texture set binding to descriptor set layout.
DescriptorSetBuilder & AddTexture(uint32_t set, uint32_t binding, VkShaderStageFlags stageFlags, const std::vector< std::string > &textureNames)
Add the texture set binding to descriptor set layout.
void Build(const VkAccelerationStructureKHR &accel=VK_NULL_HANDLE)
Create all buffer type descriptor set. Create pipeline layout.
std::unordered_map< uint32_t, std::unordered_map< uint32_t, std::vector< VkDescriptorImageInfo > > > m_ImageInfos
DescriptorSet Image type binging info. [set] - [binding] - [info].
String2 m_DescriptorSetId
The Descriptor Set Manager ID descriptorSet belongs to.
std::unordered_map< uint32_t, std::unordered_map< uint32_t, VkDescriptorBufferInfo > > m_BufferInfos
DescriptorSet Buffer type binging info. [set] - [binding] - [info].
virtual ~DescriptorSetBuilder()=default
Destructor Function.
DescriptorSetBuilder & AddStorageBuffer(uint32_t set, uint32_t binding, VkShaderStageFlags stageFlags, std::shared_ptr< VulkanBuffer > buffer)
Add buffer object in collection, and add it's set binding to descriptorsetlayout, and sets descriptor...
DescriptorSetBuilder & AddStorageBuffer(uint32_t set, uint32_t binding, uint64_t size, VkShaderStageFlags stageFlags)
Create local buffer object in collection, and add it's set binding to descriptorsetlayout,...
DescriptorSetBuilder & AddStorageTexture(uint32_t set, uint32_t binding, VkShaderStageFlags stageFlags, const std::vector< std::string > &textureNames, VkFormat format=VK_FORMAT_R8G8B8A8_UNORM, TextureType type=TextureType::Texture2D)
Add the storage texture set binding to descriptor set layout.
DescriptorSetBuilder & AddStorageTextureMipmaps(uint32_t set, uint32_t binding, VkShaderStageFlags stageFlags, const std::string &textureName, VkFormat format=VK_FORMAT_R8G8B8A8_UNORM, TextureType type=TextureType::Texture2D, std::function< void(RendererResourceCreateInfo &)> func=nullptr)
Add the storage texture set binding with mipmap to descriptor set layout.
DescriptorSetBuilder & AddUniformBuffer(uint32_t set, uint32_t binding, uint64_t size, VkShaderStageFlags stageFlags)
Create local buffer object in collection, and add it's set binding to descriptorsetlayout,...
DescriptorSetBuilder(const std::string &subPassName, Renderer *renderer)
Constructor Function.
std::shared_ptr< RendererSubPass > m_HandledSubPass
Handled Sub pass.
DescriptorSetBuilder & AddPushConstant(uint32_t size)
Set VkPushConstantRange by a specific push constant struct.
Renderer * m_Renderer
Specific Renderer pointer. Passed while this class instanced.
DescriptorSetBuilder & AddInput(uint32_t set, uint32_t binding, VkShaderStageFlags stageFlags, const std::vector< std::string > &inputAttachmentNames)
Add the texture set binding to descriptor set layout.
DescriptorSetBuilder & AddAttachmentTexture(uint32_t set, uint32_t binding, VkShaderStageFlags stageFlags, const std::vector< std::string > &textureNames)
Add the attachment as texture to descriptor set layout.
This Class is a helper for Building Specific Renderer DescriptorSet. Only instanced during CreateDesc...
PipelineBuilder & SetBindingDescriptions(const std::vector< VkVertexInputBindingDescription > &inputs)
Set bindingDescriptions.
PipelineBuilder & NullAttributeDescriptions()
Set attributeDescriptions to NULL.
std::shared_ptr< RendererSubPass > m_HandledSubPass
Handled Sub pass.
std::shared_ptr< Material > m_Material
Referenced Material.
PipelineBuilder & SetPipelineLayout(VkPipelineLayout &layout)
Set pipelineLayout to given value.
void Build()
Build Pipeline.
PipelineBuilder & SetDefault()
Set PipelineConfigInfo to default value.
PipelineBuilder(std::shared_ptr< RendererSubPass > subPass, std::shared_ptr< Material > material, Renderer *renderer)
Constructor Function.
Renderer * m_Renderer
Specific Renderer pointer. Passed while this class instanced.
PipelineBuilder & SetAttributeDescriptions(const std::vector< VkVertexInputAttributeDescription > &inputs)
Set attributeDescriptions.
void BuildDeviceGeneratedCommand(const std::string &pipelineName, const std::string &materialName, VulkanDeviceGeneratedCommandsNV *indirectPtr)
Build Raytracing Pipeline.
PipelineBuilder & NullBindingDescriptions()
Set bindingDescriptions to NULL.
PipelineConfigInfo m_pipelineConfig
PipelineConfigInfo for create Pipeline.
virtual ~PipelineBuilder()=default
Destructor Function.
PipelineBuilder & SetColorAttachments()
Set pAttachments to correct value.
void BuildCompute()
Build Compute Pipeline.
PipelineBuilder & SetCullMode(VkCullModeFlags cullMode)
Set cullMode to given value.
PipelineBuilder & SetSubPassIndex()
Set subpass to correct value.
void BuildRayTracing(const std::unordered_map< std::string, uint32_t > &hitGroups)
Build Raytracing Pipeline.
void BuildMesh()
Build Mesh Pipeline.
PipelineBuilder & SetRenderPass()
Set renderPass to correct value..
This Class is a helper for Building Specific Renderer Pipeline. Only instanced during CreatePipeline(...
VulkanRayTracing * m_VulkanRayTracing
Referenced VulkanRayTracing.
virtual std::shared_ptr< RendererSubPass > & GetStatisticsRendererPass() override
Get RenderPass in statistics. @reutrn Return RenderPass.
virtual void BindDescriptorSetAsync(const DescriptorSetInfo &infos, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) override
Binding DescriptorSet with DescriptorSetInfo Async. For Binding a Renderer DescriptorSet.
void TraceRays(const VkStridedDeviceAddressRegionKHR *rgenRegion, const VkStridedDeviceAddressRegionKHR *missRegion, const VkStridedDeviceAddressRegionKHR *hitRegion, const VkStridedDeviceAddressRegionKHR *callRegion) const
Call vkCmdTraceRaysKHR here.
virtual void EndRenderPass() override
End this Renderer's RenderPass.
virtual void BindDescriptorSet(const DescriptorSetInfo &infos, const std::string &name, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) override
Binding DescriptorSet with DescriptorSetInfo and name. For Binding a Material DescriptorSet.
RayTracingRenderBehaveBuilder(Renderer *renderer, VulkanRayTracing *rayTracing, uint32_t currentFrame, uint32_t currentImage)
Constructor Function. Bind pipeline and all buffer type descriptor set.
void TraceRays() const
Call vkCmdTraceRaysKHR here.
virtual void BindPipeline(VkPipeline pipeline, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) override
Bind the pipeline created by CreatePipeline(). Called on RenderBehaveBuilder instanced.
virtual void BindPipelineAsync(const std::string &materialName, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) override
Bind the pipeline created by CreatePipeline() Async. Called on RenderBehaveBuilder instanced.
void TraceRaysAsync(const VkStridedDeviceAddressRegionKHR *rgenRegion, const VkStridedDeviceAddressRegionKHR *missRegion, const VkStridedDeviceAddressRegionKHR *hitRegion, const VkStridedDeviceAddressRegionKHR *callRegion) const
Call vkCmdTraceRaysKHR here Async.
virtual void BeginRenderPass() override
Begin this Renderer's RenderPass.
virtual void BeginNextSubPass(const std::string &subPassName) override
End a preview sub pass and stat next sub pass.
virtual void BindPipeline(const std::string &materialName, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) override
Bind the pipeline created by CreatePipeline(). Called on RenderBehaveBuilder instanced.
virtual void BindDescriptorSet(const DescriptorSetInfo &infos, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) override
Binding DescriptorSet with DescriptorSetInfo. For Binding a Renderer DescriptorSet.
virtual ~RayTracingRenderBehaveBuilder() override=default
Destructor Function.
virtual void BindDescriptorSetAsync(const DescriptorSetInfo &infos, const std::string &name, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_RAY_TRACING_KHR) override
Binding DescriptorSet with DescriptorSetInfo and name Async. For Binding a Material DescriptorSet.
This class helps to bind pipeline and bind buffer. Specific for RayTracing Renderer....
virtual void InternalBarriers(VkAccessFlags srcAccessMask=VK_ACCESS_SHADER_WRITE_BIT, VkAccessFlags dstAccessMask=VK_ACCESS_SHADER_READ_BIT, VkPipelineStageFlags srcStageMask=VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VkPipelineStageFlags dstStageMask=VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE)
Add a Memory Barrier from this queue to this queue.
std::shared_ptr< VulkanDeviceGeneratedCommandsNV > m_HandledDGCData
Current subPass DGCData.
virtual void AddBarriers(VkBuffer buffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex=VulkanRenderBackend::GetState().m_GraphicQueueFamily, uint32_t dstQueueFamilyIndex=VulkanRenderBackend::GetState().m_ComputeQueueFamily, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE)
Add a Buffer Barrier from compute queue to this graphic queue.
virtual ~RenderBehaveBuilder()=default
Destructor Function.
virtual void BindDescriptorSetAsync(const DescriptorSetInfo &infos, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_GRAPHICS)
Binding DescriptorSet with DescriptorSetInfo Async. For Binding a Renderer DescriptorSet.
uint32_t m_CurrentFrame
Current frame index. Passed while this class instanced.
virtual void ReleaseBarriers(VulkanImage *image, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex=VulkanRenderBackend::GetState().m_GraphicQueueFamily, uint32_t dstQueueFamilyIndex=VulkanRenderBackend::GetState().m_ComputeQueueFamily, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE)
Add a Image Barrier from this graphic queue to compute queue.
virtual void BindDescriptorSet(const DescriptorSetInfo &infos, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_GRAPHICS)
Binding DescriptorSet with DescriptorSetInfo. For Binding a Renderer DescriptorSet.
virtual std::shared_ptr< RendererSubPass > & GetStatisticsRendererPass()
Get RenderPass in statistics. @reutrn Return RenderPass.
void BeginNextSubPassAsync(const std::string &subPassName)
End a preview sub pass and stat next sub pass.
uint32_t GetSubPassIndex() const
Get current subPass index in renderPass.
virtual void BindPipeline(const std::string &materialName, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_GRAPHICS)
Bind the pipeline created by CreatePipeline(). Called on RenderBehaveBuilder instanced.
virtual void BindDescriptorSet(const DescriptorSetInfo &infos, const std::string &name, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_GRAPHICS)
Binding DescriptorSet with DescriptorSetInfo and name. For Binding a Material DescriptorSet.
virtual void InternalBarriers(VulkanImage *image, VkAccessFlags srcAccessMask=VK_ACCESS_SHADER_WRITE_BIT, VkAccessFlags dstAccessMask=VK_ACCESS_SHADER_READ_BIT, VkPipelineStageFlags srcStageMask=VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VkPipelineStageFlags dstStageMask=VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE)
Add a Image Barrier from this queue to this queue.
virtual void BindDescriptorSetAsync(const DescriptorSetInfo &infos, const std::string &name, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_GRAPHICS)
Binding DescriptorSet with DescriptorSetInfo and name Async. For Binding a Material DescriptorSet.
void DrawFullScreenTriangleAsync() const
Draw a Triangle full screen Async.
void UpdatePushConstantAsync(void *data) const
Update local push constant buffer Async.
std::shared_ptr< RendererSubPass > m_HandledSubPass
Handled Sub pass.
virtual void BeginNextSubPass(const std::string &subPassName)
End a preview sub pass and stat next sub pass.
virtual void InternalBarriers(VkBuffer buffer, VkAccessFlags srcAccessMask=VK_ACCESS_SHADER_WRITE_BIT, VkAccessFlags dstAccessMask=VK_ACCESS_SHADER_READ_BIT, VkPipelineStageFlags srcStageMask=VK_PIPELINE_STAGE_BOTTOM_OF_PIPE_BIT, VkPipelineStageFlags dstStageMask=VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE)
Add a Buffer Barrier from this queue to this queue.
void UpdatePushConstantAsync(F func)
Update local push constant buffer Async.
void UpdateUniformBuffer(uint32_t set, uint32_t binding, void *data) const
Update a local buffer.
void EndRecording() const
End recording all this behaveS does.
virtual void BindPipelineAsync(const std::string &materialName, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_GRAPHICS)
Bind the pipeline created by CreatePipeline() Async. Called on RenderBehaveBuilder instanced.
virtual void ReleaseBarriers(VkBuffer buffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex=VulkanRenderBackend::GetState().m_ComputeQueueFamily, uint32_t dstQueueFamilyIndex=VulkanRenderBackend::GetState().m_GraphicQueueFamily, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE)
Add a Buffer Barrier from this graphic queue to compute queue.
uint32_t m_CurrentImage
Current frame index. Passed while this class instanced.
void UpdateStorageBuffer(uint32_t set, uint32_t binding, void *data, uint64_t size=VK_WHOLE_SIZE, uint64_t offset=0) const
Update a local buffer.
void UpdatePushConstant(void *data, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) const
Update local push constant buffer.
void InternalRegionBarrier(VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) const
Add a memory Barrier.
uint32_t m_SubPassIndex
Current subPass Index.
void PreprocessDGCAsync_NV() const
Preprocess Device Generated CommandsBuffer Async.
void InternalRegionBarrierAsync(VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask) const
Add a memory Barrier.
void DrawFullScreenTriangle(const VkCommandBuffer &cmdBuffer=VK_NULL_HANDLE) const
Draw a Triangle full screen.
void SetViewPortAsync() const
DynamicState Set Viewport and Scissor Async.
void Recording(const std::string &caption) const
Recording all this behaves does.
void UpdateStorageBuffer(uint32_t set, uint32_t binding, std::shared_ptr< VulkanBuffer > buffer) const
Update a local buffer.
void UpdateAccelerationStructure(uint32_t set, uint32_t binding, const VkAccelerationStructureKHR &accel) const
Update AccelerationStructure in descriptorSet.
void RunDGC(VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) const
Run DGC Buffer.
Renderer * m_Renderer
Specific Renderer pointer. Passed while this class instanced.
virtual void BeginRenderPass()
Begin this Renderer's RenderPass.
void Await(std::function< void(const VkCommandBuffer &cmdBuffer)> func) const
Await Async Commands.
void Wait(std::future< VkCommandBuffer > &futureCmdBuffer) const
Wait for merge secondary commandBuffers.
void RunDGCAsync() const
Run DGC Buffer Async.
RenderBehaveBuilder(Renderer *renderer, uint32_t currentFrame, uint32_t currentImage)
Constructor Function. Bind pipeline and all buffer type descriptor set.
void ExecuteDGCAsync_NV() const
Execute Device Generated CommandsBuffer Async.
void UpdatePushConstant(F func, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE)
Update local push constant buffer.
void UpdateStorageBuffer(uint32_t set, uint32_t binding, F func)
Update a local buffer.
VkCommandBuffer m_CommandBuffer
Current CommandBuffer.
std::future< VkCommandBuffer > Async(std::function< void(const VkCommandBuffer &cmdBuffer)> func) const
Async Commands.
void BeginRenderPassAsync()
Begin this Renderer's RenderPass Async.
void SetViewPort(const VkCommandBuffer &cmdBuffer=VK_NULL_HANDLE) const
DynamicState Set Viewport and Scissor.
virtual void EndRenderPass()
End this Renderer's RenderPass.
void UpdateUniformBuffer(uint32_t set, uint32_t binding, F func)
Update a local buffer.
void PreprocessDGC_NV(VkCommandBuffer cmdBuffer=VK_NULL_HANDLE) const
Preprocess Device Generated CommandsBuffer.
virtual void BindPipeline(VkPipeline pipeline, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE, VkPipelineBindPoint bindPoint=VK_PIPELINE_BIND_POINT_GRAPHICS)
Bind the pipeline created by CreatePipeline(). Called on RenderBehaveBuilder instanced.
virtual void AddBarriers(VulkanImage *image, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex=VulkanRenderBackend::GetState().m_ComputeQueueFamily, uint32_t dstQueueFamilyIndex=VulkanRenderBackend::GetState().m_GraphicQueueFamily, VkCommandBuffer cmdBuffer=VK_NULL_HANDLE)
Add a Image Barrier from compute queue to this graphic queue.
void ExecuteDGC_NV(const VkCommandBuffer &cmdBuffer=VK_NULL_HANDLE) const
Execute Device Generated CommandsBuffer.
This class helps to bind pipeline and bind buffer. Only instanced during Render().
RendererPassBuilder & EndSubPass()
End recording a sub pass.
std::shared_ptr< RendererSubPass > m_HandledRendererSubPass
Handled Sub pass.
RendererPassBuilder & AddInputAttachment(const std::string &attachmentName, const TextureType &type, T func)
Add a input attachment.
virtual ~RendererPassBuilder()=default
Destructor Function.
void Build() const
Build the RendererPass.
RendererPassBuilder & AddColorAttachment(const std::string &attachmentName, const TextureType &type, T func)
Add a color attachment.
Renderer * m_Renderer
Specific Renderer pointer. Passed while this class instanced.
RendererPassBuilder & AddSubPass(const std::string &subPassName, Querier::StatisticsFlags flags=Querier::ALL)
Add a new SubPass to Renderer Pass.
RendererPassBuilder(const std::string &rendererPassName, Renderer *renderer)
Constructor Function.
std::string m_RendererPassName
RendererPass Name.
RendererPassBuilder & AddDepthAttachment(const std::string &attachmentName, const TextureType &type, T func)
Add a depth attachment.
RendererPassBuilder & AddSelfDependency(VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask)
Add subPass Self Dependency.
RendererPassBuilder & AddSwapChainAttachment(T func)
Add a swapchain image attachment.
This Class is a helper for Building RendererPass. Only instanced during CreateRendererPass().
std::string m_RendererName
Specific renderer name, Passed by instanced.
void RegistryDGCPipeline(const std::string &materialName, const std::string &subPassName, VulkanDeviceGeneratedCommandsNV *indirectPtr)
Registry dgc pipeline to Specific Renderer.
virtual void CreateRendererPass()=0
The interface is called during OnSystemInitialize(). Create specific render pass.
std::shared_ptr< VulkanDeviceGeneratedCommandsNV > FillIndirectRenderData(const std::string &subPassName, std::shared_ptr< std::vector< uint32_t > > view)
Fill in World RenderAble data to IndirectBuffer.
void IterStatistics(F &&func)
Iterator the specific RenderPass Statistics in Renderer.
std::shared_ptr< RendererPass > m_Pass
RendererPass.
std::shared_ptr< VulkanDescriptorPool > m_DescriptorPool
This variable is passed while renderer instanced.
virtual void CreateDeviceGeneratedCommandsLayout()
This interface is called during OnSystemInitialize(). Create Device Generated Commands Layout.
void RegistryMaterial(const std::string &materialName, const std::string &subPassName)
Registry material to Specific Renderer.
std::shared_ptr< RendererPass > & GetPasses()
Get RendererPass.
bool m_IsActive
Whether this renderer is active(submit commands in RendererBehaveBuilder).
virtual void OnSlateResize()
virtual void Render(TimeStep &ts, FrameInfo &frameInfo)=0
The interface is called every frame. Defines what data needs to be renderer and how to render.
virtual ~Renderer()=default
Destructor Function. We destroy pipeline layout and free descriptors that holed by this renderer here...
virtual void OnMeshAddedWorld()
std::shared_ptr< Material > GetDefaultMaterial(const std::string &subPassName) const
Get default material using sub pass Name.
std::future< VkCommandBuffer > SubmitCmdsParallel(VkCommandBuffer primaryCmdBuffer, uint32_t subPass, F &&func)
Submit a group of commands to secondary command buffer, and execute all of them.
scl::thread_unordered_map< std::string, std::shared_ptr< VulkanPipeline > > m_Pipelines
Renderer stored material pipelines.
void GetDirectionalLightMatrix(FrameInfo &frameInfo, std::array< glm::mat4, MAX_DIRECTIONALLIGHT_NUM > &directionalLight)
void CreateDefaultMaterial()
Create Specific Renderer Default Material.
VkPipelineLayout CreatePipelineLayout(const std::vector< VkDescriptorSetLayout > &rowSetLayouts, const std::shared_ptr< RendererSubPass > &subPass) const
Create Pipeline Layout with material's descriptorset and renderer's descriptor set.
void IterWorldCompWithBreak(FrameInfo &frameInfo, F func)
Iterator the specific Component in World With break.
Renderer(const std::string &rendererName, VulkanState &vulkanState, const std::shared_ptr< VulkanDescriptorPool > &DescriptorPool, const std::shared_ptr< VulkanDevice > &device, const std::shared_ptr< RendererResourcePool > &rendererResourcePool, bool isLoadDefaultMaterial=true)
Constructor Function. Init member variables.
void IterWorldCompWithRange(FrameInfo &frameInfo, const std::vector< uint32_t > &ranges, uint32_t floor, uint32_t ceil, F func)
Iterator the specific Component in World With range.
bool m_IsLoadDefaultMaterial
Whether should load a default renderer material.
std::shared_ptr< std::vector< uint32_t > > GetEntityWithComponent(World *world)
Get entities with component in world.
std::shared_ptr< RendererCache > m_RenderCache
RendererCache.
virtual void CreateDescriptorSet()=0
This interface is called during OnSystemInitialize(). Create all sub pass descriptorSet.
void IterWorldComp(FrameInfo &frameInfo, F func)
Iterator the specific Component in World.
void IterWorldCompWithRange(FrameInfo &frameInfo, const std::vector< uint32_t > &ranges, F func)
Iterator the specific Component in World With range.
std::shared_ptr< RendererResourcePool > m_RendererResourcePool
RendererResourcePool, Passed by instanced.
void IterWorldCompWithBreakWithRange(FrameInfo &frameInfo, const std::vector< uint32_t > &ranges, uint32_t floor, uint32_t ceil, F func)
Iterator the specific Component in World With break With range.
static std::shared_ptr< scl::behave_state_list< void, Renderer::RenderBehaveBuilder *, VkCommandBuffer > > m_StatisticsStateList
Statistics StateList.
virtual void OnWindowResizeOver()
This interface is called on Window resized over (registry by swapchain). If the specific renderer use...
virtual void CreateDeviceGeneratedCommandsPipeline(const std::string &pipelineName, const std::string &materialName, VkPipelineLayout &layout, std::shared_ptr< RendererSubPass > subPass, VulkanDeviceGeneratedCommandsNV *indirectPtr)
Create device generated command Pipeline.
DescriptorSetManager::DescriptorSetCombineFlags m_DescriptorSetCombine
Combination of DescriptorSet.
Renderer(const Renderer &)=delete
Copy Constructor Function.
virtual void CreatePipeline(std::shared_ptr< Material > material, VkPipelineLayout &layout, std::shared_ptr< RendererSubPass > subPass)=0
Create Specific Material Pipeline.
std::tuple< glm::mat4, glm::mat4, unsigned int, float > GetActiveCameraMatrix(FrameInfo &frameInfo)
Get The activated camera entity's view matrix and projection matrix.
virtual void OnSystemInitialize()
This interface is called on render system is registered. Initialize the specific renderer's pipeline,...
std::shared_ptr< VulkanDevice > m_Device
VulkanDevice , Passed by instanced.
void ResetRendererState()
Reset Renderer State to disActive.
void IterWorldCompWithBreakWithRange(FrameInfo &frameInfo, const std::vector< uint32_t > &ranges, F func)
Iterator the specific Component in World With break With range.
VulkanState & m_VulkanState
This variable is passed while renderer instanced.
std::unordered_map< std::string, std::shared_ptr< VulkanDeviceGeneratedCommandsNV > > m_DGCData
Data of dgc DGC Draw.
void GetDirectionalLight(FrameInfo &frameInfo, std::array< SpicesShader::DirectionalLight, SpicesShader::DIRECTIONALLIGHT_BUFFER_MAXNUM > &dLightBuffer)
Get DirectionalLightComponent's render data in World.
void GetPointLight(FrameInfo &frameInfo, std::array< SpicesShader::PointLight, SpicesShader::POINTLIGHT_BUFFER_MAXNUM > &pLightBuffer)
Get PointLightComponent's render data in World.
void CreateDGCMaterial(const std::string &subPass, VulkanDeviceGeneratedCommandsNV *indirectPtr)
Create Specific Renderer DGC Material.
Renderer & operator=(const Renderer &)=delete
Copy Assignment Operation.
Renderer Class. This class defines the basic behaves of renderer. When we add an new Renderer,...
ResourceSystem Class. Handles resource load/unload event.
SlateImage(const std::string &textureName, const std::string &materialName)
Constructor Function.
void ReBuildMaterial()
Rebuild this Material.
std::shared_ptr< Material > m_Material
This Slate image draw material.
virtual ~SlateImage()
Destructor Function.
std::string m_TextureName
Texture name.
std::shared_ptr< Material > GetMaterial()
Get this Material.
ImTextureID GetTextureID()
Get this TextureID.
void ReBuildTextureID()
Rebuild this ImTextureID.
ImTextureID m_TextureID
ImTextureID.
std::string m_MaterialName
Material name.
Slate image draw context.
This Class defines InfoBar instance.
std::shared_ptr< ImguiSlate > GetSlate(const std::string &name)
Get Slate by name.
std::unordered_map< std::string, std::shared_ptr< ImguiSlate > > m_SlatesRenderContainer
The container of all slate handle.
std::shared_ptr< ImguiViewport > GetViewPort()
virtual ~SlateRegister()=default
Destructor Function.
void OnEvent(Event &event)
This function will be called on global Event function pointer is called.
std::unordered_map< std::string, std::shared_ptr< ImguiSlate > > m_SlatesEventContainer
The container of all slate handle.
void OnRender() const
This function is called on SlateRenderer::Render.
void OnUpdate(TimeStep &ts) const
SlateRegister & operator=(const SlateRegister &)=delete
Copy Assignment Operation.
SlateRegister()=default
Constructor Function.
std::shared_ptr< T > Register(bool isPrimary, const std::string &panelName, Args &&... args)
This function registry slate instance.
SlateRegister(const SlateRegister &)=delete
Copy Constructor Function.
This Class is the manager of all slate, it keeps all slate handle.
This Class is inherited from Event Class. Called by Viewport Resize.
virtual ~SlateSystem() override
Destructor Function.
static std::shared_ptr< SlateRegister > m_SlateRegister
The slate register.
static std::shared_ptr< SlateRegister > GetRegister()
Get slate register.
virtual void OnSystemInitialize() override
This interface defines the behaves on specific system initialized. Called when system Pushed to Syste...
SlateSystem(const std::string &systemName)
Constructor Function. Init class variable. Usually call it.
virtual void OnSystemShutDown() override
This interface defines the behaves on specific system shutdown. Called when system popped from System...
virtual void OnEvent(Event &event) override
This interface defines the behaves on global event function pointer is called.
virtual void OnSystemUpdate(TimeStep &ts) override
This interface defines the behaves on specific system updated every frame.
SlateSystem Class. This class defines the specific behaves of SlateSystem.
SystemManager()
Constructor Function.
static SystemManager & Get()
Get Static SystemManager.
SystemManager & PopSystem(const std::string &systemName)
Push a system to this manager.
SystemManager Class. This class defines the behave of SystemManager.
System(const std::string &systemName)
Constructor Function. Init class variable. Usually call it.
System Class. This class defines the basic behaves of System. When we create an new System,...
Texture2DArray(const RendererResourceCreateInfo &info)
Constructor Function. Used for create render resource.
virtual ~Texture2DArray() override=default
Destructor Function.
Texture2DArray(const std::string &path)
Constructor Function. Init class variable, load date immediately. Usually call it.
Texture2DArray()
Constructor Function.
Texture2D Class. This class defines the basic behaves of Texture2DArray.
virtual ~Texture2DCube() override=default
Destructor Function.
Texture2DCube(const RendererResourceCreateInfo &info)
Constructor Function. Used for create render resource.
Texture2DCube(const std::string &path)
Constructor Function. Init class variable, load date immediately. Usually call it.
Texture2DCube()
Constructor Function.
Texture2DCube Class. This class defines the basic behaves of Texture2DCube.
Texture2D Class. This class defines the basic behaves of texture2D.
TextureLoader Class. This class only defines static function for load data from image file.
void Flush()
Refresh time in each engine loop.
const uint64_t & fs() const
Get frames count.
This Class handles our engine time step during frames. Global Unique.
Transcoder of Texture Container format and Transform format and GPU compress format.
This Class is a Wrapper of VulkanBuffer.
virtual ~VulkanCommandBuffer() override=default
Destructor Function. VkCommandBuffer is created by VkCommandPool, we do not need destroy it here manu...
VulkanCommandBuffer(VulkanState &vulkanState)
Constructor Function. Create VkCommandBuffer.
static void CustomGraphicCmd(VulkanState &vulkanState, T func)
Create a new command buffer and record custom cmd, submit to graphic queue, execute it immediately.
VulkanCommandBuffer Class. This class defines the VulkanCommandBuffer behaves. This class is just a w...
int m_GraphicThreadId
Thread Unique Graphic ThreadId.
int m_ComputeThreadId
Thread Unique Compute ThreadId.
static VulkanCommandPoolThreadWrapper & GetInst()
Get this instance.
virtual ~VulkanCommandPoolThreadWrapper()
Destructor Function.
VulkanCommandPoolThreadWrapper()
Constructor Function.
Wrapper of Instance/Delete VkCommandPool in thread.
static std::vector< VkCommandPool > m_ThreadGraphicCommandPool
Thread Graphic VkCommandPool map.
static VkCommandPool & GetThreadComputeCommandPool()
Get Thread Compute VkCommandPool by thread id.
static bool m_IsPoolActive
True if this Pool is actived.
VulkanCommandPool(VulkanState &vulkanState)
Constructor Function. Create VkCommandPool.
virtual ~VulkanCommandPool() override
Destructor Function.
static std::mutex m_ComputeCommandPoolMutex
Mutex for GraphicCommandPool.
static VkCommandPool & GetThreadGraphicCommandPool()
Get Thread Graphic VkCommandPool by thread id.
static std::mutex m_GraphicCommandPoolMutex
Mutex for GraphicCommandPool.
static std::vector< VkCommandPool > m_ThreadComputeCommandPool
Thread Compute VkCommandPool map.
VulkanCommandPool Class. This class defines the VulkanCommandPool behaves. This class is just a wrapp...
VulkanDescriptorPool Class. This class is the wrapper of VkDescriptorPool.
VulkanDeviceGeneratedCommandsNV Class. This class defines the VulkanDeviceGeneratedCommandsNV behaves...
VkSampleCountFlagBits GetMaxUsableSampleCount() const
Get device's max usable sample count.
bool IsQueueMeetDemand(const VkPhysicalDevice &device, const VkSurfaceKHR &surface)
Check all Queue we need meet;.
static SwapChainSupportDetails QuerySwapChainSupport(const VkPhysicalDevice &device, const VkSurfaceKHR &surface, GLFWwindow *window)
Query physical device's SwapChainSupport.
const SwapChainSupportDetails & GetSwapChainSupport()
Get SwapChain Utils.
static VkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV & GetDGCProperties()
Get DeviceGeneratedCommandsPropertiesNV.
QueueHelper m_QueueHelper
QueueHelper.
static VkPhysicalDeviceFeatures m_DeviceFeatures
Selected Physical Device Features.
static VkPhysicalDeviceProperties & GetDeviceProperties()
Get VkPhysicalDeviceProperties.
virtual ~VulkanDevice() override
Destructor Function.
static VkPhysicalDeviceRayTracingPipelinePropertiesKHR m_RayTracingProperties
Device RayTracing Properties.
static VkPhysicalDeviceFeatures & GetDeviceFeatures()
Get VkPhysicalDeviceFeatures.
bool IsPropertyMeetDemand(const VkPhysicalDevice &device)
Check all Property we need meet.
static VkPhysicalDeviceRayTracingPipelinePropertiesKHR & GetRTPipelineProperties()
Get RayTracingPipelineProperties.
bool IsFeatureMeetDemand(const VkPhysicalDevice &device)
Check all Feature we need meet.
void GetExtensionRequirements()
Get all physical device extension requirements our engine needed. Source 1 : user Setting.
static VkPhysicalDeviceProperties m_DeviceProperties
Selected Physical Device Properties.
static VkPhysicalDeviceDeviceGeneratedCommandsPropertiesNV m_DGCProperties
Device DGC Properties.
VulkanDevice(VulkanState &vulkanState)
Constructor Function. Create vkDevice.
bool SelectPhysicalDevice(const VkInstance &instance, const VkSurfaceKHR &surface, GLFWwindow *window)
select a suitable physical device.
SwapChainSupportDetails m_SwapChainSupportDetails
SwapChainSupportDetails.
bool IsExtensionMeetDemand(const VkPhysicalDevice &device)
Check all Extension we need meet;.
std::vector< const char * > m_ExtensionProperties
Device Extension Properties.
void RequerySwapChainSupport()
Requery device's SwapChainSupportDetails. Mainly VkExtent2D.
const QueueHelper & GetQueueHelper() const
Get QueueHelper variable.
VulkanInstance Class. This class defines the VulkanDevice behave. This class is just a wrapper of vkd...
VkImageType m_ImageType
Image Type.
void CopyImageToMemoryHost(const std::vector< VkImageToMemoryCopyEXT > &copies) const
VkFormat m_Format
The image format.
bool IsHostCopyable() const
Check if this image format can copy from host to gpu directly.
static bool IsHostCopyable(VulkanState &state, VkFormat format)
Check if this image format can copy from host to gpu directly.
uint32_t GetWidth() const
Get this Width.
VkDescriptorSet & GetDescriptorSet()
Get VkDescriptorSet.
void CreateDescriptorSet(uint32_t binding)
Create DescriptorSet with single image.
VmaAllocation m_Alloc
VMA allocation.
void CopyImageToMemoryHost(void *data) const
VkDescriptorImageInfo * GetImageInfo(VkImageLayout imageLayout=VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL, uint32_t mipLevel=0)
void CopyMemoryToImageHost(const void *data) const
Copy the Memory's data to this VkImage.
void CreateSampler()
Create a Sampler.
void CopyImageToBuffer(VkBuffer dstBuffer, const std::vector< VkBufferImageCopy > ®ions)
void CopyImageTexelToBuffer(uint32_t x, uint32_t y, void *out_rgba)
VkDescriptorSetLayout m_DescriptorSetLayout
VkDescriptorSetLayout.
void CreateImage(VulkanState &vulkanState, const std::string &name, VkImageType type, uint32_t width, uint32_t height, uint32_t layers, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkMemoryPropertyFlags properties, uint32_t mipLevels)
void DestroyDescriptorSetLayout() const
Destroy the DescriptorSetLayout if Created a DescriptorSet.
VkDeviceMemory m_ImageMemory
The image video memory.
void CopyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height, const std::vector< VkBufferImageCopy > ®ions) const
Copy the Buffer's data to this VkImage. Used to create image data (include mipmaps),...
uint32_t GetMipLevels() const
Get this MipLevels.
void CopyMemoryToImageHost(const std::vector< VkMemoryToImageCopyEXT > &copies) const
Copy the Memory's data to this VkImage. Used to create image data (include mipmaps),...
VkSampler m_TextureSampler
The image sampler.
bool m_IsCreateSet
True if Called Create DescriptorSet.
virtual ~VulkanImage() override
Destructor Function.
VulkanImage(VulkanState &vulkanState, const std::string &name, VkImageType type, uint32_t width, uint32_t height, uint32_t layers, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkImageCreateFlags flags, VkMemoryPropertyFlags properties, uint32_t mipLevels)
uint32_t m_MipLevels
Image mipmaps num.
void CreateImageView(VkFormat format, VkImageViewType viewType, VkImageAspectFlags aspectFlags, bool isCreateMipmapView=false)
Create Image View.
int m_Height
Image height.
void Barrier(VkCommandBuffer commandBuffer, VkAccessFlags srcAccessMask, VkAccessFlags dstAccessMask, VkPipelineStageFlags srcStageMask, VkPipelineStageFlags dstStageMask, uint32_t srcQueueFamilyIndex, uint32_t dstQueueFamilyIndex) const
Wrapper of Call vkCmdImageBarrier.
VkDescriptorImageInfo m_ImageInfo
VkDescriptorImageInfo.
VkDescriptorSet m_DescriptorSet
VkDescriptorSet.
void TransitionImageLayout(VkFormat format, VkImageLayout oldLayout, VkImageLayout newLayout)
void CopyBufferToImage(VkBuffer buffer, VkImage image, uint32_t width, uint32_t height) const
Copy the Buffer's data to this VkImage.
VkImageView & GetView(uint32_t mipLevel=0)
uint32_t GetLayers() const
Get this Layers.
std::vector< VkImageView > m_ImageViews
The image view.
VulkanImage(VulkanState &vulkanState)
Constructor Function. Init class variable. Init a empty VulkanImage, used in TextureLoad.
uint32_t GetHeight() const
Get this Height.
VkImage m_Image
The VkImage this Class Wrapped.
uint32_t m_Layers
Image layer(texture cube: 6).
VkFormat GetFormat() const
Get this Format.
void GenerateMipmaps(VkFormat imageFormat, int32_t texWidth, int32_t texHeight) const
Generate mipmaps with the VkImage.
void SetVulkanDebugCallbackFuncPointer()
Set Vulkan's debug message callback function pointer. Working with DEBUG mode.
virtual ~VulkanInstance() override
Destructor Function.
VkDebugUtilsMessengerCreateInfoEXT m_DebugMessengerCreateInfo
Debug Utils Messages used to execute message callback function. Also debug vkInstance create.
void CreateVulkanSurface() const
Create a Surface Object.
std::vector< const char * > m_LayerProperties
Instance Layer Properties.
VulkanInstance(VulkanState &vulkanState, const std::string &name, const std::string &engineName)
Constructor Function. Create vkInstance and vkSurface.
std::vector< const char * > m_ExtensionProperties
Instance Extension Properties.
bool CheckExtensionRequirementsSatisfied()
Iter all our extensions, check whether all satisfied or not.
VkDebugUtilsMessengerEXT m_DebugMessenger
Parameter for Create/Destroy DebugUtilsMessengerEXT.
void FillDebugMessengerCreateInfo()
Set m_DebugMessengerCreateInfo variable.
void GetExtensionRequirements()
Get all instance extension requirements our engine needed. Source 1 : glfw requirements....
bool ChecklayerRequirementsSatisfied()
Iter all our layers, check whether all satisfied or not.
void GetLayerRequirements()
Get all instance layer requirements our engine needed. Source 1 : user Setting.
VulkanInstance Class. This class defines the VulkanInstance behaves. This class is just a wrapper of ...
virtual ~VulkanMemoryAllocator() override
Destructor Function.
VulkanMemoryAllocator(VulkanState &vulkanState)
Constructor Function. Create Specific ThreadPool.
VulkanObject(VulkanState &vulkanState)
Constructor Function. Init member variables.
VulkanObject Class. This class defines the basic behaves of VulkanObject. When we create an new Vulka...
This class is a wrapper of VkPipelineLayout and VkPipeline.
void EndFrame(FrameInfo &frameInfo)
End record the frame with vulkan render backend.
void RecreateSwapChain()
Called OnSlateResize.
std::shared_ptr< VulkanMemoryAllocator > m_VmaAllocator
VulkanMemoryAllocator.
std::unique_ptr< VulkanSwapChain > m_VulkanSwapChain
VulkanSwapChain.
virtual ~VulkanRenderBackend()
Destructor Function.
std::unique_ptr< VulkanCommandPool > m_VulkanCommandPool
VulkanCommandPool.
VulkanRenderBackend()
Constructor Function.
static std::shared_ptr< VulkanDescriptorPool > GetDescriptorPool()
Get DescriptorPool in use.
static VulkanState m_VulkanState
The VulkanState in use.
std::unique_ptr< VulkanCommandBuffer > m_VulkanCommandBuffer
VulkanCommandBuffer.
bool isWindowClosed()
Determine whether window is closed.
static std::shared_ptr< VulkanDescriptorPool > m_VulkanDescriptorPool
The VulkanDescriptorPool in use.
static std::shared_ptr< RendererResourcePool > m_RendererResourcePool
The RendererResourcePool in use.
static VulkanState & GetState()
Get VulkanState in use.
std::unique_ptr< VulkanWindows > m_VulkanWindows
VulkanWindows.
bool OnMeshAddedWorldEvent(WorldEvent &event)
This function is called on world mark query tick.
void RenderFrame(TimeStep &ts, FrameInfo &frameInfo)
Draw World.
void OnEvent(Event &event)
This function is called on global event function is called.
static std::shared_ptr< RendererResourcePool > GetRendererResourcePool()
Get RendererResourcePool in use.
void BeginFrame(FrameInfo &frameInfo)
Start record a new frame with vulkan render backend.
VulkanRenderBackend & operator=(const VulkanRenderBackend &)=delete
Copy Assignment Operation.
bool OnWindowResizeOver(WindowResizeOverEvent &event)
This function is called on window is resized over.
std::shared_ptr< VulkanDevice > m_VulkanDevice
VulkanDevice.
std::unique_ptr< VulkanInstance > m_VulkanInstance
VulkanInstance.
bool OnSlateResize(SlateResizeEvent &event)
This function is called on viewport is resized.
VulkanRenderBackend(const VulkanRenderBackend &)=delete
Copy Constructor Function.
This class defines the render backend behaves of Vulkan.
virtual ~VulkanRenderPass() override
Destructor Function.
VkRenderPass m_RenderPass
The RenderPass this class mainly manage.
VulkanRenderPass(VulkanState &vulkanState, const std::string &passName, std::shared_ptr< VulkanDevice > vulkanDevice, VkRenderPassCreateInfo &createInfo, std::vector< VkImageView > &imageViews, uint32_t layers, bool isUseSwapChianImage)
Constructor Function. Create VkRenderPass and VkFramebuffer.
VkFramebuffer & GetFramebuffer(uint32_t index)
Get Framebuffer by index.
std::array< VkFramebuffer, MaxFrameInFlight > m_SwapChainFramebuffers
The FrameBuffers.
std::shared_ptr< VulkanDevice > m_VulkanDevice
The shared pointer of VulkanDevice.
VkRenderPass & Get()
Get VkRenderPass.
VulkanRenderPass Class. This class defines the VulkanRenderPass behaves. This class is just a wrapper...
VulkanSwapChain(VulkanState &vulkanState, std::shared_ptr< VulkanDevice > vulkanDevice)
Constructor Function. Create vkInstance and vkSurface.
void DestroySyncObjects() const
Destroy Sync Objects.
static VkFormat FindDepthFormat(const VkPhysicalDevice &physicalDevice)
Check whether Depth Image's Format is supported by physical device.
void Destroy() const
Destroy this.
std::shared_ptr< VulkanDevice > m_VulkanDevice
The shared pointer of VulkanDevice.
void Create() const
Create this.
static VkFormat findSupportedFormat(const VkPhysicalDevice &physicalDevice, const std::vector< VkFormat > &candidates, VkImageTiling tiling, VkFormatFeatureFlags features)
Check whether specific formats is supported by physical device.
virtual ~VulkanSwapChain() override
Destructor Function.
void CreateSyncObjects() const
Create Sync Objects.
VulkanSwapChain Class. This class defines the VulkanSwapChain behaves. This class is just a wrapper o...
static void Destroy()
Destroy all ThreadQueue.
static scl::thread_queue< std::shared_ptr< VulkanThreadQueue > > m_ComputeQueues
Compute VulkanThreadQueue.
static void CreateGraphic(VulkanState &vulkanState, VkQueue queue)
Create Graphic VulkanThreadQueue.
VkQueue m_Queue
This Thread VkQueue.
void Submit(VkCommandBuffer commandBuffer) const
Submit the CommandBuffer in this Queue.
void Wait() const
Wait for queue execute.
static void PushToGraphic(std::shared_ptr< VulkanThreadQueue > &queue)
Push queue to Graphic ThreadQueue.
static std::shared_ptr< VulkanThreadQueue > FetchGraphicQueue()
Fetch valid Graphic Queue.
static std::shared_ptr< VulkanThreadQueue > FetchComputeQueue()
Fetch valid Compute Queue.
static void CreateCompute(VulkanState &vulkanState, VkQueue queue)
Create Compute VulkanThreadQueue.
virtual ~VulkanThreadQueue() override
Destructor Function.
static void PushToCompute(std::shared_ptr< VulkanThreadQueue > &queue)
Push queue to Compute ThreadQueue.
static scl::thread_queue< std::shared_ptr< VulkanThreadQueue > > m_GraphicQueues
Graphic VulkanThreadQueue.
VulkanThreadQueue(VulkanState &vulkanState, VkQueue queue)
Constructor Function.
VulkanThreadQueue Class. This class is a wrapper of Thread VkQueue.
VulkanWindows(VulkanState &vulkanState, const WindowInfo &initInfo)
Constructor Function. Create Windows.
bool m_WindowsResized
True if viewPort is resized.
virtual ~VulkanWindows() override
Destructor Function.
void SetInternalCallBack() const
Set all needed GLFW events call back.
void SetResized(bool isResized)
Set m_WindowsResized variable.
WindowInfo m_WindowInfo
Window's info. not viewport's info.
bool IsResized() const
Get m_WindowsResized variable.
VulkanWindows Class. This class defines the windows behaves.
virtual ~WorldEvent() override=default
Destructor Function.
WorldEvent()=default
Constructor Function.
This Class is inherited from Event Class. Inherit from it and create specific KeyEvent class....
World Class. This class defines the basic behaves of World. When we create an new world,...
behave_state_node< Ret, Args... > * AddNode()
Add a empty node to this list.
virtual ~behave_state_list()=default
Destructor Function.
behave_state_list()
Constructor Function.
uint32_t m_CurrentState
current state.
void SetState(uint32_t state)
Set Current State.
std::vector< std::unique_ptr< behave_state_node< Ret, Args... > > > m_List
Linear Node list.
behave_state_node< Ret, Args... > * GetState() const
Get current state node.
void IncreateState()
Current State move forward.
void ResetState()
Current State move to start.
behave_state_list. wrapper of combing all state behaves.
std::unordered_map< std::string, std::function< Ret(Args...)> > m_Behavies
Function behaves map.
void ExecuteBehave(const std::string &name, Args... args)
Execute a behave in this state.
behave_state_node()=default
Constructor Function.
virtual ~behave_state_node()=default
Destructor Function.
void PushBehave(const std::string &name, const std::function< Ret(Args...)> &fn)
Push a behave to this state.
behave_state_list single node. defines behaves in single state.
The container combines hashmap and list together. Used in the case that we want iter a hashmap in ord...
void Push(T &&item)
Push a item to this queue.
std::mutex m_Mutex
Mutex of this queue.
thread_queue()
Constructor Function.
T Pop()
Pop a item from this queue.
void Clear()
Clear this queue.
std::atomic_int m_Count
Count of tasks.
std::condition_variable m_NotEmpty
Not empty condition.
bool IsEmpty() const
Is this queue is empty. @reutrn Returns true if empty.
virtual ~thread_queue()=default
Destructor Function.
std::queue< T > m_Queue
This wrapped queue.
Thread safe unordered_map.
TextureType
The enum of all Texture Type.
VMAMemoryPropertyFlagExtendBits
Map to VmaAllocationCreateFlagBits while use VMA for memory create.
@ VMA_MEMORY_PROPERTY_DEDICATED_MEMORY_BIT
VkMemoryPropertyFlagBits.
static constexpr int NThreadQueue
Thread Queue Count.
This struct included all infos usd to create a VkPipeline.
std::optional< uint32_t > graphicqueuefamily
The graphic queue's in used identify.
std::optional< uint32_t > presentqueuefamily
The present queue's in used identify.
std::optional< uint32_t > transferqueuefamily
The transfer queue's in used identify.
std::optional< uint32_t > computequeuefamily
The compute queue's in used identify.
bool isComplete() const
Whether all queues that we need is valid.
This struct contains all queues's identify we need.
uint32_t width
Texture' width.
virtual ~RendererResourceCreateInfo()=default
Destructor Function.
uint32_t height
Texture' height..
uint32_t mipLevel
Texture's mipmap level.
RendererResourceCreateInfo()=default
Constructor Function.
uint32_t layer
Texture's layer(1 for Texture2D, 6 for TextureCube, any for TextureArray).
VkAttachmentDescription description
Texture's description info.
bool isDepthResource
True if this resource is a DepthResource.
TextureType type
Texture's Class Type.
RendererResourceCreateInfo(const std::string &name)
Constructor Function.
float sizeScale
Texture's size scale.
VkImageUsageFlagBits usage
Image Usage.
bool isResizeable
True if this resource needs resize(sync with viewport's size).
std::string name
Texture's name.
This struct defines the data used to create a texture2d. From render pass.
VkExtent2D surfaceSize
The VkSurface Size.
std::vector< VkSurfaceFormatKHR > formats
All supported VkSurfaceFormatKHR.
VkSurfaceFormatKHR format
The selected VkSurfaceFormatKHR.
VkSurfaceCapabilitiesKHR capabilities
VkSurfaceCapabilitiesKHR.
VkPresentModeKHR presentMode
The selected VkPresentModeKHR.
VkExtent2D viewPortSize
The ViewPort Size. Init value. Reset by resize event.
std::vector< VkPresentModeKHR > presentModes
All supported VkPresentModeKHR.
SwapChain Utils. Queried from device.
uint32_t m_ComputeQueueFamily
uint32_t m_GraphicQueueFamily
This struct contains all Vulkan object in used global.
GLFWimage image
GLFWimage.
WindowIcon(const std::string &iconPath)
Constructor Function. Load the icon file immediately.
virtual ~WindowIcon()
Destructor Function.
This struct helps load the icon of window.
std::shared_ptr< WindowIcon > icon
Window's icon.
std::string name
Window's name.
int height
Window's height.
This struct defines the basic information of window.