3
0

RenderPass.cpp 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578
  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 <Atom/RHI/CommandList.h>
  9. #include <Atom/RHI/FrameGraphAttachmentInterface.h>
  10. #include <Atom/RHI/FrameGraphBuilder.h>
  11. #include <Atom/RHI/FrameGraphCompileContext.h>
  12. #include <Atom/RHI/FrameGraphExecuteContext.h>
  13. #include <Atom/RHI/RHIUtils.h>
  14. #include <Atom/RHI.Reflect/ImageScopeAttachmentDescriptor.h>
  15. #include <Atom/RHI.Reflect/RenderAttachmentLayoutBuilder.h>
  16. #include <Atom/RHI.Reflect/Size.h>
  17. #include <Atom/RPI.Public/Base.h>
  18. #include <Atom/RPI.Reflect/Pass/RenderPassData.h>
  19. #include <Atom/RPI.Public/GpuQuery/Query.h>
  20. #include <Atom/RPI.Public/Pass/PassUtils.h>
  21. #include <Atom/RPI.Public/Pass/RenderPass.h>
  22. #include <Atom/RPI.Public/Pass/Specific/ImageAttachmentPreviewPass.h>
  23. #include <Atom/RPI.Public/RenderPipeline.h>
  24. #include <Atom/RPI.Public/Scene.h>
  25. #include <Atom/RPI.Public/View.h>
  26. namespace AZ
  27. {
  28. namespace RPI
  29. {
  30. RenderPass::RenderPass(const PassDescriptor& descriptor)
  31. : Pass(descriptor)
  32. {
  33. // Read view tag from pass data
  34. const RenderPassData* passData = PassUtils::GetPassData<RenderPassData>(descriptor);
  35. if (passData && !passData->m_pipelineViewTag.IsEmpty())
  36. {
  37. SetPipelineViewTag(passData->m_pipelineViewTag);
  38. }
  39. if (passData && passData->m_bindViewSrg)
  40. {
  41. m_flags.m_bindViewSrg = true;
  42. }
  43. }
  44. RenderPass::~RenderPass()
  45. {
  46. }
  47. RHI::RenderAttachmentConfiguration RenderPass::GetRenderAttachmentConfiguration() const
  48. {
  49. RHI::RenderAttachmentLayoutBuilder builder;
  50. auto* layoutBuilder = builder.AddSubpass();
  51. for (size_t slotIndex = 0; slotIndex < m_attachmentBindings.size(); ++slotIndex)
  52. {
  53. const PassAttachmentBinding& binding = m_attachmentBindings[slotIndex];
  54. if (!binding.GetAttachment())
  55. {
  56. continue;
  57. }
  58. // Handle the depth-stencil attachment. There should be only one.
  59. if (binding.m_scopeAttachmentUsage == RHI::ScopeAttachmentUsage::DepthStencil)
  60. {
  61. layoutBuilder->DepthStencilAttachment(binding.GetAttachment()->m_descriptor.m_image.m_format);
  62. continue;
  63. }
  64. // Handle shading rate attachment. There should be only one.
  65. if (binding.m_scopeAttachmentUsage == RHI::ScopeAttachmentUsage::ShadingRate)
  66. {
  67. layoutBuilder->ShadingRateAttachment(binding.GetAttachment()->m_descriptor.m_image.m_format);
  68. continue;
  69. }
  70. // Skip bindings that aren't outputs or inputOutputs
  71. if (binding.m_slotType != PassSlotType::Output && binding.m_slotType != PassSlotType::InputOutput)
  72. {
  73. continue;
  74. }
  75. if (binding.m_scopeAttachmentUsage == RHI::ScopeAttachmentUsage::RenderTarget)
  76. {
  77. RHI::Format format = binding.GetAttachment()->m_descriptor.m_image.m_format;
  78. layoutBuilder->RenderTargetAttachment(format);
  79. }
  80. }
  81. RHI::RenderAttachmentLayout layout;
  82. [[maybe_unused]] RHI::ResultCode result = builder.End(layout);
  83. AZ_Assert(result == RHI::ResultCode::Success, "RenderPass [%s] failed to create render attachment layout", GetPathName().GetCStr());
  84. return RHI::RenderAttachmentConfiguration{ layout, 0 };
  85. }
  86. RHI::MultisampleState RenderPass::GetMultisampleState() const
  87. {
  88. RHI::MultisampleState outputMultiSampleState;
  89. bool wasSet = false;
  90. for (size_t slotIndex = 0; slotIndex < m_attachmentBindings.size(); ++slotIndex)
  91. {
  92. const PassAttachmentBinding& binding = m_attachmentBindings[slotIndex];
  93. if (binding.m_slotType != PassSlotType::Output && binding.m_slotType != PassSlotType::InputOutput)
  94. {
  95. continue;
  96. }
  97. if (!binding.GetAttachment())
  98. {
  99. continue;
  100. }
  101. if (binding.m_scopeAttachmentUsage == RHI::ScopeAttachmentUsage::RenderTarget
  102. || binding.m_scopeAttachmentUsage == RHI::ScopeAttachmentUsage::DepthStencil)
  103. {
  104. if (!wasSet)
  105. {
  106. // save multi-sample state found in the first output color attachment
  107. outputMultiSampleState = binding.GetAttachment()->m_descriptor.m_image.m_multisampleState;
  108. wasSet = true;
  109. }
  110. else if (PassValidation::IsEnabled())
  111. {
  112. // return false directly if the current output color attachment has different multi-sample state then previous ones
  113. if (outputMultiSampleState != binding.GetAttachment()->m_descriptor.m_image.m_multisampleState)
  114. {
  115. AZ_Error("RPI", false, "Pass %s has different multi-sample states within its color attachments", GetPathName().GetCStr());
  116. break;
  117. }
  118. }
  119. else
  120. {
  121. break;
  122. }
  123. }
  124. }
  125. return outputMultiSampleState;
  126. }
  127. void RenderPass::InitializeInternal()
  128. {
  129. if (m_shaderResourceGroup != nullptr)
  130. {
  131. Name autoBind = Name("AutoBind");
  132. Name noBind = Name("NoBind");
  133. for (PassAttachmentBinding& binding : m_attachmentBindings)
  134. {
  135. const Name& shaderName = binding.m_shaderInputName;
  136. PassAttachment* attachment = binding.GetAttachment().get();
  137. if (shaderName == autoBind)
  138. {
  139. binding.m_shaderInputIndex = PassAttachmentBinding::ShaderInputAutoBind;
  140. }
  141. else if (shaderName == noBind)
  142. {
  143. binding.m_shaderInputIndex = PassAttachmentBinding::ShaderInputNoBind;
  144. }
  145. else if (attachment)
  146. {
  147. if (attachment->GetAttachmentType() == RHI::AttachmentType::Image)
  148. {
  149. RHI::ShaderInputImageIndex idx = m_shaderResourceGroup->FindShaderInputImageIndex(shaderName);
  150. AZ_Error("Pass System", idx.IsValid(), "[Pass %s] Could not retrieve Shader Image Index for SRG variable'%s'", GetName().GetCStr(), shaderName.GetCStr());
  151. binding.m_shaderInputIndex = idx.IsValid() ? static_cast<int16_t>(idx.GetIndex()) : PassAttachmentBinding::ShaderInputNoBind;
  152. }
  153. else if (attachment->GetAttachmentType() == RHI::AttachmentType::Buffer)
  154. {
  155. RHI::ShaderInputBufferIndex idx = m_shaderResourceGroup->FindShaderInputBufferIndex(shaderName);
  156. AZ_Error("Pass System", idx.IsValid(), "[Pass %s] Could not retrieve Shader Buffer Index for SRG variable '%s'", GetName().GetCStr(), shaderName.GetCStr());
  157. binding.m_shaderInputIndex = idx.IsValid() ? static_cast<int16_t>(idx.GetIndex()) : PassAttachmentBinding::ShaderInputNoBind;
  158. }
  159. }
  160. else
  161. {
  162. AZ_Error( "Pass System", AZ::RHI::IsNullRHI(), "[Pass %s] Could not bind shader buffer index '%s' because it has no attachment.", GetName().GetCStr(), shaderName.GetCStr());
  163. binding.m_shaderInputIndex = PassAttachmentBinding::ShaderInputNoBind;
  164. }
  165. }
  166. }
  167. }
  168. void RenderPass::FrameBeginInternal(FramePrepareParams params)
  169. {
  170. if (GetScopeId().IsEmpty())
  171. {
  172. InitScope(RHI::ScopeId(GetPathName()), m_hardwareQueueClass);
  173. }
  174. params.m_frameGraphBuilder->ImportScopeProducer(*this);
  175. // Read back the ScopeQueries submitted from previous frames
  176. ReadbackScopeQueryResults();
  177. CollectSrgs();
  178. PassSystemInterface::Get()->IncrementFrameRenderPassCount();
  179. }
  180. void RenderPass::FrameEndInternal()
  181. {
  182. ResetSrgs();
  183. }
  184. void RenderPass::SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph)
  185. {
  186. DeclareAttachmentsToFrameGraph(frameGraph);
  187. DeclarePassDependenciesToFrameGraph(frameGraph);
  188. AddScopeQueryToFrameGraph(frameGraph);
  189. }
  190. void RenderPass::BuildCommandList(const RHI::FrameGraphExecuteContext& context)
  191. {
  192. BeginScopeQuery(context);
  193. BuildCommandListInternal(context);
  194. EndScopeQuery(context);
  195. }
  196. void RenderPass::DeclareAttachmentsToFrameGraph(RHI::FrameGraphInterface frameGraph) const
  197. {
  198. for (const PassAttachmentBinding& attachmentBinding : m_attachmentBindings)
  199. {
  200. if (attachmentBinding.GetAttachment() != nullptr &&
  201. frameGraph.GetAttachmentDatabase().IsAttachmentValid(attachmentBinding.GetAttachment()->GetAttachmentId()))
  202. {
  203. switch (attachmentBinding.m_unifiedScopeDesc.GetType())
  204. {
  205. case RHI::AttachmentType::Image:
  206. {
  207. frameGraph.UseAttachment(attachmentBinding.m_unifiedScopeDesc.GetAsImage(), attachmentBinding.GetAttachmentAccess(), attachmentBinding.m_scopeAttachmentUsage);
  208. break;
  209. }
  210. case RHI::AttachmentType::Buffer:
  211. {
  212. frameGraph.UseAttachment(attachmentBinding.m_unifiedScopeDesc.GetAsBuffer(), attachmentBinding.GetAttachmentAccess(), attachmentBinding.m_scopeAttachmentUsage);
  213. break;
  214. }
  215. default:
  216. AZ_Assert(false, "Error, trying to bind an attachment that is neither an image nor a buffer!");
  217. break;
  218. }
  219. }
  220. }
  221. }
  222. void RenderPass::DeclarePassDependenciesToFrameGraph(RHI::FrameGraphInterface frameGraph) const
  223. {
  224. for (Pass* pass : m_executeAfterPasses)
  225. {
  226. RenderPass* renderPass = azrtti_cast<RenderPass*>(pass);
  227. if (renderPass)
  228. {
  229. frameGraph.ExecuteAfter(renderPass->GetScopeId());
  230. }
  231. }
  232. for (Pass* pass : m_executeBeforePasses)
  233. {
  234. RenderPass* renderPass = azrtti_cast<RenderPass*>(pass);
  235. if (renderPass)
  236. {
  237. frameGraph.ExecuteBefore(renderPass->GetScopeId());
  238. }
  239. }
  240. }
  241. void RenderPass::BindAttachment(const RHI::FrameGraphCompileContext& context, PassAttachmentBinding& binding, int16_t& imageIndex, int16_t& bufferIndex)
  242. {
  243. PassAttachment* attachment = binding.GetAttachment().get();
  244. if (attachment)
  245. {
  246. int16_t inputIndex = binding.m_shaderInputIndex;
  247. uint16_t arrayIndex = binding.m_shaderInputArrayIndex;
  248. if (attachment->GetAttachmentType() == RHI::AttachmentType::Image)
  249. {
  250. if (inputIndex == PassAttachmentBinding::ShaderInputAutoBind)
  251. {
  252. inputIndex = imageIndex;
  253. }
  254. const RHI::ImageView* imageView =
  255. context.GetImageView(attachment->GetAttachmentId(), binding.m_unifiedScopeDesc.GetImageViewDescriptor(), binding.m_scopeAttachmentUsage);
  256. if (binding.m_shaderImageDimensionsNameIndex.HasName())
  257. {
  258. RHI::Size size = attachment->m_descriptor.m_image.m_size;
  259. AZ::Vector4 imageDimensions;
  260. imageDimensions.SetX(float(size.m_width));
  261. imageDimensions.SetY(float(size.m_height));
  262. imageDimensions.SetZ(1.0f / float(size.m_width));
  263. imageDimensions.SetW(1.0f / float(size.m_height));
  264. [[maybe_unused]]
  265. bool success = m_shaderResourceGroup->SetConstant(binding.m_shaderImageDimensionsNameIndex, imageDimensions);
  266. AZ_Assert(success, "Pass [%s] Could not find float4 constant [%s] in Shader Resource Group [%s]",
  267. GetPathName().GetCStr(),
  268. binding.m_shaderImageDimensionsNameIndex.GetNameForDebug().GetCStr(),
  269. m_shaderResourceGroup->GetDatabaseName());
  270. }
  271. if (binding.m_shaderInputIndex != PassAttachmentBinding::ShaderInputNoBind &&
  272. binding.m_scopeAttachmentUsage != RHI::ScopeAttachmentUsage::RenderTarget &&
  273. binding.m_scopeAttachmentUsage != RHI::ScopeAttachmentUsage::DepthStencil)
  274. {
  275. m_shaderResourceGroup->SetImageView(RHI::ShaderInputImageIndex(inputIndex), imageView, arrayIndex);
  276. ++imageIndex;
  277. }
  278. }
  279. else if (attachment->GetAttachmentType() == RHI::AttachmentType::Buffer)
  280. {
  281. if (binding.m_shaderInputIndex == PassAttachmentBinding::ShaderInputNoBind)
  282. {
  283. return;
  284. }
  285. if (inputIndex == PassAttachmentBinding::ShaderInputAutoBind)
  286. {
  287. inputIndex = bufferIndex;
  288. }
  289. const RHI::BufferView* bufferView = context.GetBufferView(attachment->GetAttachmentId(), binding.m_scopeAttachmentUsage);
  290. m_shaderResourceGroup->SetBufferView(RHI::ShaderInputBufferIndex(inputIndex), bufferView, arrayIndex);
  291. ++bufferIndex;
  292. }
  293. }
  294. }
  295. void RenderPass::BindPassSrg(const RHI::FrameGraphCompileContext& context, [[maybe_unused]] Data::Instance<ShaderResourceGroup>& shaderResourceGroup)
  296. {
  297. AZ_Assert(m_shaderResourceGroup != nullptr, "Passing a null shader resource group to RenderPass::BindPassSrg");
  298. int16_t imageIndex = 0;
  299. int16_t bufferIndex = 0;
  300. // Bind the input attachments to the SRG
  301. for (uint32_t idx = 0; idx < GetInputCount(); ++idx)
  302. {
  303. PassAttachmentBinding& binding = GetInputBinding(idx);
  304. AZ_Assert(binding.m_scopeAttachmentUsage != RHI::ScopeAttachmentUsage::RenderTarget,
  305. "Attachment bindings that are inputs cannot have their type set to 'RenderTarget'. Binding in question is %s on pass %s.",
  306. binding.m_name.GetCStr(),
  307. GetPathName().GetCStr());
  308. BindAttachment(context, binding, imageIndex, bufferIndex);
  309. }
  310. // Bind the input/output attachments to the SRG
  311. for (uint32_t idx = 0; idx < GetInputOutputCount(); ++idx)
  312. {
  313. PassAttachmentBinding& binding = GetInputOutputBinding(idx);
  314. BindAttachment(context, binding, imageIndex, bufferIndex);
  315. }
  316. // Bind the output attachments to the SRG
  317. for (uint32_t idx = 0; idx < GetOutputCount(); ++idx)
  318. {
  319. PassAttachmentBinding& binding = GetOutputBinding(idx);
  320. BindAttachment(context, binding, imageIndex, bufferIndex);
  321. }
  322. }
  323. ViewPtr RenderPass::GetView() const
  324. {
  325. if (m_pipeline)
  326. {
  327. return m_pipeline->GetFirstView(GetPipelineViewTag());
  328. }
  329. return nullptr;
  330. }
  331. void RenderPass::CollectSrgs()
  332. {
  333. // Scene srg
  334. const RHI::ShaderResourceGroup* sceneSrg = m_pipeline->GetScene()->GetRHIShaderResourceGroup();
  335. BindSrg(sceneSrg);
  336. // View srg
  337. if (m_flags.m_bindViewSrg)
  338. {
  339. ViewPtr view = GetView();
  340. if (view)
  341. {
  342. BindSrg(view->GetRHIShaderResourceGroup());
  343. }
  344. }
  345. // Pass srg
  346. if (m_shaderResourceGroup)
  347. {
  348. BindSrg(m_shaderResourceGroup->GetRHIShaderResourceGroup());
  349. }
  350. }
  351. void RenderPass::ResetSrgs()
  352. {
  353. m_shaderResourceGroupsToBind.clear();
  354. }
  355. void RenderPass::BindSrg(const RHI::ShaderResourceGroup* srg)
  356. {
  357. if (srg)
  358. {
  359. m_shaderResourceGroupsToBind[aznumeric_caster(srg->GetBindingSlot())] = srg;
  360. }
  361. }
  362. void RenderPass::SetSrgsForDraw(RHI::CommandList* commandList)
  363. {
  364. for (auto itr : m_shaderResourceGroupsToBind)
  365. {
  366. commandList->SetShaderResourceGroupForDraw(*(itr.second));
  367. }
  368. }
  369. void RenderPass::SetSrgsForDispatch(RHI::CommandList* commandList)
  370. {
  371. for (auto itr : m_shaderResourceGroupsToBind)
  372. {
  373. commandList->SetShaderResourceGroupForDispatch(*(itr.second));
  374. }
  375. }
  376. void RenderPass::SetPipelineViewTag(const PipelineViewTag& viewTag)
  377. {
  378. if (m_viewTag != viewTag)
  379. {
  380. m_viewTag = viewTag;
  381. if (m_pipeline)
  382. {
  383. m_pipeline->MarkPipelinePassChanges(PipelinePassChanges::PipelineViewTagChanged);
  384. }
  385. }
  386. m_flags.m_bindViewSrg = !viewTag.IsEmpty();
  387. }
  388. TimestampResult RenderPass::GetTimestampResultInternal() const
  389. {
  390. return m_timestampResult;
  391. }
  392. PipelineStatisticsResult RenderPass::GetPipelineStatisticsResultInternal() const
  393. {
  394. return m_statisticsResult;
  395. }
  396. Data::Instance<RPI::ShaderResourceGroup> RenderPass::GetShaderResourceGroup()
  397. {
  398. return m_shaderResourceGroup;
  399. }
  400. RHI::Ptr<Query> RenderPass::GetQuery(ScopeQueryType queryType)
  401. {
  402. uint32_t typeIndex = static_cast<uint32_t>(queryType);
  403. if (!m_scopeQueries[typeIndex])
  404. {
  405. RHI::Ptr<Query> query;
  406. switch (queryType)
  407. {
  408. case ScopeQueryType::Timestamp:
  409. query = GpuQuerySystemInterface::Get()->CreateQuery(
  410. RHI::QueryType::Timestamp, RHI::QueryPoolScopeAttachmentType::Global, RHI::ScopeAttachmentAccess::Write);
  411. break;
  412. case ScopeQueryType::PipelineStatistics:
  413. query = GpuQuerySystemInterface::Get()->CreateQuery(
  414. RHI::QueryType::PipelineStatistics, RHI::QueryPoolScopeAttachmentType::Global, RHI::ScopeAttachmentAccess::Write);
  415. break;
  416. }
  417. m_scopeQueries[typeIndex] = query;
  418. }
  419. return m_scopeQueries[typeIndex];
  420. }
  421. template<typename Func>
  422. inline void RenderPass::ExecuteOnTimestampQuery(Func&& func)
  423. {
  424. if (IsTimestampQueryEnabled())
  425. {
  426. auto query = GetQuery(ScopeQueryType::Timestamp);
  427. if (query)
  428. {
  429. func(query);
  430. }
  431. }
  432. }
  433. template<typename Func>
  434. inline void RenderPass::ExecuteOnPipelineStatisticsQuery(Func&& func)
  435. {
  436. if (IsPipelineStatisticsQueryEnabled())
  437. {
  438. auto query = GetQuery(ScopeQueryType::PipelineStatistics);
  439. if (query)
  440. {
  441. func(query);
  442. }
  443. }
  444. }
  445. void RenderPass::AddScopeQueryToFrameGraph(RHI::FrameGraphInterface frameGraph)
  446. {
  447. const auto addToFrameGraph = [&frameGraph](RHI::Ptr<Query> query)
  448. {
  449. query->AddToFrameGraph(frameGraph);
  450. };
  451. ExecuteOnTimestampQuery(addToFrameGraph);
  452. ExecuteOnPipelineStatisticsQuery(addToFrameGraph);
  453. }
  454. void RenderPass::BeginScopeQuery(const RHI::FrameGraphExecuteContext& context)
  455. {
  456. const auto beginQuery = [&context, this](RHI::Ptr<Query> query)
  457. {
  458. if (query->BeginQuery(context) == QueryResultCode::Fail)
  459. {
  460. AZ_UNUSED(this); // Prevent unused warning in release builds
  461. AZ_WarningOnce("RenderPass", false, "BeginScopeQuery failed. Make sure AddScopeQueryToFrameGraph was called in SetupFrameGraphDependencies"
  462. " for this pass: %s", this->RTTI_GetTypeName());
  463. }
  464. };
  465. if (context.GetCommandListIndex() == 0)
  466. {
  467. ExecuteOnTimestampQuery(beginQuery);
  468. ExecuteOnPipelineStatisticsQuery(beginQuery);
  469. }
  470. }
  471. void RenderPass::EndScopeQuery(const RHI::FrameGraphExecuteContext& context)
  472. {
  473. const auto endQuery = [&context](RHI::Ptr<Query> query)
  474. {
  475. query->EndQuery(context);
  476. };
  477. // This scope query implementation should be replaced by
  478. // [ATOM-5407] [RHI][Core] - Add GPU timestamp and pipeline statistic support for scopes
  479. // For timestamp query, it's okay to execute across different command lists
  480. if (context.GetCommandListIndex() == context.GetCommandListCount() - 1)
  481. {
  482. ExecuteOnTimestampQuery(endQuery);
  483. }
  484. // For all the other types of queries except timestamp, the query start and end has to be in the same command list
  485. // Here only tracks the PipelineStatistics for the first command list due to that we don't know how many queries are
  486. // needed when AddScopeQueryToFrameGraph is called.
  487. // This implementation leads to an issue that we may not get accurate pipeline statistic data
  488. // for passes which were executed with more than one command list
  489. if (context.GetCommandListIndex() == 0)
  490. {
  491. ExecuteOnPipelineStatisticsQuery(endQuery);
  492. }
  493. }
  494. void RenderPass::ReadbackScopeQueryResults()
  495. {
  496. ExecuteOnTimestampQuery([this](RHI::Ptr<Query> query)
  497. {
  498. const uint32_t TimestampResultQueryCount = 2u;
  499. uint64_t timestampResult[TimestampResultQueryCount] = {0};
  500. query->GetLatestResult(&timestampResult, sizeof(uint64_t) * TimestampResultQueryCount);
  501. m_timestampResult = TimestampResult(timestampResult[0], timestampResult[1], RHI::HardwareQueueClass::Graphics);
  502. });
  503. ExecuteOnPipelineStatisticsQuery([this](RHI::Ptr<Query> query)
  504. {
  505. query->GetLatestResult(&m_statisticsResult, sizeof(PipelineStatisticsResult));
  506. });
  507. }
  508. } // namespace RPI
  509. } // namespace AZ