Factory.cpp 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226
  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 <Common/RHI/Factory.h>
  9. #include <Common/RHI/Stubs.h>
  10. #include <Atom/RHI/DeviceDispatchRaysIndirectBuffer.h>
  11. #include <Atom/RHI/DeviceRayTracingAccelerationStructure.h>
  12. #include <Atom/RHI/DeviceRayTracingPipelineState.h>
  13. #include <Atom/RHI/DeviceRayTracingShaderTable.h>
  14. #include <Atom/RHI/DeviceRayTracingBufferPools.h>
  15. #include <Atom/RHI/DeviceTransientAttachmentPool.h>
  16. #include <Atom/RHI/FrameGraphExecuter.h>
  17. #include <Atom/RHI/FrameGraphCompiler.h>
  18. #include <Atom/RHI/DevicePipelineState.h>
  19. #include <Atom/RHI/DeviceShaderResourceGroupPool.h>
  20. #include <Atom/RHI/DeviceFence.h>
  21. #include <Atom/RHI/DeviceSwapChain.h>
  22. namespace UnitTest
  23. {
  24. namespace StubRHI
  25. {
  26. using namespace AZ;
  27. Factory::Factory() :
  28. m_platformName{"UnitTest"}
  29. {
  30. RHI::Factory::Register(this);
  31. }
  32. Factory::~Factory()
  33. {
  34. RHI::Factory::Unregister(this);
  35. RHI::ResourceInvalidateBus::AllowFunctionQueuing(false);
  36. RHI::ResourceInvalidateBus::ClearQueuedEvents();
  37. }
  38. RHI::Ptr<RHI::Device> Factory::CreateDefaultDevice()
  39. {
  40. RHI::PhysicalDeviceList physicalDevices = Get().EnumeratePhysicalDevices();
  41. AZ_Assert(physicalDevices.size() == 1, "Expected a single physical device.");
  42. RHI::Ptr<RHI::Device> device = Get().CreateDevice();
  43. device->Init(RHI::MultiDevice::DefaultDeviceIndex, *physicalDevices[0]);
  44. return device;
  45. }
  46. Name Factory::GetName()
  47. {
  48. return m_platformName;
  49. }
  50. RHI::APIPriority Factory::GetDefaultPriority()
  51. {
  52. return RHI::APIMiddlePriority;
  53. }
  54. RHI::APIType Factory::GetType()
  55. {
  56. return RHI::APIType(m_platformName.GetStringView());
  57. }
  58. bool Factory::SupportsXR() const
  59. {
  60. return false;
  61. }
  62. RHI::PhysicalDeviceList Factory::EnumeratePhysicalDevices()
  63. {
  64. return PhysicalDevice::Enumerate();
  65. }
  66. RHI::Ptr<RHI::Device> Factory::CreateDevice()
  67. {
  68. return aznew Device;
  69. }
  70. RHI::Ptr<RHI::DeviceSwapChain> Factory::CreateSwapChain()
  71. {
  72. return aznew SwapChain;
  73. }
  74. RHI::Ptr<RHI::DeviceFence> Factory::CreateFence()
  75. {
  76. return aznew Fence;
  77. }
  78. RHI::Ptr<RHI::DeviceBuffer> Factory::CreateBuffer()
  79. {
  80. return aznew Buffer;
  81. }
  82. RHI::Ptr<RHI::DeviceBufferView> Factory::CreateBufferView()
  83. {
  84. return aznew BufferView;
  85. }
  86. RHI::Ptr<RHI::DeviceBufferPool> Factory::CreateBufferPool()
  87. {
  88. return aznew BufferPool;
  89. }
  90. RHI::Ptr<RHI::DeviceImage> Factory::CreateImage()
  91. {
  92. return aznew Image;
  93. }
  94. RHI::Ptr<RHI::DeviceImageView> Factory::CreateImageView()
  95. {
  96. return aznew ImageView;
  97. }
  98. RHI::Ptr<RHI::DeviceImagePool> Factory::CreateImagePool()
  99. {
  100. return aznew ImagePool;
  101. }
  102. RHI::Ptr<RHI::DeviceStreamingImagePool> Factory::CreateStreamingImagePool()
  103. {
  104. return aznew StreamingImagePool;
  105. }
  106. RHI::Ptr<RHI::DeviceShaderResourceGroupPool> Factory::CreateShaderResourceGroupPool()
  107. {
  108. return aznew ShaderResourceGroupPool;
  109. }
  110. RHI::Ptr<RHI::DeviceShaderResourceGroup> Factory::CreateShaderResourceGroup()
  111. {
  112. return aznew ShaderResourceGroup;
  113. }
  114. RHI::Ptr<RHI::DevicePipelineLibrary> Factory::CreatePipelineLibrary()
  115. {
  116. return aznew PipelineLibrary;
  117. }
  118. RHI::Ptr<RHI::DevicePipelineState> Factory::CreatePipelineState()
  119. {
  120. return aznew PipelineState;
  121. }
  122. RHI::Ptr<RHI::Scope> Factory::CreateScope()
  123. {
  124. return aznew Scope;
  125. }
  126. RHI::Ptr<RHI::FrameGraphCompiler> Factory::CreateFrameGraphCompiler()
  127. {
  128. return aznew FrameGraphCompiler;
  129. }
  130. RHI::Ptr<RHI::FrameGraphExecuter> Factory::CreateFrameGraphExecuter()
  131. {
  132. return aznew FrameGraphExecuter;
  133. }
  134. RHI::Ptr<RHI::DeviceTransientAttachmentPool> Factory::CreateTransientAttachmentPool()
  135. {
  136. return aznew TransientAttachmentPool;
  137. }
  138. AZ::RHI::Ptr<AZ::RHI::DeviceQueryPool> Factory::CreateQueryPool()
  139. {
  140. return aznew QueryPool;
  141. }
  142. AZ::RHI::Ptr<AZ::RHI::DeviceQuery> Factory::CreateQuery()
  143. {
  144. return aznew Query;
  145. }
  146. AZ::RHI::Ptr<AZ::RHI::DeviceIndirectBufferSignature> Factory::CreateIndirectBufferSignature()
  147. {
  148. return aznew IndirectBufferSignature;
  149. }
  150. AZ::RHI::Ptr<AZ::RHI::DeviceIndirectBufferWriter> Factory::CreateIndirectBufferWriter()
  151. {
  152. return aznew IndirectBufferWriter;
  153. }
  154. AZ::RHI::Ptr<AZ::RHI::DeviceRayTracingBufferPools> Factory::CreateRayTracingBufferPools()
  155. {
  156. AZ_Assert(false, "Not implemented");
  157. return nullptr;
  158. }
  159. AZ::RHI::Ptr<AZ::RHI::DeviceRayTracingBlas> Factory::CreateRayTracingBlas()
  160. {
  161. AZ_Assert(false, "Not implemented");
  162. return nullptr;
  163. }
  164. AZ::RHI::Ptr<AZ::RHI::DeviceRayTracingTlas> Factory::CreateRayTracingTlas()
  165. {
  166. AZ_Assert(false, "Not implemented");
  167. return nullptr;
  168. }
  169. AZ::RHI::Ptr<AZ::RHI::DeviceRayTracingPipelineState> Factory::CreateRayTracingPipelineState()
  170. {
  171. AZ_Assert(false, "Not implemented");
  172. return nullptr;
  173. }
  174. AZ::RHI::Ptr<AZ::RHI::DeviceRayTracingShaderTable> Factory::CreateRayTracingShaderTable()
  175. {
  176. AZ_Assert(false, "Not implemented");
  177. return nullptr;
  178. }
  179. RHI::Ptr<RHI::DeviceDispatchRaysIndirectBuffer> Factory::CreateDispatchRaysIndirectBuffer()
  180. {
  181. AZ_Assert(false, "Not implemented");
  182. return nullptr;
  183. }
  184. }
  185. }