ShaderResourceGroupLayout.cpp 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596
  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.Reflect/ShaderResourceGroupLayout.h>
  9. #include <AzCore/Serialization/SerializeContext.h>
  10. #include <AzCore/Utils/TypeHash.h>
  11. namespace AZ::RHI
  12. {
  13. void ShaderResourceGroupLayout::Reflect(AZ::ReflectContext* context)
  14. {
  15. if (SerializeContext* serializeContext = azrtti_cast<SerializeContext*>(context))
  16. {
  17. serializeContext->Class<ShaderResourceGroupLayout>()
  18. ->Version(8) // ATOM-15472
  19. ->Field("m_name", &ShaderResourceGroupLayout::m_name)
  20. ->Field("m_azslFileOfOrigin", &ShaderResourceGroupLayout::m_uniqueId)
  21. ->Field("m_staticSamplers", &ShaderResourceGroupLayout::m_staticSamplers)
  22. ->Field("m_inputsForBuffers", &ShaderResourceGroupLayout::m_inputsForBuffers)
  23. ->Field("m_inputsForImages", &ShaderResourceGroupLayout::m_inputsForImages)
  24. ->Field("m_inputsForBufferUnboundedArrays", &ShaderResourceGroupLayout::m_inputsForBufferUnboundedArrays)
  25. ->Field("m_inputsForImageUnboundedArrays", &ShaderResourceGroupLayout::m_inputsForImageUnboundedArrays)
  26. ->Field("m_inputsForSamplers", &ShaderResourceGroupLayout::m_inputsForSamplers)
  27. ->Field("m_intervalsForBuffers", &ShaderResourceGroupLayout::m_intervalsForBuffers)
  28. ->Field("m_intervalsForImages", &ShaderResourceGroupLayout::m_intervalsForImages)
  29. ->Field("m_intervalsForSamplers", &ShaderResourceGroupLayout::m_intervalsForSamplers)
  30. ->Field("m_groupSizeForBuffers", &ShaderResourceGroupLayout::m_groupSizeForBuffers)
  31. ->Field("m_groupSizeForImages", &ShaderResourceGroupLayout::m_groupSizeForImages)
  32. ->Field("m_groupSizeForBufferUnboundedArrays", &ShaderResourceGroupLayout::m_groupSizeForBufferUnboundedArrays)
  33. ->Field("m_groupSizeForImageUnboundedArrays", &ShaderResourceGroupLayout::m_groupSizeForImageUnboundedArrays)
  34. ->Field("m_groupSizeForSamplers", &ShaderResourceGroupLayout::m_groupSizeForSamplers)
  35. ->Field("m_idReflectionForBuffers", &ShaderResourceGroupLayout::m_idReflectionForBuffers)
  36. ->Field("m_idReflectionForImages", &ShaderResourceGroupLayout::m_idReflectionForImages)
  37. ->Field("m_idReflectionForBufferUnboundedArrays", &ShaderResourceGroupLayout::m_idReflectionForBufferUnboundedArrays)
  38. ->Field("m_idReflectionForImageUnboundedArrays", &ShaderResourceGroupLayout::m_idReflectionForImageUnboundedArrays)
  39. ->Field("m_idReflectionForSamplers", &ShaderResourceGroupLayout::m_idReflectionForSamplers)
  40. ->Field("m_constantsDataLayout", &ShaderResourceGroupLayout::m_constantsDataLayout)
  41. ->Field("m_bindingSlot", &ShaderResourceGroupLayout::m_bindingSlot)
  42. ->Field("m_shaderVariantKeyFallbackSize", &ShaderResourceGroupLayout::m_shaderVariantKeyFallbackSize)
  43. ->Field("m_shaderVariantKeyFallbackConstantIndex", &ShaderResourceGroupLayout::m_shaderVariantKeyFallbackConstantIndex)
  44. ->Field("m_hash", &ShaderResourceGroupLayout::m_hash)
  45. ;
  46. }
  47. IdReflectionMapForBuffers::Reflect(context);
  48. IdReflectionMapForImages::Reflect(context);
  49. IdReflectionMapForBufferUnboundedArrays::Reflect(context);
  50. IdReflectionMapForImageUnboundedArrays::Reflect(context);
  51. IdReflectionMapForSamplers::Reflect(context);
  52. }
  53. RHI::Ptr<ShaderResourceGroupLayout> ShaderResourceGroupLayout::Create()
  54. {
  55. return aznew ShaderResourceGroupLayout();
  56. }
  57. bool ShaderResourceGroupLayout::IsFinalized() const
  58. {
  59. return m_hash != HashValue64{ 0 };
  60. }
  61. bool ShaderResourceGroupLayout::ValidateFinalizeState(ValidateFinalizeStateExpect expect) const
  62. {
  63. if (Validation::IsEnabled())
  64. {
  65. if (expect == ValidateFinalizeStateExpect::Finalized && !IsFinalized())
  66. {
  67. AZ_Assert(false, "ShaderResourceGroupLayout must be finalized when calling this method.");
  68. return false;
  69. }
  70. else if (expect == ValidateFinalizeStateExpect::NotFinalized && IsFinalized())
  71. {
  72. AZ_Assert(false, "ShaderResourceGroupLayout cannot be finalized when calling this method.");
  73. return false;
  74. }
  75. }
  76. return true;
  77. }
  78. template<typename IndexType>
  79. bool ShaderResourceGroupLayout::ValidateAccess(IndexType inputIndex, size_t inputIndexLimit, [[maybe_unused]] const char* inputArrayTypeName) const
  80. {
  81. if (Validation::IsEnabled())
  82. {
  83. if (inputIndex.GetIndex() >= inputIndexLimit)
  84. {
  85. AZ_Assert(false, "%s Input index '%d' out of range [0,%d).", inputArrayTypeName, inputIndex.GetIndex(), inputIndexLimit);
  86. return false;
  87. }
  88. }
  89. return true;
  90. }
  91. template<typename IndexType>
  92. bool ShaderResourceGroupLayout::ValidateAccess(IndexType inputIndex, uint32_t arrayIndex, size_t inputIndexLimit, const char* inputArrayTypeName) const
  93. {
  94. if (Validation::IsEnabled())
  95. {
  96. if (!ValidateAccess(inputIndex, inputIndexLimit, inputArrayTypeName))
  97. {
  98. return false;
  99. }
  100. auto& descriptor = GetShaderInput(inputIndex);
  101. if (arrayIndex >= descriptor.m_count)
  102. {
  103. AZ_Assert(false, "%s Input '%s[%d]': Array index '%d' out of range [0,%d).", inputArrayTypeName, descriptor.m_name.GetCStr(), descriptor.m_count, arrayIndex, descriptor.m_count);
  104. return false;
  105. }
  106. }
  107. return true;
  108. }
  109. bool ShaderResourceGroupLayout::ValidateAccess(RHI::ShaderInputConstantIndex inputIndex) const
  110. {
  111. return m_constantsDataLayout->ValidateAccess(inputIndex);
  112. }
  113. bool ShaderResourceGroupLayout::ValidateAccess(RHI::ShaderInputBufferIndex inputIndex, uint32_t arrayIndex) const
  114. {
  115. return ValidateAccess(inputIndex, arrayIndex, m_inputsForBuffers.size(), "Buffer");
  116. }
  117. bool ShaderResourceGroupLayout::ValidateAccess(RHI::ShaderInputImageIndex inputIndex, uint32_t arrayIndex) const
  118. {
  119. return ValidateAccess(inputIndex, arrayIndex, m_inputsForImages.size(), "Image");
  120. }
  121. bool ShaderResourceGroupLayout::ValidateAccess(RHI::ShaderInputSamplerIndex inputIndex, uint32_t arrayIndex) const
  122. {
  123. return ValidateAccess(inputIndex, arrayIndex, m_inputsForSamplers.size(), "Sampler");
  124. }
  125. bool ShaderResourceGroupLayout::ValidateAccess(RHI::ShaderInputBufferUnboundedArrayIndex inputIndex) const
  126. {
  127. return ValidateAccess(inputIndex, m_inputsForBufferUnboundedArrays.size(), "BufferUnboundedArray");
  128. }
  129. bool ShaderResourceGroupLayout::ValidateAccess(RHI::ShaderInputImageUnboundedArrayIndex inputIndex) const
  130. {
  131. return ValidateAccess(inputIndex, m_inputsForImageUnboundedArrays.size(), "ImageUnboundedArray");
  132. }
  133. ShaderResourceGroupLayout::ShaderResourceGroupLayout()
  134. : m_constantsDataLayout(ConstantsLayout::Create())
  135. {
  136. }
  137. void ShaderResourceGroupLayout::Clear()
  138. {
  139. m_staticSamplers.clear();
  140. m_inputsForBuffers.clear();
  141. m_inputsForImages.clear();
  142. m_inputsForSamplers.clear();
  143. m_intervalsForBuffers.clear();
  144. m_intervalsForImages.clear();
  145. m_intervalsForSamplers.clear();
  146. m_groupSizeForBuffers = 0;
  147. m_groupSizeForImages = 0;
  148. m_groupSizeForBufferUnboundedArrays = 0;
  149. m_groupSizeForImageUnboundedArrays = 0;
  150. m_groupSizeForSamplers = 0;
  151. m_idReflectionForBuffers.Clear();
  152. m_idReflectionForImages.Clear();
  153. m_idReflectionForSamplers.Clear();
  154. if (m_constantsDataLayout)
  155. {
  156. m_constantsDataLayout->Clear();
  157. }
  158. m_bindingSlot = {};
  159. m_hash = HashValue64{ 0 };
  160. }
  161. template<typename NameIdReflectionMapT, typename ShaderInputDescriptorT, typename ShaderInputIndexT>
  162. bool ShaderResourceGroupLayout::FinalizeShaderInputGroup(
  163. const AZStd::vector<ShaderInputDescriptorT>& shaderInputDescriptors,
  164. AZStd::vector<Interval>& intervals,
  165. NameIdReflectionMapT& nameIdReflectionMap,
  166. uint32_t& groupSize)
  167. {
  168. intervals.reserve(shaderInputDescriptors.size());
  169. nameIdReflectionMap.Reserve(shaderInputDescriptors.size());
  170. uint32_t currentGroupSize = 0;
  171. uint32_t shaderInputIndex = 0;
  172. for (const ShaderInputDescriptorT& shaderInput : shaderInputDescriptors)
  173. {
  174. const ShaderInputIndexT inputIndex(shaderInputIndex);
  175. if (!nameIdReflectionMap.Insert(shaderInput.m_name, inputIndex))
  176. {
  177. Clear();
  178. return false;
  179. }
  180. // Add the [min, max) interval for the input in the group.
  181. intervals.emplace_back(currentGroupSize, currentGroupSize + shaderInput.m_count);
  182. currentGroupSize += shaderInput.m_count;
  183. ++shaderInputIndex;
  184. }
  185. groupSize = currentGroupSize;
  186. return true;
  187. }
  188. template<typename NameIdReflectionMapT, typename ShaderInputDescriptorT, typename ShaderInputIndexT>
  189. bool ShaderResourceGroupLayout::FinalizeUnboundedArrayShaderInputGroup(
  190. const AZStd::vector<ShaderInputDescriptorT>& shaderInputDescriptors,
  191. NameIdReflectionMapT& nameIdReflectionMap,
  192. uint32_t& groupSize)
  193. {
  194. nameIdReflectionMap.Reserve(shaderInputDescriptors.size());
  195. uint32_t currentGroupSize = 0;
  196. uint32_t shaderInputIndex = 0;
  197. for (const ShaderInputDescriptorT& shaderInput : shaderInputDescriptors)
  198. {
  199. const ShaderInputIndexT inputIndex(shaderInputIndex);
  200. if (!nameIdReflectionMap.Insert(shaderInput.m_name, inputIndex))
  201. {
  202. Clear();
  203. return false;
  204. }
  205. ++currentGroupSize;
  206. ++shaderInputIndex;
  207. }
  208. groupSize = currentGroupSize;
  209. return true;
  210. }
  211. bool ShaderResourceGroupLayout::Finalize()
  212. {
  213. if (IsFinalized())
  214. {
  215. return true;
  216. }
  217. if (m_bindingSlot.IsNull())
  218. {
  219. AZ_Error("ShaderResourceGroupLayout", false, "You must supply a valid binding slot to ShaderResourceGroupLayoutDescriptor.");
  220. Clear();
  221. return false;
  222. }
  223. if (m_bindingSlot.GetIndex() >= Limits::Pipeline::ShaderResourceGroupCountMax)
  224. {
  225. AZ_Error("ShaderResourceGroupLayout", false,
  226. "Binding index (%d) must be less than the maximum number of allowed shader resource groups (%d)",
  227. m_bindingSlot.GetIndex(), Limits::Pipeline::ShaderResourceGroupCountMax);
  228. Clear();
  229. return false;
  230. }
  231. // Build buffer group
  232. if (!FinalizeShaderInputGroup<IdReflectionMapForBuffers, ShaderInputBufferDescriptor, ShaderInputBufferIndex>(
  233. m_inputsForBuffers, m_intervalsForBuffers, m_idReflectionForBuffers, m_groupSizeForBuffers))
  234. {
  235. return false;
  236. }
  237. // Build image group
  238. if (!FinalizeShaderInputGroup<IdReflectionMapForImages, ShaderInputImageDescriptor, ShaderInputImageIndex>(
  239. m_inputsForImages, m_intervalsForImages, m_idReflectionForImages, m_groupSizeForImages))
  240. {
  241. return false;
  242. }
  243. // Build buffer unbounded array group
  244. if (!FinalizeUnboundedArrayShaderInputGroup<IdReflectionMapForBufferUnboundedArrays, ShaderInputBufferUnboundedArrayDescriptor, ShaderInputBufferUnboundedArrayIndex>(
  245. m_inputsForBufferUnboundedArrays, m_idReflectionForBufferUnboundedArrays, m_groupSizeForBufferUnboundedArrays))
  246. {
  247. return false;
  248. }
  249. // Build image unbounded array group
  250. if (!FinalizeUnboundedArrayShaderInputGroup<IdReflectionMapForImageUnboundedArrays, ShaderInputImageUnboundedArrayDescriptor, ShaderInputImageUnboundedArrayIndex>(
  251. m_inputsForImageUnboundedArrays, m_idReflectionForImageUnboundedArrays, m_groupSizeForImageUnboundedArrays))
  252. {
  253. return false;
  254. }
  255. // Build sampler group
  256. if (!FinalizeShaderInputGroup<IdReflectionMapForSamplers, ShaderInputSamplerDescriptor, ShaderInputSamplerIndex>(
  257. m_inputsForSamplers, m_intervalsForSamplers, m_idReflectionForSamplers, m_groupSizeForSamplers))
  258. {
  259. return false;
  260. }
  261. // Finalize the constants data layout.
  262. if (!m_constantsDataLayout->Finalize())
  263. {
  264. Clear();
  265. return false;
  266. }
  267. if (!m_shaderVariantKeyFallbackConstantId.IsEmpty())
  268. {
  269. m_shaderVariantKeyFallbackConstantIndex = FindShaderInputConstantIndex(m_shaderVariantKeyFallbackConstantId);
  270. if (Validation::IsEnabled())
  271. {
  272. AZ_Assert(m_shaderVariantKeyFallbackConstantIndex.IsValid(), "Failed to find a valid ShaderVariantKey fallback constant index!");
  273. }
  274. }
  275. // Build the final hash based on the inputs.
  276. {
  277. HashValue64 hash = HashValue64{ 0 };
  278. for (const ShaderInputStaticSamplerDescriptor& staticSamplerDescriptor : m_staticSamplers)
  279. {
  280. hash = staticSamplerDescriptor.GetHash(hash);
  281. }
  282. for (const ShaderInputBufferDescriptor& shaderInputBuffer : m_inputsForBuffers)
  283. {
  284. hash = shaderInputBuffer.GetHash(hash);
  285. }
  286. for (const ShaderInputImageDescriptor& shaderInputImage : m_inputsForImages)
  287. {
  288. hash = shaderInputImage.GetHash(hash);
  289. }
  290. for (const ShaderInputBufferUnboundedArrayDescriptor& shaderInputBufferUnboundedArray : m_inputsForBufferUnboundedArrays)
  291. {
  292. hash = shaderInputBufferUnboundedArray.GetHash(hash);
  293. }
  294. for (const ShaderInputImageUnboundedArrayDescriptor& shaderInputImageUnboundedArray : m_inputsForImageUnboundedArrays)
  295. {
  296. hash = shaderInputImageUnboundedArray.GetHash(hash);
  297. }
  298. for (const ShaderInputSamplerDescriptor& shaderInputSampler : m_inputsForSamplers)
  299. {
  300. hash = shaderInputSampler.GetHash(hash);
  301. }
  302. hash = TypeHash64(m_constantsDataLayout->GetHash(), hash);
  303. hash = TypeHash64(m_bindingSlot.GetIndex(), hash);
  304. hash = TypeHash64(m_shaderVariantKeyFallbackSize, hash);
  305. hash = TypeHash64(m_shaderVariantKeyFallbackConstantIndex.GetIndex(), hash);
  306. m_hash = hash;
  307. }
  308. return true;
  309. }
  310. void ShaderResourceGroupLayout::SetShaderVariantKeyFallback(const Name& shaderConstantName, uint32_t bitSize)
  311. {
  312. if (Validation::IsEnabled())
  313. {
  314. AZ_Assert(bitSize > 0, "ShaderVariant fallback must have positive key size!");
  315. AZ_Assert(!shaderConstantName.IsEmpty(), "ShaderVariant fallback must have a valid attribute name!");
  316. }
  317. m_shaderVariantKeyFallbackSize = bitSize;
  318. m_shaderVariantKeyFallbackConstantId = shaderConstantName;
  319. }
  320. uint32_t ShaderResourceGroupLayout::GetShaderVariantKeyFallbackSize() const
  321. {
  322. return m_shaderVariantKeyFallbackSize;
  323. }
  324. bool ShaderResourceGroupLayout::HasShaderVariantKeyFallbackEntry() const
  325. {
  326. return m_shaderVariantKeyFallbackSize > 0;
  327. }
  328. const RHI::ShaderInputConstantIndex& ShaderResourceGroupLayout::GetShaderVariantKeyFallbackConstantIndex() const
  329. {
  330. return m_shaderVariantKeyFallbackConstantIndex;
  331. }
  332. void ShaderResourceGroupLayout::AddStaticSampler(const ShaderInputStaticSamplerDescriptor& sampler)
  333. {
  334. m_staticSamplers.push_back(sampler);
  335. }
  336. void ShaderResourceGroupLayout::AddShaderInput(const ShaderInputBufferDescriptor& buffer)
  337. {
  338. m_inputsForBuffers.push_back(buffer);
  339. }
  340. void ShaderResourceGroupLayout::AddShaderInput(const ShaderInputImageDescriptor& image)
  341. {
  342. m_inputsForImages.push_back(image);
  343. }
  344. void ShaderResourceGroupLayout::AddShaderInput(const ShaderInputBufferUnboundedArrayDescriptor& bufferUnboundedArray)
  345. {
  346. m_inputsForBufferUnboundedArrays.push_back(bufferUnboundedArray);
  347. }
  348. void ShaderResourceGroupLayout::AddShaderInput(const ShaderInputImageUnboundedArrayDescriptor& imageUnboundedArray)
  349. {
  350. m_inputsForImageUnboundedArrays.push_back(imageUnboundedArray);
  351. }
  352. void ShaderResourceGroupLayout::AddShaderInput(const ShaderInputSamplerDescriptor& sampler)
  353. {
  354. m_inputsForSamplers.push_back(sampler);
  355. }
  356. void ShaderResourceGroupLayout::AddShaderInput(const ShaderInputConstantDescriptor& constant)
  357. {
  358. m_constantsDataLayout->AddShaderInput(constant);
  359. }
  360. void ShaderResourceGroupLayout::SetBindingSlot(uint32_t bindingSlot)
  361. {
  362. m_bindingSlot = Handle<uint32_t>(bindingSlot);
  363. }
  364. AZStd::span<const ShaderInputStaticSamplerDescriptor> ShaderResourceGroupLayout::GetStaticSamplers() const
  365. {
  366. return m_staticSamplers;
  367. }
  368. ShaderInputBufferIndex ShaderResourceGroupLayout::FindShaderInputBufferIndex(const Name& name) const
  369. {
  370. return m_idReflectionForBuffers.Find(name);
  371. }
  372. ShaderInputImageIndex ShaderResourceGroupLayout::FindShaderInputImageIndex(const Name& name) const
  373. {
  374. return m_idReflectionForImages.Find(name);
  375. }
  376. ShaderInputSamplerIndex ShaderResourceGroupLayout::FindShaderInputSamplerIndex(const Name& name) const
  377. {
  378. return m_idReflectionForSamplers.Find(name);
  379. }
  380. ShaderInputConstantIndex ShaderResourceGroupLayout::FindShaderInputConstantIndex(const Name& name) const
  381. {
  382. return m_constantsDataLayout->FindShaderInputIndex(name);
  383. }
  384. ShaderInputBufferUnboundedArrayIndex ShaderResourceGroupLayout::FindShaderInputBufferUnboundedArrayIndex(const Name& name) const
  385. {
  386. return m_idReflectionForBufferUnboundedArrays.Find(name);
  387. }
  388. ShaderInputImageUnboundedArrayIndex ShaderResourceGroupLayout::FindShaderInputImageUnboundedArrayIndex(const Name& name) const
  389. {
  390. return m_idReflectionForImageUnboundedArrays.Find(name);
  391. }
  392. const ShaderInputBufferDescriptor& ShaderResourceGroupLayout::GetShaderInput(ShaderInputBufferIndex index) const
  393. {
  394. return m_inputsForBuffers[index.GetIndex()];
  395. }
  396. const ShaderInputImageDescriptor& ShaderResourceGroupLayout::GetShaderInput(ShaderInputImageIndex index) const
  397. {
  398. return m_inputsForImages[index.GetIndex()];
  399. }
  400. const ShaderInputBufferUnboundedArrayDescriptor& ShaderResourceGroupLayout::GetShaderInput(ShaderInputBufferUnboundedArrayIndex index) const
  401. {
  402. return m_inputsForBufferUnboundedArrays[index.GetIndex()];
  403. }
  404. const ShaderInputImageUnboundedArrayDescriptor& ShaderResourceGroupLayout::GetShaderInput(ShaderInputImageUnboundedArrayIndex index) const
  405. {
  406. return m_inputsForImageUnboundedArrays[index.GetIndex()];
  407. }
  408. const ShaderInputSamplerDescriptor& ShaderResourceGroupLayout::GetShaderInput(ShaderInputSamplerIndex index) const
  409. {
  410. return m_inputsForSamplers[index.GetIndex()];
  411. }
  412. const ShaderInputConstantDescriptor& ShaderResourceGroupLayout::GetShaderInput(ShaderInputConstantIndex index) const
  413. {
  414. return m_constantsDataLayout->GetShaderInput(index);
  415. }
  416. AZStd::span<const ShaderInputBufferDescriptor> ShaderResourceGroupLayout::GetShaderInputListForBuffers() const
  417. {
  418. return m_inputsForBuffers;
  419. }
  420. AZStd::span<const ShaderInputImageDescriptor> ShaderResourceGroupLayout::GetShaderInputListForImages() const
  421. {
  422. return m_inputsForImages;
  423. }
  424. AZStd::span<const ShaderInputSamplerDescriptor> ShaderResourceGroupLayout::GetShaderInputListForSamplers() const
  425. {
  426. return m_inputsForSamplers;
  427. }
  428. AZStd::span<const ShaderInputConstantDescriptor> ShaderResourceGroupLayout::GetShaderInputListForConstants() const
  429. {
  430. return m_constantsDataLayout->GetShaderInputList();
  431. }
  432. AZStd::span<const ShaderInputBufferUnboundedArrayDescriptor> ShaderResourceGroupLayout::GetShaderInputListForBufferUnboundedArrays() const
  433. {
  434. return m_inputsForBufferUnboundedArrays;
  435. }
  436. AZStd::span<const ShaderInputImageUnboundedArrayDescriptor> ShaderResourceGroupLayout::GetShaderInputListForImageUnboundedArrays() const
  437. {
  438. return m_inputsForImageUnboundedArrays;
  439. }
  440. Interval ShaderResourceGroupLayout::GetGroupInterval(ShaderInputBufferIndex inputIndex) const
  441. {
  442. return m_intervalsForBuffers[inputIndex.GetIndex()];
  443. }
  444. Interval ShaderResourceGroupLayout::GetGroupInterval(ShaderInputImageIndex inputIndex) const
  445. {
  446. return m_intervalsForImages[inputIndex.GetIndex()];
  447. }
  448. Interval ShaderResourceGroupLayout::GetGroupInterval(ShaderInputSamplerIndex inputIndex) const
  449. {
  450. return m_intervalsForSamplers[inputIndex.GetIndex()];
  451. }
  452. Interval ShaderResourceGroupLayout::GetConstantInterval(ShaderInputConstantIndex inputIndex) const
  453. {
  454. return m_constantsDataLayout->GetInterval(inputIndex);
  455. }
  456. uint32_t ShaderResourceGroupLayout::GetGroupSizeForBuffers() const
  457. {
  458. return m_groupSizeForBuffers;
  459. }
  460. uint32_t ShaderResourceGroupLayout::GetGroupSizeForImages() const
  461. {
  462. return m_groupSizeForImages;
  463. }
  464. uint32_t ShaderResourceGroupLayout::GetGroupSizeForBufferUnboundedArrays() const
  465. {
  466. return m_groupSizeForBufferUnboundedArrays;
  467. }
  468. uint32_t ShaderResourceGroupLayout::GetGroupSizeForImageUnboundedArrays() const
  469. {
  470. return m_groupSizeForImageUnboundedArrays;
  471. }
  472. uint32_t ShaderResourceGroupLayout::GetGroupSizeForSamplers() const
  473. {
  474. return m_groupSizeForSamplers;
  475. }
  476. uint32_t ShaderResourceGroupLayout::GetConstantDataSize() const
  477. {
  478. return m_constantsDataLayout->GetDataSize();
  479. }
  480. uint32_t ShaderResourceGroupLayout::GetBindingSlot() const
  481. {
  482. ValidateFinalizeState(ValidateFinalizeStateExpect::Finalized);
  483. return m_bindingSlot.GetIndex();
  484. }
  485. HashValue64 ShaderResourceGroupLayout::GetHash() const
  486. {
  487. ValidateFinalizeState(ValidateFinalizeStateExpect::Finalized);
  488. return m_hash;
  489. }
  490. const ConstantsLayout* ShaderResourceGroupLayout::GetConstantsLayout() const
  491. {
  492. return m_constantsDataLayout.get();
  493. }
  494. }