Pass.cpp 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/RTTI/RTTI.h>
  9. #include <AzCore/std/string/conversions.h>
  10. #include <AtomCore/Instance/InstanceDatabase.h>
  11. #include <AtomCore/std/containers/vector_set.h>
  12. #include <Atom/RHI/FrameGraphAttachmentInterface.h>
  13. #include <Atom/RHI/FrameGraphBuilder.h>
  14. #include <Atom/RHI/RHIUtils.h>
  15. #include <Atom/RHI.Reflect/Base.h>
  16. #include <Atom/RPI.Public/Buffer/Buffer.h>
  17. #include <Atom/RPI.Public/Image/AttachmentImage.h>
  18. #include <Atom/RPI.Reflect/Image/Image.h>
  19. #include <Atom/RPI.Public/Pass/AttachmentReadback.h>
  20. #include <Atom/RPI.Public/Pass/ParentPass.h>
  21. #include <Atom/RPI.Public/Pass/Pass.h>
  22. #include <Atom/RPI.Public/Pass/PassLibrary.h>
  23. #include <Atom/RPI.Public/Pass/PassDefines.h>
  24. #include <Atom/RPI.Public/Pass/PassSystemInterface.h>
  25. #include <Atom/RPI.Public/Pass/PassUtils.h>
  26. #include <Atom/RPI.Public/Pass/Specific/ImageAttachmentPreviewPass.h>
  27. #include <Atom/RPI.Public/RenderPipeline.h>
  28. #include <Atom/RPI.Public/Image/ImageSystemInterface.h>
  29. #include <Atom/RPI.Public/Image/AttachmentImagePool.h>
  30. #include <Atom/RPI.Reflect/Image/AttachmentImageAsset.h>
  31. #include <Atom/RPI.Reflect/Pass/PassRequest.h>
  32. #include <Atom/RPI.Reflect/Pass/PassTemplate.h>
  33. #include <Atom/RPI.Reflect/Pass/PassName.h>
  34. #include <Atom/RPI.Reflect/Asset/AssetUtils.h>
  35. namespace AZ
  36. {
  37. namespace RPI
  38. {
  39. // --- Constructors ---
  40. Pass::Pass(const PassDescriptor& descriptor)
  41. : m_name(descriptor.m_passName)
  42. , m_path(descriptor.m_passName)
  43. {
  44. AZ_RPI_PASS_ASSERT((descriptor.m_passRequest == nullptr) || (descriptor.m_passTemplate != nullptr),
  45. "Pass::Pass - request is valid but template is nullptr. This is not allowed. Passing a valid passRequest also requires a valid passTemplate.");
  46. m_passData = PassUtils::GetPassDataPtr(descriptor);
  47. if (m_passData)
  48. {
  49. PassUtils::ExtractPipelineGlobalConnections(m_passData, m_pipelineGlobalConnections);
  50. m_viewTag = m_passData->m_pipelineViewTag;
  51. }
  52. m_flags.m_enabled = true;
  53. m_flags.m_timestampQueryEnabled = false;
  54. m_flags.m_pipelineStatisticsQueryEnabled = false;
  55. m_template = descriptor.m_passTemplate;
  56. if (descriptor.m_passRequest != nullptr)
  57. {
  58. // Assert m_template is the same as the one in the pass request
  59. if (PassValidation::IsEnabled())
  60. {
  61. const AZStd::shared_ptr<const PassTemplate> passTemplate = PassSystemInterface::Get()->GetPassTemplate(descriptor.m_passRequest->m_templateName);
  62. AZ_RPI_PASS_ASSERT(m_template == passTemplate, "Error: template in PassDescriptor doesn't match template from PassRequest!");
  63. }
  64. m_request = *descriptor.m_passRequest;
  65. m_flags.m_createdByPassRequest = true;
  66. m_flags.m_enabled = m_request.m_passEnabled;
  67. }
  68. PassSystemInterface::Get()->RegisterPass(this);
  69. QueueForBuildAndInitialization();
  70. // Skip reset since the pass just got created
  71. m_state = PassState::Reset;
  72. }
  73. Pass::~Pass()
  74. {
  75. AZ_RPI_BREAK_ON_TARGET_PASS;
  76. PassSystemInterface::Get()->UnregisterPass(this);
  77. }
  78. PassDescriptor Pass::GetPassDescriptor() const
  79. {
  80. PassDescriptor desc;
  81. desc.m_passName = m_name;
  82. desc.m_passTemplate = m_template ? PassSystemInterface::Get()->GetPassTemplate(m_template->m_name) : nullptr;
  83. if (m_flags.m_createdByPassRequest)
  84. {
  85. desc.m_passRequest = AZStd::make_shared<PassRequest>(m_request);
  86. }
  87. else
  88. {
  89. desc.m_passRequest.reset();
  90. }
  91. desc.m_passData = m_passData;
  92. return desc;
  93. }
  94. void Pass::SetEnabled(bool enabled)
  95. {
  96. m_flags.m_enabled = enabled;
  97. OnHierarchyChange();
  98. }
  99. // --- Error Logging ---
  100. void Pass::LogError(AZStd::string&& message)
  101. {
  102. #if AZ_RPI_ENABLE_PASS_DEBUGGING
  103. AZ::Debug::Trace::Instance().Break();
  104. #endif
  105. if (PassValidation::IsEnabled())
  106. {
  107. ++m_errors;
  108. if (m_errorMessages.size() < MessageLogLimit)
  109. {
  110. m_errorMessages.push_back(AZStd::move(message));
  111. }
  112. }
  113. }
  114. void Pass::LogWarning(AZStd::string&& message)
  115. {
  116. if (PassValidation::IsEnabled())
  117. {
  118. ++m_warnings;
  119. if (m_warningMessages.size() < MessageLogLimit)
  120. {
  121. m_warningMessages.push_back(AZStd::move(message));
  122. }
  123. }
  124. }
  125. // --- Hierarchy functions ---
  126. void Pass::OnHierarchyChange()
  127. {
  128. if (m_parent != nullptr)
  129. {
  130. // Set new tree depth and path
  131. m_flags.m_parentEnabled = m_parent->m_flags.m_enabled && (m_parent->m_flags.m_parentEnabled || m_parent->m_parent == nullptr);
  132. m_treeDepth = m_parent->m_treeDepth + 1;
  133. m_path = ConcatPassName(m_parent->m_path, m_name);
  134. m_flags.m_partOfHierarchy = m_parent->m_flags.m_partOfHierarchy;
  135. if (m_state == PassState::Orphaned)
  136. {
  137. QueueForBuildAndInitialization();
  138. }
  139. }
  140. AZ_RPI_BREAK_ON_TARGET_PASS;
  141. }
  142. void Pass::RemoveFromParent()
  143. {
  144. AZ_RPI_BREAK_ON_TARGET_PASS;
  145. AZ_RPI_PASS_ASSERT(m_parent != nullptr, "Trying to remove pass from parent but pointer to the parent pass is null.");
  146. m_parent->RemoveChild(Ptr<Pass>(this));
  147. m_queueState = PassQueueState::NoQueue;
  148. m_state = PassState::Orphaned;
  149. }
  150. void Pass::OnOrphan()
  151. {
  152. AZ_RPI_BREAK_ON_TARGET_PASS;
  153. if (m_flags.m_containsGlobalReference && m_pipeline != nullptr)
  154. {
  155. m_pipeline->RemovePipelineGlobalConnectionsFromPass(this);
  156. }
  157. m_parent = nullptr;
  158. m_flags.m_partOfHierarchy = false;
  159. m_treeDepth = 0;
  160. m_parentChildIndex = 0;
  161. m_queueState = PassQueueState::NoQueue;
  162. m_state = PassState::Orphaned;
  163. }
  164. ParentPass* Pass::AsParent()
  165. {
  166. return azrtti_cast<ParentPass*>(this);
  167. }
  168. const ParentPass* Pass::AsParent() const
  169. {
  170. return azrtti_cast<const ParentPass*>(this);
  171. }
  172. // --- Bindings ---
  173. PassAttachmentBinding& Pass::GetInputBinding(uint32_t index)
  174. {
  175. uint32_t bindingIndex = m_inputBindingIndices[index];
  176. return m_attachmentBindings[bindingIndex];
  177. }
  178. PassAttachmentBinding& Pass::GetInputOutputBinding(uint32_t index)
  179. {
  180. uint32_t bindingIndex = m_inputOutputBindingIndices[index];
  181. return m_attachmentBindings[bindingIndex];
  182. }
  183. PassAttachmentBinding& Pass::GetOutputBinding(uint32_t index)
  184. {
  185. uint32_t bindingIndex = m_outputBindingIndices[index];
  186. return m_attachmentBindings[bindingIndex];
  187. }
  188. void Pass::AddAttachmentBinding(PassAttachmentBinding attachmentBinding)
  189. {
  190. auto index = static_cast<uint8_t>(m_attachmentBindings.size());
  191. // Add the binding. This will assert if the fixed size array is full.
  192. m_attachmentBindings.push_back(attachmentBinding);
  193. // Add the index of the binding to the input, output or input/output list based on the slot type
  194. switch (attachmentBinding.m_slotType)
  195. {
  196. case PassSlotType::Input:
  197. m_inputBindingIndices.push_back(index);
  198. break;
  199. case PassSlotType::InputOutput:
  200. m_inputOutputBindingIndices.push_back(index);
  201. break;
  202. case PassSlotType::Output:
  203. m_outputBindingIndices.push_back(index);
  204. break;
  205. default:
  206. break;
  207. }
  208. }
  209. // --- Finders ---
  210. Ptr<Pass> Pass::FindAdjacentPass(const Name& passName)
  211. {
  212. // 1. Check This
  213. if (passName == PassNameThis)
  214. {
  215. return Ptr<Pass>(this);
  216. }
  217. // 2. Check Parent
  218. if (m_parent == nullptr)
  219. {
  220. return nullptr;
  221. }
  222. if (passName == PassNameParent || passName == m_parent->GetName())
  223. {
  224. return Ptr<Pass>(m_parent);
  225. }
  226. // 3. Check Siblings
  227. Ptr<Pass> foundPass = m_parent->FindChildPass(passName);
  228. // 4. Check Children
  229. if (!foundPass && AsParent())
  230. {
  231. foundPass = AsParent()->FindChildPass(passName);
  232. }
  233. // Finished search, return
  234. return foundPass;
  235. }
  236. PassAttachmentBinding* Pass::FindAttachmentBinding(const Name& slotName)
  237. {
  238. for (PassAttachmentBinding& binding : m_attachmentBindings)
  239. {
  240. if (slotName == binding.m_name)
  241. {
  242. return &binding;
  243. }
  244. }
  245. return nullptr;
  246. }
  247. const PassAttachmentBinding* Pass::FindAttachmentBinding(const Name& slotName) const
  248. {
  249. for (const PassAttachmentBinding& binding : m_attachmentBindings)
  250. {
  251. if (slotName == binding.m_name)
  252. {
  253. return &binding;
  254. }
  255. }
  256. return nullptr;
  257. }
  258. Ptr<PassAttachment> Pass::FindOwnedAttachment(const Name& attachmentName) const
  259. {
  260. for (const Ptr<PassAttachment>& attachment : m_ownedAttachments)
  261. {
  262. if (attachment->m_name == attachmentName)
  263. {
  264. return attachment;
  265. }
  266. }
  267. return nullptr;
  268. }
  269. Ptr<PassAttachment> Pass::FindAttachment(const Name& slotName) const
  270. {
  271. if (const PassAttachmentBinding* binding = FindAttachmentBinding(slotName))
  272. {
  273. return binding->GetAttachment();
  274. }
  275. return FindOwnedAttachment(slotName);
  276. }
  277. const PassAttachmentBinding* Pass::FindAdjacentBinding(const PassAttachmentRef& attachmentRef, [[maybe_unused]] const char* attachmentSourceTypeDebugName)
  278. {
  279. const PassAttachmentBinding* result = nullptr;
  280. if (attachmentRef.m_pass.IsEmpty() && attachmentRef.m_attachment.IsEmpty())
  281. {
  282. // The data isn't actually referencing anything, so this is not an error, just return null.
  283. return result;
  284. }
  285. if (attachmentRef.m_pass.IsEmpty() != attachmentRef.m_attachment.IsEmpty())
  286. {
  287. AZ_Error("Pass", false,
  288. "Invalid attachment reference (Pass [%s], Attachment [%s]). Both Pass and Attachment must be set.",
  289. attachmentRef.m_pass.GetCStr(), attachmentRef.m_attachment.GetCStr());
  290. return result;
  291. }
  292. // Find pass
  293. if (Ptr<Pass> pass = FindAdjacentPass(attachmentRef.m_pass))
  294. {
  295. // Find attachment within pass
  296. result = pass->FindAttachmentBinding(attachmentRef.m_attachment);
  297. }
  298. AZ_Error("Pass", result, "Pass [%s] could not find %s (Pass [%s], Attachment [%s])",
  299. m_path.GetCStr(), attachmentSourceTypeDebugName, attachmentRef.m_pass.GetCStr(), attachmentRef.m_attachment.GetCStr());
  300. return result;
  301. }
  302. // --- PassTemplate related functions ---
  303. void Pass::CreateBindingsFromTemplate()
  304. {
  305. if (m_template)
  306. {
  307. for (const PassSlot& slot : m_template->m_slots)
  308. {
  309. PassAttachmentBinding binding(slot);
  310. AddAttachmentBinding(binding);
  311. }
  312. }
  313. }
  314. void Pass::AttachBufferToSlot(AZStd::string_view slot, Data::Instance<Buffer> buffer)
  315. {
  316. AttachBufferToSlot(Name(slot), buffer);
  317. }
  318. void Pass::AttachBufferToSlot(const Name& slot, Data::Instance<Buffer> buffer)
  319. {
  320. if (!buffer)
  321. {
  322. return;
  323. }
  324. PassAttachmentBinding* localBinding = FindAttachmentBinding(slot);
  325. if (!localBinding)
  326. {
  327. AZ_RPI_PASS_ERROR(false, "Pass::AttachBufferToSlot - Pass [%s] failed to find slot [%s].",
  328. m_path.GetCStr(), slot.GetCStr());
  329. return;
  330. }
  331. // We can't handle the case that there is already an attachment attached yet.
  332. // We could consider to add it later if there are needs. It may require remove from the owned attachment list and
  333. // handle the connected bindings
  334. if (localBinding->GetAttachment())
  335. {
  336. AZ_RPI_PASS_ERROR(false, "Pass::AttachBufferToSlot - Slot [%s] already has attachment [%s].",
  337. slot.GetCStr(), localBinding->GetAttachment()->m_name.GetCStr());
  338. return;
  339. }
  340. PassBufferAttachmentDesc desc;
  341. desc.m_bufferDescriptor = buffer->GetRHIBuffer()->GetDescriptor();
  342. desc.m_lifetime = RHI::AttachmentLifetimeType::Imported;
  343. desc.m_name = buffer->GetAttachmentId();
  344. Ptr<PassAttachment> attachment = CreateAttachmentFromDesc(desc);
  345. attachment->m_importedResource = buffer;
  346. m_ownedAttachments.push_back(attachment);
  347. localBinding->SetOriginalAttachment(attachment);
  348. }
  349. void Pass::AttachImageToSlot(const Name& slot, Data::Instance<AttachmentImage> image)
  350. {
  351. PassAttachmentBinding* localBinding = FindAttachmentBinding(slot);
  352. if (!localBinding)
  353. {
  354. AZ_RPI_PASS_ERROR(false, "Pass::AttachImageToSlot - Pass [%s] failed to find slot [%s].",
  355. m_path.GetCStr(), slot.GetCStr());
  356. return;
  357. }
  358. // We can't handle the case that there is already an attachment attached yet.
  359. // We could consider to add it later if there are needs. It may require remove from the owned attachment list and
  360. // handle the connected bindings
  361. if (localBinding->GetAttachment())
  362. {
  363. AZ_RPI_PASS_ERROR(false, "Pass::AttachImageToSlot - Slot [%s] already has attachment [%s].",
  364. slot.GetCStr(), localBinding->GetAttachment()->m_name.GetCStr());
  365. return;
  366. }
  367. PassImageAttachmentDesc desc;
  368. desc.m_imageDescriptor = image->GetRHIImage()->GetDescriptor();
  369. desc.m_lifetime = RHI::AttachmentLifetimeType::Imported;
  370. desc.m_name = image->GetAttachmentId();
  371. Ptr<PassAttachment> attachment = CreateAttachmentFromDesc(desc);
  372. attachment->m_importedResource = image;
  373. m_ownedAttachments.push_back(attachment);
  374. localBinding->SetOriginalAttachment(attachment);
  375. }
  376. void Pass::ProcessConnection(const PassConnection& connection, uint32_t slotTypeMask)
  377. {
  378. [[maybe_unused]] auto prefix = [&]() -> AZStd::string
  379. {
  380. return AZStd::string::format(
  381. "Pass::ProcessConnection %s:%s -> %s:%s",
  382. m_path.GetCStr(),
  383. connection.m_localSlot.GetCStr(),
  384. connection.m_attachmentRef.m_pass.GetCStr(),
  385. connection.m_attachmentRef.m_attachment.GetCStr());
  386. };
  387. // -- Find Local Binding --
  388. // Get the input from this pass that forms one end of the connection
  389. PassAttachmentBinding* localBinding = FindAttachmentBinding(connection.m_localSlot);
  390. if (!localBinding)
  391. {
  392. AZ_RPI_PASS_ERROR(false, "%s: failed to find Local Slot.", prefix().c_str());
  393. return;
  394. }
  395. // Slot type mask used to skip connections at various stages of initialization
  396. uint32_t bindingMask = (1 << uint32_t(localBinding->m_slotType));
  397. if (!(bindingMask & slotTypeMask))
  398. {
  399. return;
  400. }
  401. // -- Local Variables --
  402. Name connectedPassName = connection.m_attachmentRef.m_pass;
  403. Name connectedSlotName = connection.m_attachmentRef.m_attachment;
  404. Ptr<PassAttachment> attachment = nullptr;
  405. PassAttachmentBinding* connectedBinding = nullptr;
  406. bool foundPass = false;
  407. bool slotTypeMismatch = false;
  408. // -- Search This Pass --
  409. if (connectedPassName == PassNameThis)
  410. {
  411. foundPass = true;
  412. attachment = FindOwnedAttachment(connectedSlotName);
  413. AZ_RPI_PASS_ERROR(
  414. attachment, "%s: Current Pass doesn't own an attachment named [%s].", prefix().c_str(), connectedSlotName.GetCStr());
  415. }
  416. // -- Search Pipeline --
  417. else if (connectedPassName == PipelineGlobalKeyword)
  418. {
  419. AZ_RPI_PASS_ERROR(m_pipeline != nullptr, "%s: Pass doesn't have a valid pipeline pointer.", prefix().c_str());
  420. foundPass = true; // Using the "Pipeline" keyword, no need to continue searching for passes
  421. if (m_pipeline)
  422. {
  423. const PipelineGlobalBinding* globalBinding = m_pipeline->GetPipelineGlobalConnection(connectedSlotName);
  424. if (globalBinding)
  425. {
  426. connectedBinding = globalBinding->m_binding;
  427. }
  428. AZ_RPI_PASS_ERROR(connectedBinding, "%s: Cannot find pipeline global connection.", prefix().c_str());
  429. }
  430. }
  431. // -- Search Parent & Siblings --
  432. // The (connectedPassName != m_name) avoids edge case where parent pass has child pass of same name.
  433. // In this case, parent pass would ask it's parent pass for a sibling with the given name and get a pointer to itself.
  434. // It would then try to connect to itself, which is obviously not the intention of the user
  435. if (!foundPass && m_parent && connectedPassName != m_name)
  436. {
  437. if (connectedPassName == PassNameParent)
  438. {
  439. foundPass = true;
  440. connectedBinding = m_parent->FindAttachmentBinding(connectedSlotName);
  441. if (!connectedBinding)
  442. {
  443. attachment = m_parent->FindOwnedAttachment(connectedSlotName);
  444. }
  445. else
  446. {
  447. slotTypeMismatch = connectedBinding->m_slotType != localBinding->m_slotType &&
  448. connectedBinding->m_slotType != PassSlotType::InputOutput &&
  449. localBinding->m_slotType != PassSlotType::InputOutput;
  450. }
  451. }
  452. else
  453. {
  454. // Use the connection Name to find a sibling pass
  455. Ptr<Pass> siblingPass = m_parent->FindChildPass(connectedPassName);
  456. if (siblingPass)
  457. {
  458. foundPass = true;
  459. connectedBinding = siblingPass->FindAttachmentBinding(connectedSlotName);
  460. slotTypeMismatch = connectedBinding != nullptr &&
  461. connectedBinding->m_slotType == localBinding->m_slotType &&
  462. connectedBinding->m_slotType != PassSlotType::InputOutput;
  463. }
  464. }
  465. }
  466. // -- Search Children --
  467. ParentPass* asParent = AsParent();
  468. if (!foundPass && asParent)
  469. {
  470. Ptr<Pass> childPass = asParent->FindChildPass(connectedPassName);
  471. if (childPass)
  472. {
  473. foundPass = true;
  474. connectedBinding = childPass->FindAttachmentBinding(connectedSlotName);
  475. slotTypeMismatch = connectedBinding != nullptr &&
  476. connectedBinding->m_slotType != localBinding->m_slotType &&
  477. connectedBinding->m_slotType != PassSlotType::InputOutput &&
  478. localBinding->m_slotType != PassSlotType::InputOutput;
  479. }
  480. }
  481. // -- Finalize & Report Errors --
  482. if (slotTypeMismatch)
  483. {
  484. AZ_RPI_PASS_ERROR(
  485. false,
  486. "%s: Slot Type Mismatch - When connecting to a child slot, both slots must be of the same type, or one must be "
  487. "InputOutput.",
  488. prefix().c_str());
  489. connectedBinding = nullptr;
  490. }
  491. if (connectedBinding)
  492. {
  493. localBinding->m_connectedBinding = connectedBinding;
  494. UpdateConnectedBinding(*localBinding);
  495. }
  496. else if (attachment)
  497. {
  498. localBinding->SetOriginalAttachment(attachment);
  499. }
  500. else
  501. {
  502. if (!m_flags.m_partOfHierarchy)
  503. {
  504. // [GFX TODO][ATOM-13693]: REMOVE POST R1 - passes not in hierarchy should no longer have this function called
  505. // When view is changing, removal of the passes can occur (cascade shadow passes for example)
  506. // resulting in temporary orphan passes that will be removed over the next frame.
  507. AZ_RPI_PASS_WARNING(false, "%s: Pass is no longer part of the hierarchy and about to be removed.", prefix().c_str());
  508. }
  509. else if (foundPass)
  510. {
  511. AZ_RPI_PASS_ERROR(false, "%s: Could not find binding on target.", prefix().c_str());
  512. }
  513. else
  514. {
  515. AZ_RPI_PASS_ERROR(false, "%s: Could not find target pass.", prefix().c_str());
  516. }
  517. }
  518. }
  519. void Pass::ProcessFallbackConnection(const PassFallbackConnection& connection)
  520. {
  521. PassAttachmentBinding* inputBinding = FindAttachmentBinding(connection.m_inputSlotName);
  522. PassAttachmentBinding* outputBinding = FindAttachmentBinding(connection.m_outputSlotName);
  523. [[maybe_unused]] auto prefix = [&]() -> AZStd::string
  524. {
  525. return AZStd::string::format(
  526. "Pass::ProcessFallbackConnection: %s, %s -> %s",
  527. m_path.GetCStr(),
  528. connection.m_inputSlotName.GetCStr(),
  529. connection.m_outputSlotName.GetCStr());
  530. };
  531. if (!outputBinding || !inputBinding)
  532. {
  533. AZ_RPI_PASS_ERROR(inputBinding, "%s: failed to find input slot.", prefix().c_str());
  534. AZ_RPI_PASS_ERROR(outputBinding, "%s: failed to find output slot.", prefix().c_str());
  535. return;
  536. }
  537. bool typesAreValid = inputBinding->m_slotType == PassSlotType::Input && outputBinding->m_slotType == PassSlotType::Output;
  538. if (!typesAreValid)
  539. {
  540. AZ_RPI_PASS_ERROR(
  541. inputBinding->m_slotType == PassSlotType::Input, "%s: Input doesn't have SlotType::Input.", prefix().c_str());
  542. AZ_RPI_PASS_ERROR(
  543. outputBinding->m_slotType == PassSlotType::Output, "%s: Output doesn't have SlotType::Output.", prefix().c_str());
  544. return;
  545. }
  546. outputBinding->m_fallbackBinding = inputBinding;
  547. UpdateConnectedBinding(*outputBinding);
  548. }
  549. template<typename AttachmentDescType>
  550. Ptr<PassAttachment> Pass::CreateAttachmentFromDesc(const AttachmentDescType& desc)
  551. {
  552. Ptr<PassAttachment> attachment = aznew PassAttachment(desc);
  553. // If the attachment is imported, we will create the resource (buffer or image) of this attachment
  554. // from asset referenced in m_assetRef
  555. // The resource instance will be saved in m_importedResource and the attachment id is acquired from resource instance
  556. if (desc.m_lifetime == RHI::AttachmentLifetimeType::Imported)
  557. {
  558. attachment->m_path = desc.m_name;
  559. if (attachment->m_descriptor.m_type == RHI::AttachmentType::Buffer)
  560. {
  561. Data::Asset<BufferAsset> bufferAsset = AssetUtils::LoadAssetById<BufferAsset>(desc.m_assetRef.m_assetId, AssetUtils::TraceLevel::None);
  562. if (bufferAsset.IsReady())
  563. {
  564. Data::Instance<Buffer> buffer = Buffer::FindOrCreate(bufferAsset);
  565. if (buffer)
  566. {
  567. attachment->m_path = buffer->GetAttachmentId();
  568. attachment->m_importedResource = buffer;
  569. attachment->m_descriptor = buffer->GetRHIBuffer()->GetDescriptor();
  570. }
  571. }
  572. }
  573. else if (attachment->m_descriptor.m_type == RHI::AttachmentType::Image)
  574. {
  575. Data::Asset<AttachmentImageAsset> imageAsset = AssetUtils::LoadAssetById<AttachmentImageAsset>(desc.m_assetRef.m_assetId, AssetUtils::TraceLevel::None);
  576. if (imageAsset.IsReady())
  577. {
  578. Data::Instance<AttachmentImage> image = AttachmentImage::FindOrCreate(imageAsset);
  579. if (image)
  580. {
  581. attachment->m_path = image->GetAttachmentId();
  582. attachment->m_importedResource = image;
  583. attachment->m_descriptor = image->GetDescriptor();
  584. }
  585. }
  586. }
  587. else
  588. {
  589. AZ_RPI_PASS_ASSERT(false, "Unsupported imported attachment type");
  590. }
  591. }
  592. else
  593. {
  594. // Only apply path name to transient attachment. Keep the original name for imported attachment
  595. attachment->ComputePathName(m_path);
  596. }
  597. // Setup attachment sources...
  598. if (desc.m_sizeSource.m_source.m_pass == PipelineKeyword) // if source is pipeline
  599. {
  600. attachment->m_renderPipelineSource = m_pipeline;
  601. attachment->m_getSizeFromPipeline = true;
  602. attachment->m_sizeMultipliers = desc.m_sizeSource.m_multipliers;
  603. }
  604. else if (const PassAttachmentBinding* source = FindAdjacentBinding(desc.m_sizeSource.m_source, "SizeSource"))
  605. {
  606. attachment->m_sizeSource = source;
  607. attachment->m_sizeMultipliers = desc.m_sizeSource.m_multipliers;
  608. }
  609. if (desc.m_formatSource.m_pass == PipelineKeyword) // if source is pipeline
  610. {
  611. attachment->m_renderPipelineSource = m_pipeline;
  612. attachment->m_getFormatFromPipeline = true;
  613. }
  614. else if (const PassAttachmentBinding* source = FindAdjacentBinding(desc.m_formatSource, "FormatSource"))
  615. {
  616. attachment->m_formatSource = source;
  617. }
  618. if (desc.m_multisampleSource.m_pass == PipelineKeyword) // if source is pipeline
  619. {
  620. attachment->m_renderPipelineSource = m_pipeline;
  621. attachment->m_getMultisampleStateFromPipeline = true;
  622. }
  623. else if (const PassAttachmentBinding* source = FindAdjacentBinding(desc.m_multisampleSource, "MultisampleSource"))
  624. {
  625. attachment->m_multisampleSource = source;
  626. }
  627. if (const PassAttachmentBinding* source = FindAdjacentBinding(desc.m_arraySizeSource, "ArraySizeSource"))
  628. {
  629. attachment->m_arraySizeSource = source;
  630. }
  631. attachment->m_ownerPass = this;
  632. return attachment;
  633. }
  634. template<typename AttachmentDescType>
  635. void Pass::OverrideOrAddAttachment(const AttachmentDescType& desc)
  636. {
  637. bool overrideAttachment = false;
  638. // Search existing attachments
  639. for (size_t i = 0; i < m_ownedAttachments.size(); ++i)
  640. {
  641. // If we find one with the same name
  642. if (m_ownedAttachments[i]->m_name == desc.m_name)
  643. {
  644. // Override it
  645. m_ownedAttachments[i] = CreateAttachmentFromDesc(desc);
  646. overrideAttachment = true;
  647. break;
  648. }
  649. }
  650. // If we didn't override any attachments
  651. if (!overrideAttachment)
  652. {
  653. // Create a new one
  654. m_ownedAttachments.emplace_back(CreateAttachmentFromDesc(desc));
  655. }
  656. }
  657. void Pass::SetupInputsFromRequest()
  658. {
  659. if (m_flags.m_createdByPassRequest)
  660. {
  661. const uint32_t slotTypeMask = (1 << uint32_t(PassSlotType::Input)) | (1 << uint32_t(PassSlotType::InputOutput));
  662. for (const PassConnection& connection : m_request.m_connections)
  663. {
  664. ProcessConnection(connection, slotTypeMask);
  665. }
  666. }
  667. }
  668. void Pass::SetupOutputsFromRequest()
  669. {
  670. if (m_flags.m_createdByPassRequest)
  671. {
  672. const uint32_t slotTypeMask = (1 << uint32_t(PassSlotType::Output));
  673. for (const PassConnection& connection : m_request.m_connections)
  674. {
  675. ProcessConnection(connection, slotTypeMask);
  676. }
  677. }
  678. }
  679. void Pass::SetupPassDependencies()
  680. {
  681. // Get dependencies declared in the PassRequest
  682. if (m_flags.m_createdByPassRequest)
  683. {
  684. for (const Name& passName : m_request.m_executeAfterPasses)
  685. {
  686. Ptr<Pass> executeAfterPass = FindAdjacentPass(passName);
  687. if (executeAfterPass != nullptr)
  688. {
  689. m_executeAfterPasses.push_back(executeAfterPass.get());
  690. }
  691. }
  692. for (const Name& passName : m_request.m_executeBeforePasses)
  693. {
  694. Ptr<Pass> executeBeforePass = FindAdjacentPass(passName);
  695. if (executeBeforePass != nullptr)
  696. {
  697. m_executeBeforePasses.push_back(executeBeforePass.get());
  698. }
  699. }
  700. }
  701. // Inherit dependencies from ParentPass
  702. if (m_parent)
  703. {
  704. for (Pass* pass : m_parent->m_executeAfterPasses)
  705. {
  706. m_executeAfterPasses.push_back(pass);
  707. }
  708. for (Pass* pass : m_parent->m_executeBeforePasses)
  709. {
  710. m_executeBeforePasses.push_back(pass);
  711. }
  712. }
  713. }
  714. void Pass::SetupInputsFromTemplate()
  715. {
  716. if (m_template)
  717. {
  718. const uint32_t slotTypeMask = (1 << uint32_t(PassSlotType::Input)) | (1 << uint32_t(PassSlotType::InputOutput));
  719. for (const PassConnection& outputConnection : m_template->m_connections)
  720. {
  721. ProcessConnection(outputConnection, slotTypeMask);
  722. }
  723. }
  724. }
  725. void Pass::SetupOutputsFromTemplate()
  726. {
  727. if (m_template)
  728. {
  729. const uint32_t slotTypeMask = (1 << uint32_t(PassSlotType::Output));
  730. for (const PassConnection& outputConnection : m_template->m_connections)
  731. {
  732. ProcessConnection(outputConnection, slotTypeMask);
  733. }
  734. for (const PassFallbackConnection& fallbackConnection : m_template->m_fallbackConnections)
  735. {
  736. ProcessFallbackConnection(fallbackConnection);
  737. }
  738. }
  739. }
  740. void Pass::CreateAttachmentsFromTemplate()
  741. {
  742. if (m_template)
  743. {
  744. // Create image attachments
  745. for (const PassImageAttachmentDesc& desc : m_template->m_imageAttachments)
  746. {
  747. m_ownedAttachments.emplace_back(CreateAttachmentFromDesc(desc));
  748. }
  749. // Create buffer attachments
  750. for (const PassBufferAttachmentDesc& desc : m_template->m_bufferAttachments)
  751. {
  752. m_ownedAttachments.emplace_back(CreateAttachmentFromDesc(desc));
  753. }
  754. }
  755. }
  756. void Pass::CreateAttachmentsFromRequest()
  757. {
  758. if (m_flags.m_createdByPassRequest)
  759. {
  760. // Create image attachments
  761. for (const PassImageAttachmentDesc& desc : m_request.m_imageAttachmentOverrides)
  762. {
  763. OverrideOrAddAttachment(desc);
  764. }
  765. // Create buffer attachments
  766. for (const PassBufferAttachmentDesc& desc : m_request.m_bufferAttachmentOverrides)
  767. {
  768. OverrideOrAddAttachment(desc);
  769. }
  770. }
  771. }
  772. // --- Attachment and Binding related functions ---
  773. void Pass::StoreImportedAttachmentReferences()
  774. {
  775. m_importedAttachmentStore.clear();
  776. for (const Ptr<PassAttachment>& attachment : m_ownedAttachments)
  777. {
  778. if (attachment->m_lifetime == RHI::AttachmentLifetimeType::Imported)
  779. {
  780. m_importedAttachmentStore.push_back(attachment);
  781. }
  782. }
  783. }
  784. void Pass::CreateTransientAttachments(RHI::FrameGraphAttachmentInterface attachmentDatabase)
  785. {
  786. for (const Ptr<PassAttachment>& attachment : m_ownedAttachments)
  787. {
  788. if (attachment->m_lifetime == RHI::AttachmentLifetimeType::Transient)
  789. {
  790. switch (attachment->m_descriptor.m_type)
  791. {
  792. case RHI::AttachmentType::Image:
  793. attachmentDatabase.CreateTransientImage(attachment->GetTransientImageDescriptor());
  794. break;
  795. case RHI::AttachmentType::Buffer:
  796. attachmentDatabase.CreateTransientBuffer(attachment->GetTransientBufferDescriptor());
  797. break;
  798. default:
  799. AZ_RPI_PASS_ASSERT(false, "Error, transient attachment is neither an image nor a buffer!");
  800. break;
  801. }
  802. }
  803. }
  804. }
  805. void Pass::ImportAttachments(RHI::FrameGraphAttachmentInterface attachmentDatabase)
  806. {
  807. for (const Ptr<PassAttachment>& attachment : m_ownedAttachments)
  808. {
  809. if (attachment->m_lifetime == RHI::AttachmentLifetimeType::Imported)
  810. {
  811. // make sure to only import the resource one time
  812. RHI::AttachmentId attachmentId = attachment->GetAttachmentId();
  813. const RHI::FrameAttachment* currentAttachment = attachmentDatabase.FindAttachment(attachmentId);
  814. if (azrtti_istypeof<Image>(attachment->m_importedResource.get()))
  815. {
  816. Image* image = static_cast<Image*>(attachment->m_importedResource.get());
  817. if (currentAttachment == nullptr)
  818. {
  819. attachmentDatabase.ImportImage(attachmentId, image->GetRHIImage());
  820. }
  821. else
  822. {
  823. AZ_Assert(currentAttachment->GetResource() == image->GetRHIImage(),
  824. "Importing image attachment named \"%s\" but a different attachment with the "
  825. "same name already exists in the database.\n", attachmentId.GetCStr());
  826. }
  827. }
  828. else if (azrtti_istypeof<Buffer>(attachment->m_importedResource.get()))
  829. {
  830. Buffer* buffer = static_cast<Buffer*>(attachment->m_importedResource.get());
  831. if (currentAttachment == nullptr)
  832. {
  833. attachmentDatabase.ImportBuffer(attachmentId, buffer->GetRHIBuffer());
  834. }
  835. else
  836. {
  837. AZ_Assert(currentAttachment->GetResource() == buffer->GetRHIBuffer(),
  838. "Importing buffer attachment named \"%s\" but a different attachment with the "
  839. "same name already exists in the database.\n", attachmentId.GetCStr());
  840. }
  841. }
  842. else
  843. {
  844. AZ_RPI_PASS_ERROR(false, "Can't import unknown resource type");
  845. }
  846. }
  847. }
  848. }
  849. void Pass::UpdateAttachmentUsageIndices()
  850. {
  851. // We want to find attachments that are used more than once by the same pass
  852. // An example of this could be reading from and writing to different mips of the same texture
  853. // Loop over all attachments bound to this pass
  854. size_t size = m_attachmentBindings.size();
  855. for (size_t i = 0; i < size; ++i)
  856. {
  857. PassAttachmentBinding& binding01 = m_attachmentBindings[i];
  858. // For the outer loop, only consider bindings which are the
  859. // first occurrence of their given attachment in the pass
  860. if (binding01.m_attachmentUsageIndex != 0)
  861. {
  862. continue;
  863. }
  864. // Loop over all subsequent bindings in the pass
  865. uint8_t duplicateCount = 0;
  866. for (size_t j = i + 1; j < size; ++j)
  867. {
  868. PassAttachmentBinding& binding02 = m_attachmentBindings[j];
  869. // Bindings are considered having the same attachment if they are connected to the same binding...
  870. bool haveSameConnection = binding01.m_connectedBinding == binding02.m_connectedBinding;
  871. haveSameConnection = haveSameConnection && binding01.m_connectedBinding != nullptr;
  872. // ... Or if they point to the same attachment
  873. bool isSameAttachment = binding01.GetAttachment() == binding02.GetAttachment();
  874. isSameAttachment = isSameAttachment && binding01.GetAttachment() != nullptr;
  875. // If binding 01 and binding 02 have the same attachment, update the attachment usage index on binding 02
  876. if (haveSameConnection || isSameAttachment)
  877. {
  878. binding02.m_attachmentUsageIndex = ++duplicateCount;
  879. }
  880. }
  881. }
  882. }
  883. void Pass::UpdateOwnedAttachments()
  884. {
  885. // Update the output attachments to coincide with their source attachments (if specified)
  886. // This involves getting the format and calculating the size from the source attachment
  887. for (Ptr<PassAttachment>& attachment: m_ownedAttachments)
  888. {
  889. attachment->Update();
  890. }
  891. }
  892. void Pass::UpdateConnectedBinding(PassAttachmentBinding& binding)
  893. {
  894. bool useFallback = (m_state != PassState::Building && !IsEnabled());
  895. binding.UpdateConnection(useFallback);
  896. }
  897. void Pass::UpdateConnectedBindings()
  898. {
  899. // Depending on whether a pass is enabled or not, it may switch it's bindings to become a pass-through
  900. // For this reason we update connecting bindings on a per-frame basis
  901. for (PassAttachmentBinding& binding : m_attachmentBindings)
  902. {
  903. UpdateConnectedBinding(binding);
  904. }
  905. }
  906. void Pass::RegisterPipelineGlobalConnections()
  907. {
  908. if (!m_pipeline)
  909. {
  910. AZ_RPI_PASS_ERROR(m_pipelineGlobalConnections.size() == 0,
  911. "Pass::RegisterPipelineGlobalConnections() - PipelineGlobal connections specified but no pipeline set on pass [%s]",
  912. m_path.GetCStr());
  913. }
  914. for (const PipelineGlobalConnection& connection : m_pipelineGlobalConnections)
  915. {
  916. PassAttachmentBinding* binding = FindAttachmentBinding(connection.m_localBinding);
  917. AZ_RPI_PASS_ERROR(binding != nullptr, "Pass::RegisterPipelineGlobalConnections() - Could not find local binding [%s]",
  918. connection.m_localBinding.GetCStr());
  919. if (binding)
  920. {
  921. m_pipeline->AddPipelineGlobalConnection(connection.m_globalName, binding, this);
  922. }
  923. }
  924. m_flags.m_containsGlobalReference = (m_pipelineGlobalConnections.size() > 0);
  925. }
  926. // --- Queuing functions with PassSystem ---
  927. void Pass::QueueForBuildAndInitialization()
  928. {
  929. // Don't queue if we're currently building. Don't queue if we're already queued for Build or Removal
  930. if (m_state != PassState::Building &&
  931. m_queueState != PassQueueState::QueuedForBuildAndInitialization &&
  932. m_queueState != PassQueueState::QueuedForRemoval)
  933. {
  934. // NOTE: We only queue for Build here, the queue for Initialization happens at the end of Pass::Build
  935. // (doing it this way is an optimization to minimize the number of passes queued for initialization,
  936. // as many passes will be initialized by their parent passes and thus don't need to be queued)
  937. PassSystemInterface::Get()->QueueForBuild(this);
  938. m_queueState = PassQueueState::QueuedForBuildAndInitialization;
  939. // Transition state
  940. // If we are Rendering, the state will transition [Rendering -> Queued] in Pass::FrameEnd
  941. // TODO: the PassState::Reset check is a quick fix until the pass concurrency with multiple scenes issue is fixed
  942. if (m_state != PassState::Rendering && m_state != PassState::Reset)
  943. {
  944. m_state = PassState::Queued;
  945. }
  946. }
  947. }
  948. void Pass::QueueForInitialization()
  949. {
  950. // Only queue if the pass is not in any queue. Don't queue if we're currently initializing.
  951. if (m_queueState == PassQueueState::NoQueue && m_state != PassState::Initializing)
  952. {
  953. PassSystemInterface::Get()->QueueForInitialization(this);
  954. m_queueState = PassQueueState::QueuedForInitialization;
  955. // Transition state
  956. // If we are Rendering, the state will transition [Rendering -> Queued] in Pass::FrameEnd
  957. // If the state is Built, preserve the state since [Built -> Initializing] is a valid transition
  958. // Preserving PassState::Built lets the pass ignore subsequent build calls in the same frame
  959. if (m_state != PassState::Rendering && m_state != PassState::Built)
  960. {
  961. m_state = PassState::Queued;
  962. }
  963. }
  964. }
  965. void Pass::QueueForRemoval()
  966. {
  967. // Skip only if we're already queued for removal, otherwise proceed.
  968. // QueuedForRemoval overrides QueuedForBuildAndInitialization and QueuedForInitialization.
  969. if (m_queueState != PassQueueState::QueuedForRemoval)
  970. {
  971. PassSystemInterface::Get()->QueueForRemoval(this);
  972. m_queueState = PassQueueState::QueuedForRemoval;
  973. // Transition state
  974. // If we are Rendering, the state will transition [Rendering -> Queued] in Pass::FrameEnd
  975. if (m_state != PassState::Rendering)
  976. {
  977. m_state = PassState::Queued;
  978. }
  979. }
  980. }
  981. // --- Pass behavior functions ---
  982. void Pass::Reset()
  983. {
  984. AZ_RPI_BREAK_ON_TARGET_PASS;
  985. // Ensure we're in a valid state to reset. This ensures the pass won't be reset multiple times in the same frame.
  986. bool execute = (m_state == PassState::Idle);
  987. execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForBuildAndInitialization);
  988. execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization);
  989. if (!execute)
  990. {
  991. return;
  992. }
  993. m_state = PassState::Resetting;
  994. if (m_flags.m_isPipelineRoot)
  995. {
  996. m_pipeline->ClearGlobalBindings();
  997. }
  998. // Store references to imported attachments to underlying images and buffers aren't deleted during attachment building
  999. StoreImportedAttachmentReferences();
  1000. // Clear lists
  1001. m_inputBindingIndices.clear();
  1002. m_inputOutputBindingIndices.clear();
  1003. m_outputBindingIndices.clear();
  1004. m_attachmentBindings.clear();
  1005. m_ownedAttachments.clear();
  1006. m_executeAfterPasses.clear();
  1007. m_executeBeforePasses.clear();
  1008. ResetInternal();
  1009. m_state = PassState::Reset;
  1010. }
  1011. void Pass::Build(bool calledFromPassSystem)
  1012. {
  1013. AZ_RPI_BREAK_ON_TARGET_PASS;
  1014. // Ensure we're in a valid state to build. This ensures the pass won't be built multiple times in the same frame.
  1015. bool execute = (m_state == PassState::Reset);
  1016. if (!execute)
  1017. {
  1018. return;
  1019. }
  1020. m_state = PassState::Building;
  1021. // Bindings, inputs and attachments
  1022. CreateBindingsFromTemplate();
  1023. RegisterPipelineGlobalConnections();
  1024. SetupPassDependencies();
  1025. CreateAttachmentsFromTemplate();
  1026. CreateAttachmentsFromRequest();
  1027. SetupInputsFromTemplate();
  1028. SetupInputsFromRequest();
  1029. // Custom pass behavior
  1030. BuildInternal();
  1031. // Outputs
  1032. SetupOutputsFromTemplate();
  1033. SetupOutputsFromRequest();
  1034. // Update
  1035. UpdateConnectedBindings();
  1036. UpdateOwnedAttachments();
  1037. UpdateAttachmentUsageIndices();
  1038. m_state = PassState::Built;
  1039. m_queueState = PassQueueState::NoQueue;
  1040. // If this pass's Build() wasn't called from the Pass System, then it was called by it's parent pass
  1041. // In which case we don't need to queue for initialization because the parent will already be queued
  1042. if (calledFromPassSystem)
  1043. {
  1044. // Queue for Initialization
  1045. QueueForInitialization();
  1046. }
  1047. }
  1048. void Pass::Initialize()
  1049. {
  1050. AZ_RPI_BREAK_ON_TARGET_PASS;
  1051. // Ensure we're in a valid state to initialize. This ensures the pass won't be initialized multiple times in the same frame.
  1052. bool execute = (m_state == PassState::Idle || m_state == PassState::Built);
  1053. execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization);
  1054. if (!execute)
  1055. {
  1056. return;
  1057. }
  1058. m_state = PassState::Initializing;
  1059. m_queueState = PassQueueState::NoQueue;
  1060. InitializeInternal();
  1061. // Need to recreate the dest attachment because the source attachment might be changed
  1062. if (!m_attachmentCopy.expired())
  1063. {
  1064. m_attachmentCopy.lock()->InvalidateDestImage();
  1065. }
  1066. m_state = PassState::Initialized;
  1067. }
  1068. void Pass::OnInitializationFinished()
  1069. {
  1070. m_flags.m_alreadyCreatedChildren = false;
  1071. m_importedAttachmentStore.clear();
  1072. OnInitializationFinishedInternal();
  1073. m_state = PassState::Idle;
  1074. }
  1075. void Pass::Validate(PassValidationResults& validationResults)
  1076. {
  1077. if (PassValidation::IsEnabled())
  1078. {
  1079. // Log passes with missing input
  1080. for (uint8_t idx : m_inputBindingIndices)
  1081. {
  1082. if (!m_attachmentBindings[idx].GetAttachment())
  1083. {
  1084. validationResults.m_passesWithMissingInputs.push_back(this);
  1085. break;
  1086. }
  1087. }
  1088. // Log passes with missing input/output
  1089. for (uint8_t idx : m_inputOutputBindingIndices)
  1090. {
  1091. if (!m_attachmentBindings[idx].GetAttachment())
  1092. {
  1093. validationResults.m_passesWithMissingInputOutputs.push_back(this);
  1094. break;
  1095. }
  1096. }
  1097. // Log passes with missing output (note that missing output connections are not considered an error)
  1098. for (uint8_t idx : m_outputBindingIndices)
  1099. {
  1100. if (!m_attachmentBindings[idx].GetAttachment())
  1101. {
  1102. validationResults.m_passesWithMissingOutputs.push_back(this);
  1103. break;
  1104. }
  1105. }
  1106. if (m_errorMessages.size() > 0)
  1107. {
  1108. validationResults.m_passesWithErrors.push_back(this);
  1109. }
  1110. if (m_warningMessages.size() > 0)
  1111. {
  1112. validationResults.m_passesWithWarnings.push_back(this);
  1113. }
  1114. }
  1115. }
  1116. void Pass::FrameBegin(FramePrepareParams params)
  1117. {
  1118. AZ_RPI_BREAK_ON_TARGET_PASS;
  1119. bool earlyOut = !IsEnabled();
  1120. // Skip if this pass is the root of the pipeline and the pipeline is set to not render
  1121. if (m_flags.m_isPipelineRoot)
  1122. {
  1123. AZ_RPI_PASS_ASSERT(m_pipeline != nullptr, "Pass is flagged as a pipeline root but it's pipeline pointer is invalid while trying to render");
  1124. earlyOut = earlyOut || m_pipeline == nullptr || m_pipeline->GetRenderMode() == RenderPipeline::RenderMode::NoRender;
  1125. }
  1126. if (earlyOut)
  1127. {
  1128. return;
  1129. }
  1130. AZ_Error("PassSystem", m_state == PassState::Idle,
  1131. "Pass::FrameBegin - Pass [%s] is attempting to render, and should be in the 'Idle' or 'Queued' state, but is in the '%s' state.",
  1132. m_path.GetCStr(), ToString(m_state).data());
  1133. m_state = PassState::Rendering;
  1134. UpdateOwnedAttachments();
  1135. CreateTransientAttachments(params.m_frameGraphBuilder->GetAttachmentDatabase());
  1136. ImportAttachments(params.m_frameGraphBuilder->GetAttachmentDatabase());
  1137. // readback attachment with input state
  1138. UpdateReadbackAttachment(params, true);
  1139. // FrameBeginInternal needs to be the last function be called in FrameBegin because its implementation expects
  1140. // all the attachments are imported to database (for example, ImageAttachmentPreview)
  1141. FrameBeginInternal(params);
  1142. // readback attachment with output state
  1143. UpdateReadbackAttachment(params, false);
  1144. // update attachment copy for preview
  1145. UpdateAttachmentCopy(params);
  1146. }
  1147. void Pass::FrameEnd()
  1148. {
  1149. if (m_state == PassState::Rendering)
  1150. {
  1151. FrameEndInternal();
  1152. m_state = (m_queueState == PassQueueState::NoQueue) ? PassState::Idle : PassState::Queued;
  1153. }
  1154. }
  1155. // --- RenderPipeline, PipelineViewTag and DrawListTag ---
  1156. RHI::DrawListTag Pass::GetDrawListTag() const
  1157. {
  1158. static RHI::DrawListTag invalidTag;
  1159. return invalidTag;
  1160. }
  1161. const PipelineViewTag& Pass::GetPipelineViewTag() const
  1162. {
  1163. if (m_viewTag.IsEmpty())
  1164. {
  1165. if (m_flags.m_isPipelineRoot && m_pipeline)
  1166. {
  1167. return m_pipeline->GetMainViewTag();
  1168. }
  1169. else if (m_parent)
  1170. {
  1171. return m_parent->GetPipelineViewTag();
  1172. }
  1173. }
  1174. return m_viewTag;
  1175. }
  1176. void Pass::SetRenderPipeline(RenderPipeline* pipeline)
  1177. {
  1178. AZ_Assert(!m_pipeline || !pipeline || m_pipeline == pipeline,
  1179. "Switching passes between pipelines is not supported and may result in undefined behavior");
  1180. if (m_pipeline != pipeline)
  1181. {
  1182. m_pipeline = pipeline;
  1183. // Re-queue for new pipeline.
  1184. if (m_pipeline != nullptr)
  1185. {
  1186. PassState currentState = m_state;
  1187. m_queueState = PassQueueState::NoQueue;
  1188. QueueForBuildAndInitialization();
  1189. if (currentState == PassState::Reset)
  1190. {
  1191. m_state = PassState::Reset;
  1192. }
  1193. }
  1194. }
  1195. }
  1196. void Pass::ManualPipelineBuildAndInitialize()
  1197. {
  1198. Build();
  1199. Initialize();
  1200. OnInitializationFinished();
  1201. }
  1202. Scene* Pass::GetScene() const
  1203. {
  1204. if (m_pipeline)
  1205. {
  1206. return m_pipeline->GetScene();
  1207. }
  1208. return nullptr;
  1209. }
  1210. PassTree* Pass::GetPassTree() const
  1211. {
  1212. return m_pipeline ? &(m_pipeline->m_passTree) : nullptr;
  1213. }
  1214. void Pass::GetViewDrawListInfo(RHI::DrawListMask& outDrawListMask, PassesByDrawList& outPassesByDrawList, const PipelineViewTag& viewTag) const
  1215. {
  1216. // NOTE: we always collect the draw list mask regardless if the pass enabled or not. The reason is we want to keep the view information
  1217. // even when pass is disabled so it can continue work correctly when re-enable it.
  1218. // Only get the DrawListTag if this pass has a DrawListTag and it's PipelineViewId matches
  1219. if (BindViewSrg() && HasDrawListTag() && GetPipelineViewTag() == viewTag)
  1220. {
  1221. RHI::DrawListTag drawListTag = GetDrawListTag();
  1222. if (drawListTag.IsValid() && outPassesByDrawList.find(drawListTag) == outPassesByDrawList.end())
  1223. {
  1224. outPassesByDrawList[drawListTag] = this;
  1225. outDrawListMask.set(drawListTag.GetIndex());
  1226. }
  1227. }
  1228. }
  1229. void Pass::GetPipelineViewTags(PipelineViewTags& outTags) const
  1230. {
  1231. if (BindViewSrg())
  1232. {
  1233. outTags.insert(GetPipelineViewTag());
  1234. }
  1235. }
  1236. void Pass::SortDrawList(RHI::DrawList& drawList) const
  1237. {
  1238. if (!drawList.empty())
  1239. {
  1240. RHI::SortDrawList(drawList, m_drawListSortType);
  1241. }
  1242. }
  1243. // --- Debug & Validation functions ---
  1244. bool PassValidationResults::IsValid()
  1245. {
  1246. if (PassValidation::IsEnabled())
  1247. {
  1248. // Pass validation fail if there are any passes with build errors or missing inputs (or input/outputs)
  1249. return (m_passesWithErrors.size() == 0) && (m_passesWithMissingInputs.size() == 0) && (m_passesWithMissingInputOutputs.size() == 0);
  1250. }
  1251. else
  1252. {
  1253. return true;
  1254. }
  1255. }
  1256. TimestampResult Pass::GetLatestTimestampResult() const
  1257. {
  1258. return GetTimestampResultInternal();
  1259. }
  1260. PipelineStatisticsResult Pass::GetLatestPipelineStatisticsResult() const
  1261. {
  1262. return GetPipelineStatisticsResultInternal();
  1263. }
  1264. bool Pass::ReadbackAttachment(AZStd::shared_ptr<AttachmentReadback> readback, uint32_t readbackIndex, const Name& slotName
  1265. , PassAttachmentReadbackOption option, const RHI::ImageSubresourceRange* mipsRange)
  1266. {
  1267. // Return false if it's already readback
  1268. if (m_attachmentReadback)
  1269. {
  1270. AZ_Warning("Pass", false, "ReadbackAttachment: skip readback pass [%s] slot [%s] because there is an another active readback", m_path.GetCStr(), slotName.GetCStr());
  1271. return false;
  1272. }
  1273. uint32_t bindingIndex = 0;
  1274. for (auto& binding : m_attachmentBindings)
  1275. {
  1276. if (slotName == binding.m_name)
  1277. {
  1278. RHI::AttachmentType type = binding.GetAttachment()->GetAttachmentType();
  1279. if (type == RHI::AttachmentType::Buffer || type == RHI::AttachmentType::Image)
  1280. {
  1281. RHI::AttachmentId attachmentId = binding.GetAttachment()->GetAttachmentId();
  1282. // Append slot index and pass name so the read back's name won't be same as the attachment used in other passes.
  1283. AZStd::string readbackName = AZStd::string::format("%s_%d_%d_%s", attachmentId.GetCStr(),
  1284. readbackIndex, bindingIndex, GetName().GetCStr());
  1285. if (readback->ReadPassAttachment(binding.GetAttachment().get(), AZ::Name(readbackName), mipsRange))
  1286. {
  1287. m_readbackOption = PassAttachmentReadbackOption::Output;
  1288. // The m_readbackOption is only meaningful if the attachment is used for InputOutput.
  1289. if (binding.m_slotType == PassSlotType::InputOutput)
  1290. {
  1291. m_readbackOption = option;
  1292. }
  1293. m_attachmentReadback = readback;
  1294. return true;
  1295. }
  1296. return false;
  1297. }
  1298. }
  1299. bindingIndex++;
  1300. }
  1301. AZ_Warning("Pass", false, "ReadbackAttachment: failed to find slot [%s] from pass [%s]", slotName.GetCStr(), m_path.GetCStr());
  1302. return false;
  1303. }
  1304. void Pass::UpdateReadbackAttachment(FramePrepareParams params, bool beforeAddScopes)
  1305. {
  1306. if (beforeAddScopes == (m_readbackOption == PassAttachmentReadbackOption::Input) && m_attachmentReadback)
  1307. {
  1308. // Read the attachment for one frame. The reference can be released afterwards
  1309. m_attachmentReadback->FrameBegin(params);
  1310. m_attachmentReadback = nullptr;
  1311. }
  1312. }
  1313. void Pass::UpdateAttachmentCopy(FramePrepareParams params)
  1314. {
  1315. if (!m_attachmentCopy.expired())
  1316. {
  1317. m_attachmentCopy.lock()->FrameBegin(params);
  1318. }
  1319. }
  1320. bool Pass::UpdateImportedAttachmentImage(Ptr<PassAttachment>& attachment, RHI::ImageBindFlags bindFlags, RHI::ImageAspectFlags aspectFlags)
  1321. {
  1322. if (!attachment)
  1323. {
  1324. return false;
  1325. }
  1326. // update the image attachment descriptor to sync up size and format
  1327. attachment->Update(true);
  1328. RHI::ImageDescriptor& imageDesc = attachment->m_descriptor.m_image;
  1329. // The Format Source had no valid attachment
  1330. if (imageDesc.m_format == RHI::Format::Unknown)
  1331. {
  1332. return false;
  1333. }
  1334. RPI::AttachmentImage* currentImage = azrtti_cast<RPI::AttachmentImage*>(attachment->m_importedResource.get());
  1335. if (attachment->m_importedResource && imageDesc.m_size == currentImage->GetDescriptor().m_size)
  1336. {
  1337. // If there's a resource already and the size didn't change, just keep using the old AttachmentImage.
  1338. return true;
  1339. }
  1340. Data::Instance<RPI::AttachmentImagePool> pool = RPI::ImageSystemInterface::Get()->GetSystemAttachmentPool();
  1341. // set the bind flags
  1342. imageDesc.m_bindFlags |= bindFlags;
  1343. // The ImageViewDescriptor must be specified to make sure the frame graph compiler doesn't treat this as a transient image.
  1344. RHI::ImageViewDescriptor viewDesc = RHI::ImageViewDescriptor::Create(imageDesc.m_format, 0, 0);
  1345. viewDesc.m_aspectFlags = aspectFlags;
  1346. // The full path name is needed for the attachment image so it's not deduplicated from accumulation images in different pipelines.
  1347. AZStd::string imageName = RPI::ConcatPassString(GetPathName(), attachment->m_path);
  1348. auto attachmentImage = RPI::AttachmentImage::Create(*pool.get(), imageDesc, Name(imageName), nullptr, &viewDesc);
  1349. if (attachmentImage)
  1350. {
  1351. attachment->m_path = attachmentImage->GetAttachmentId();
  1352. attachment->m_importedResource = attachmentImage;
  1353. return true;
  1354. }else
  1355. {
  1356. AZ_Error("Pass", false, "UpdateImportedAttachmentImage failed because it is unable to create an attachment image.");
  1357. }
  1358. return false;
  1359. }
  1360. void Pass::PrintIndent(AZStd::string& stringOutput, uint32_t indent) const
  1361. {
  1362. if (PassValidation::IsEnabled())
  1363. {
  1364. for (uint32_t i = 0; i < indent; ++i)
  1365. {
  1366. stringOutput += " ";
  1367. }
  1368. }
  1369. }
  1370. void Pass::PrintPassName(AZStd::string& stringOutput, uint32_t indent) const
  1371. {
  1372. if (PassValidation::IsEnabled())
  1373. {
  1374. stringOutput += "\n";
  1375. PrintIndent(stringOutput, indent);
  1376. stringOutput += "- ";
  1377. //stringOutput += m_name.GetStringView();
  1378. //stringOutput += "- ";
  1379. stringOutput += m_path.GetStringView();
  1380. stringOutput += "\n";
  1381. }
  1382. }
  1383. void Pass::PrintErrors() const
  1384. {
  1385. if (PassValidation::IsEnabled())
  1386. {
  1387. PrintMessages(m_errorMessages);
  1388. }
  1389. }
  1390. void Pass::PrintWarnings() const
  1391. {
  1392. if (PassValidation::IsEnabled())
  1393. {
  1394. PrintMessages(m_warningMessages);
  1395. }
  1396. }
  1397. void Pass::PrintMessages(const AZStd::vector<AZStd::string>& messages) const
  1398. {
  1399. if (PassValidation::IsEnabled())
  1400. {
  1401. AZStd::string stringOutput;
  1402. PrintPassName(stringOutput);
  1403. for (const AZStd::string& message : messages)
  1404. {
  1405. PrintIndent(stringOutput, 1);
  1406. stringOutput += message;
  1407. stringOutput += "\n";
  1408. }
  1409. AZ_Printf("PassSystem", stringOutput.c_str());
  1410. }
  1411. }
  1412. void Pass::PrintBindingsWithoutAttachments(uint32_t slotTypeMask) const
  1413. {
  1414. if (PassValidation::IsEnabled())
  1415. {
  1416. AZStd::string stringOutput;
  1417. PrintPassName(stringOutput);
  1418. for (const PassAttachmentBinding& binding : m_attachmentBindings)
  1419. {
  1420. uint32_t bindingMask = (1 << uint32_t(binding.m_slotType));
  1421. if ((bindingMask & slotTypeMask) && (binding.GetAttachment() == nullptr))
  1422. {
  1423. // Print the name of the slot
  1424. PrintIndent(stringOutput, 1);
  1425. stringOutput += binding.m_name.GetStringView();
  1426. stringOutput += " has no valid attachment\n";
  1427. }
  1428. }
  1429. AZ_Printf("PassSystem", stringOutput.c_str());
  1430. }
  1431. }
  1432. void Pass::DebugPrintBinding(AZStd::string& stringOutput, const PassAttachmentBinding& binding) const
  1433. {
  1434. if (PassValidation::IsEnabled())
  1435. {
  1436. // Print the name of the slot
  1437. stringOutput += binding.m_name.GetStringView();
  1438. // Print the attachment type and size, for example:
  1439. // (Image, 1920, 1080) or (Buffer, 4096 bytes)
  1440. if (binding.GetAttachment() != nullptr)
  1441. {
  1442. stringOutput += " (";
  1443. // Images will have the format: AttachmentName (Image, 1920, 1080)
  1444. if (binding.GetAttachment()->m_descriptor.m_type == RHI::AttachmentType::Image)
  1445. {
  1446. stringOutput += "Image";
  1447. RHI::ImageDescriptor& desc = binding.GetAttachment()->m_descriptor.m_image;
  1448. uint32_t dimensions = static_cast<uint32_t>(desc.m_dimension);
  1449. for (uint32_t i = 0; i < dimensions; ++i)
  1450. {
  1451. stringOutput += ", ";
  1452. stringOutput += AZStd::to_string(desc.m_size[i]);
  1453. }
  1454. if (desc.m_multisampleState.m_samples > 1)
  1455. {
  1456. if (desc.m_multisampleState.m_customPositionsCount > 0)
  1457. {
  1458. stringOutput += ", Custom_MSAA_";
  1459. }
  1460. else
  1461. {
  1462. stringOutput += ", MSAA_";
  1463. }
  1464. stringOutput += AZStd::to_string(desc.m_multisampleState.m_samples);
  1465. stringOutput += "x";
  1466. }
  1467. }
  1468. // Buffers will have the format: AttachmentName (Buffer, 4092 bytes)
  1469. else if (binding.GetAttachment()->m_descriptor.m_type == RHI::AttachmentType::Buffer)
  1470. {
  1471. stringOutput += "Buffer, ";
  1472. stringOutput += AZStd::to_string(binding.GetAttachment()->m_descriptor.m_buffer.m_byteCount);
  1473. stringOutput += " bytes";
  1474. }
  1475. stringOutput += ")";
  1476. }
  1477. }
  1478. }
  1479. void Pass::DebugPrintBindingAndConnection(AZStd::string& stringOutput, uint8_t bindingIndex) const
  1480. {
  1481. if (PassValidation::IsEnabled())
  1482. {
  1483. PrintIndent(stringOutput, m_treeDepth + 2);
  1484. // Print the Attachment
  1485. const PassAttachmentBinding& binding = m_attachmentBindings[bindingIndex];
  1486. DebugPrintBinding(stringOutput, binding);
  1487. // Print the Attachment it's connected to
  1488. if (binding.m_connectedBinding != nullptr)
  1489. {
  1490. stringOutput += " connected to ";
  1491. DebugPrintBinding(stringOutput, *binding.m_connectedBinding);
  1492. }
  1493. stringOutput += "\n";
  1494. }
  1495. }
  1496. void Pass::DebugPrint() const
  1497. {
  1498. if (PassValidation::IsEnabled())
  1499. {
  1500. AZStd::string stringOutput;
  1501. PrintPassName(stringOutput, m_treeDepth);
  1502. // Print inputs
  1503. if (m_inputBindingIndices.size() > 0)
  1504. {
  1505. PrintIndent(stringOutput, m_treeDepth + 1);
  1506. stringOutput += "Inputs:\n";
  1507. for (uint8_t inputIndex : m_inputBindingIndices)
  1508. {
  1509. DebugPrintBindingAndConnection(stringOutput, inputIndex);
  1510. }
  1511. }
  1512. // Print input/outputs
  1513. if (m_inputOutputBindingIndices.size() > 0)
  1514. {
  1515. PrintIndent(stringOutput, m_treeDepth + 1);
  1516. stringOutput += "Input/Outputs:\n";
  1517. for (uint8_t inputIndex : m_inputOutputBindingIndices)
  1518. {
  1519. DebugPrintBindingAndConnection(stringOutput, inputIndex);
  1520. }
  1521. }
  1522. // Print outputs
  1523. if (m_outputBindingIndices.size() > 0)
  1524. {
  1525. PrintIndent(stringOutput, m_treeDepth + 1);
  1526. stringOutput += "Outputs:\n";
  1527. for (uint8_t inputIndex : m_outputBindingIndices)
  1528. {
  1529. DebugPrintBindingAndConnection(stringOutput, inputIndex);
  1530. }
  1531. }
  1532. AZ_Printf("PassSystem", stringOutput.c_str());
  1533. }
  1534. }
  1535. void PassValidationResults::PrintValidationIfError()
  1536. {
  1537. if (PassValidation::IsEnabled())
  1538. {
  1539. if (!IsValid())
  1540. {
  1541. AZ_Printf("PassSystem", "\n--- PASS VALIDATION FAILURE ---"
  1542. "\n--Critical Errors--\n");
  1543. AZ_Printf("PassSystem", "\nThere are %d passes with errors:\n", m_passesWithErrors.size());
  1544. for (Pass* pass : m_passesWithErrors)
  1545. {
  1546. pass->PrintErrors();
  1547. }
  1548. AZ_Printf("PassSystem", "\nThere are %d passes with missing Inputs:\n", m_passesWithMissingInputs.size());
  1549. for (Pass* pass : m_passesWithMissingInputs)
  1550. {
  1551. pass->PrintBindingsWithoutAttachments(uint32_t(PassSlotMask::Input));
  1552. }
  1553. AZ_Printf("PassSystem", "\nThere are %d passes with missing Inputs/Outputs:\n", m_passesWithMissingInputOutputs.size());
  1554. for (Pass* pass : m_passesWithMissingInputOutputs)
  1555. {
  1556. pass->PrintBindingsWithoutAttachments(uint32_t(PassSlotMask::InputOutput));
  1557. }
  1558. AZ_Printf("PassSystem", "\n--Non-Critical Errors/Warnings--\n");
  1559. AZ_Printf("PassSystem", "\nThere are %d passes with warnings:\n", m_passesWithWarnings.size());
  1560. for (Pass* pass : m_passesWithWarnings)
  1561. {
  1562. pass->PrintWarnings();
  1563. }
  1564. }
  1565. }
  1566. }
  1567. } // namespace RPI
  1568. } // namespace AZ