Преглед изворни кода

Buffer-related resources

Signed-off-by: Martin Winter <[email protected]>
Martin Winter пре 1 година
родитељ
комит
579dd36db4
51 измењених фајлова са 413 додато и 417 уклоњено
  1. 1 1
      Gem/Code/Source/Passes/RayTracingAmbientOcclusionPass.cpp
  2. 7 7
      Gem/Code/Source/RHI/AlphaToCoverageExampleComponent.cpp
  3. 4 4
      Gem/Code/Source/RHI/AlphaToCoverageExampleComponent.h
  4. 8 8
      Gem/Code/Source/RHI/AsyncComputeExampleComponent.cpp
  5. 3 3
      Gem/Code/Source/RHI/AsyncComputeExampleComponent.h
  6. 44 48
      Gem/Code/Source/RHI/BindlessPrototypeExampleComponent.cpp
  7. 21 21
      Gem/Code/Source/RHI/BindlessPrototypeExampleComponent.h
  8. 16 16
      Gem/Code/Source/RHI/ComputeExampleComponent.cpp
  9. 6 6
      Gem/Code/Source/RHI/ComputeExampleComponent.h
  10. 10 10
      Gem/Code/Source/RHI/CopyQueueComponent.cpp
  11. 5 5
      Gem/Code/Source/RHI/CopyQueueComponent.h
  12. 7 7
      Gem/Code/Source/RHI/DualSourceBlendingComponent.cpp
  13. 2 2
      Gem/Code/Source/RHI/DualSourceBlendingComponent.h
  14. 38 38
      Gem/Code/Source/RHI/IndirectRenderingExampleComponent.cpp
  15. 12 12
      Gem/Code/Source/RHI/IndirectRenderingExampleComponent.h
  16. 9 9
      Gem/Code/Source/RHI/InputAssemblyExampleComponent.cpp
  17. 2 2
      Gem/Code/Source/RHI/InputAssemblyExampleComponent.h
  18. 7 7
      Gem/Code/Source/RHI/MRTExampleComponent.cpp
  19. 3 3
      Gem/Code/Source/RHI/MRTExampleComponent.h
  20. 12 12
      Gem/Code/Source/RHI/MSAAExampleComponent.cpp
  21. 5 5
      Gem/Code/Source/RHI/MSAAExampleComponent.h
  22. 7 7
      Gem/Code/Source/RHI/MatrixAlignmentTestExampleComponent.cpp
  23. 3 3
      Gem/Code/Source/RHI/MatrixAlignmentTestExampleComponent.h
  24. 7 7
      Gem/Code/Source/RHI/MultiThreadComponent.cpp
  25. 4 4
      Gem/Code/Source/RHI/MultiThreadComponent.h
  26. 9 9
      Gem/Code/Source/RHI/MultipleViewsComponent.cpp
  27. 4 4
      Gem/Code/Source/RHI/MultipleViewsComponent.h
  28. 13 13
      Gem/Code/Source/RHI/QueryExampleComponent.cpp
  29. 6 6
      Gem/Code/Source/RHI/QueryExampleComponent.h
  30. 17 17
      Gem/Code/Source/RHI/RayTracingExampleComponent.cpp
  31. 7 7
      Gem/Code/Source/RHI/RayTracingExampleComponent.h
  32. 9 9
      Gem/Code/Source/RHI/SphericalHarmonicsExampleComponent.cpp
  33. 5 5
      Gem/Code/Source/RHI/SphericalHarmonicsExampleComponent.h
  34. 7 7
      Gem/Code/Source/RHI/StencilExampleComponent.cpp
  35. 3 3
      Gem/Code/Source/RHI/StencilExampleComponent.h
  36. 1 1
      Gem/Code/Source/RHI/SubpassExampleComponent.h
  37. 1 1
      Gem/Code/Source/RHI/Texture3dExampleComponent.h
  38. 7 7
      Gem/Code/Source/RHI/TextureArrayExampleComponent.cpp
  39. 2 2
      Gem/Code/Source/RHI/TextureArrayExampleComponent.h
  40. 9 9
      Gem/Code/Source/RHI/TextureExampleComponent.cpp
  41. 5 5
      Gem/Code/Source/RHI/TextureExampleComponent.h
  42. 9 9
      Gem/Code/Source/RHI/TextureMapExampleComponent.cpp
  43. 4 4
      Gem/Code/Source/RHI/TextureMapExampleComponent.h
  44. 7 7
      Gem/Code/Source/RHI/TriangleExampleComponent.cpp
  45. 3 3
      Gem/Code/Source/RHI/TriangleExampleComponent.h
  46. 16 16
      Gem/Code/Source/RHI/TrianglesConstantBufferExampleComponent.cpp
  47. 6 6
      Gem/Code/Source/RHI/TrianglesConstantBufferExampleComponent.h
  48. 7 7
      Gem/Code/Source/RHI/VariableRateShadingExampleComponent.cpp
  49. 3 3
      Gem/Code/Source/RHI/VariableRateShadingExampleComponent.h
  50. 7 7
      Gem/Code/Source/RHI/XRExampleComponent.cpp
  51. 3 3
      Gem/Code/Source/RHI/XRExampleComponent.h

+ 1 - 1
Gem/Code/Source/Passes/RayTracingAmbientOcclusionPass.cpp

@@ -162,7 +162,7 @@ namespace AZ
             RHI::ShaderInputConstantIndex constantIndex;
 
             // Bind scene TLAS buffer
-            const RHI::Ptr<RHI::SingleDeviceBuffer> tlasBuffer = m_rayTracingFeatureProcessor->GetTlas()->GetTlasBuffer();
+            auto tlasBuffer = m_rayTracingFeatureProcessor->GetTlas()->GetTlasBuffer();
             if (tlasBuffer)
             {
                 // TLAS

+ 7 - 7
Gem/Code/Source/RHI/AlphaToCoverageExampleComponent.cpp

@@ -50,12 +50,12 @@ namespace AtomSampleViewer
     {
         using namespace AZ;
         RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
-        m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+        m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         m_depthImageAttachmentId = RHI::AttachmentId("A2C_Depth");
         m_multisamleDepthImageAttachmentId = RHI::AttachmentId("A2C_MSAA_Depth");
@@ -145,10 +145,10 @@ namespace AtomSampleViewer
         RectangleBufferData bufferData;
         SetFullScreenRect(bufferData.m_positions.data(), bufferData.m_uvs.data(), bufferData.m_indices.data());
 
-        m_rectangleInputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_rectangleInputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
         RHI::ResultCode result = RHI::ResultCode::Success;
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_rectangleInputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{RHI::BufferBindFlags::InputAssembly, sizeof(bufferData)};
         request.m_initialData = &bufferData;
@@ -160,14 +160,14 @@ namespace AtomSampleViewer
         }
         
         m_rectangleStreamBufferViews[0] = {
-            *m_rectangleInputAssemblyBuffer,
+            *m_rectangleInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(RectangleBufferData, m_positions),
             sizeof(RectangleBufferData::m_positions),
             sizeof(VertexPosition)
         };
         
         m_rectangleStreamBufferViews[1] = {
-            *m_rectangleInputAssemblyBuffer,
+            *m_rectangleInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(RectangleBufferData, m_uvs),
             sizeof(RectangleBufferData::m_uvs),
             sizeof(VertexUV)
@@ -400,7 +400,7 @@ namespace AtomSampleViewer
 
                 const RHI::SingleDeviceIndexBufferView indexBufferView =
                 {
-                    *m_rectangleInputAssemblyBuffer,
+                    *m_rectangleInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(RectangleBufferData, m_indices),
                     sizeof(RectangleBufferData::m_indices),
                     RHI::IndexFormat::Uint16

+ 4 - 4
Gem/Code/Source/RHI/AlphaToCoverageExampleComponent.h

@@ -18,8 +18,8 @@
 #include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h>
 #include <Atom/RHI.Reflect/ScopeId.h>
 
-#include <Atom/RHI/SingleDeviceBuffer.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBuffer.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
 #include <Atom/RHI/SingleDeviceStreamBufferView.h>
@@ -91,8 +91,8 @@ namespace AtomSampleViewer
             AZStd::array<VertexUV, 4> m_uvs;
             AZStd::array<uint16_t, 6> m_indices;
         };
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_rectangleInputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_rectangleInputAssemblyBuffer;
         AZStd::array<AZ::RHI::SingleDeviceStreamBufferView, 2> m_rectangleStreamBufferViews;
         AZ::RHI::InputStreamLayout m_rectangleInputStreamLayout;
 

+ 8 - 8
Gem/Code/Source/RHI/AsyncComputeExampleComponent.cpp

@@ -171,11 +171,11 @@ namespace AtomSampleViewer
     {
         const RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
 
-        m_quadBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_quadBufferPool = aznew RHI::MultiDeviceBufferPool();
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_quadBufferPool->Init(*device, bufferPoolDesc);
+        m_quadBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         struct BufferData
         {
@@ -193,9 +193,9 @@ namespace AtomSampleViewer
             uv.m_uv[1] = 1.0f - uv.m_uv[1];
         }
 
-        m_quadInputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_quadInputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
         RHI::ResultCode result = RHI::ResultCode::Success;
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
 
         request.m_buffer = m_quadInputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
@@ -209,7 +209,7 @@ namespace AtomSampleViewer
 
         AZ::RHI::SingleDeviceStreamBufferView positionsBufferView =
         {
-            *m_quadInputAssemblyBuffer,
+            *m_quadInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_positions),
             sizeof(BufferData::m_positions),
             sizeof(VertexPosition)
@@ -217,7 +217,7 @@ namespace AtomSampleViewer
 
         AZ::RHI::SingleDeviceStreamBufferView normalsBufferView =
         {
-            *m_quadInputAssemblyBuffer,
+            *m_quadInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_normals),
             sizeof(BufferData::m_normals),
             sizeof(VertexNormal)
@@ -225,7 +225,7 @@ namespace AtomSampleViewer
 
         AZ::RHI::SingleDeviceStreamBufferView uvsBufferView =
         {
-            *m_quadInputAssemblyBuffer,
+            *m_quadInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_uvs),
             sizeof(BufferData::m_uvs),
             sizeof(VertexUV)
@@ -240,7 +240,7 @@ namespace AtomSampleViewer
 
         m_quadIndexBufferView =
         {
-            *m_quadInputAssemblyBuffer,
+            *m_quadInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_indices),
             sizeof(BufferData::m_indices),
             RHI::IndexFormat::Uint16

+ 3 - 3
Gem/Code/Source/RHI/AsyncComputeExampleComponent.h

@@ -8,7 +8,7 @@
 
 #pragma once
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/ScopeProducer.h>
 
@@ -120,8 +120,8 @@ namespace AtomSampleViewer
         };
        
         // Quad related variables
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_quadBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_quadInputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_quadBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_quadInputAssemblyBuffer;
         AZ::RHI::SingleDeviceIndexBufferView m_quadIndexBufferView;
         AZStd::array<AZStd::vector<AZ::RHI::SingleDeviceStreamBufferView>, NumScopes> m_quadStreamBufferViews;
 

+ 44 - 48
Gem/Code/Source/RHI/BindlessPrototypeExampleComponent.cpp

@@ -220,25 +220,25 @@ namespace AtomSampleViewer
         const RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
         //Create Buffer pool for read only buffers
         {
-            m_bufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_bufferPool = aznew RHI::MultiDeviceBufferPool();
             m_bufferPool->SetName(Name("BindlessBufferPool"));
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::ShaderRead;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
             bufferPoolDesc.m_hostMemoryAccess = RHI::HostMemoryAccess::Write;
             bufferPoolDesc.m_budgetInBytes = m_poolSizeInBytes;
-            [[maybe_unused]] RHI::ResultCode resultCode = m_bufferPool->Init(*device, bufferPoolDesc);
+            [[maybe_unused]] RHI::ResultCode resultCode = m_bufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
             AZ_Assert(resultCode == RHI::ResultCode::Success, "Failed to create Material Buffer Pool");
         }
 
         // Create Buffer pool for read write buffers
         {
-            m_computeBufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_computeBufferPool = aznew RHI::MultiDeviceBufferPool();
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
             bufferPoolDesc.m_hostMemoryAccess = RHI::HostMemoryAccess::Write;
-            [[maybe_unused]] RHI::ResultCode result = m_computeBufferPool->Init(*device, bufferPoolDesc);
+            [[maybe_unused]] RHI::ResultCode result = m_computeBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
             AZ_Assert(result == RHI::ResultCode::Success, "Failed to initialized compute buffer pool");
         }
 
@@ -254,9 +254,9 @@ namespace AtomSampleViewer
 
     void BindlessPrototypeExampleComponent::FloatBuffer::CreateBufferFromPool(const uint32_t byteCount)
     {
-        m_buffer = RHI::Factory::Get().CreateBuffer();
+        m_buffer = aznew RHI::MultiDeviceBuffer();
         m_buffer->SetName(Name("FloatBuffer"));
-        RHI::SingleDeviceBufferInitRequest bufferRequest;
+        RHI::MultiDeviceBufferInitRequest bufferRequest;
         bufferRequest.m_descriptor.m_bindFlags = RHI::BufferBindFlags::ShaderRead;
         bufferRequest.m_descriptor.m_byteCount = byteCount;
         bufferRequest.m_buffer = m_buffer.get();
@@ -267,13 +267,13 @@ namespace AtomSampleViewer
 
     void BindlessPrototypeExampleComponent::CreateIndirectBuffer(
         const Name& bufferName,
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer>& indirectionBuffer,
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView>& bufferView, 
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer>& indirectionBuffer,
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView>& bufferView, 
         size_t byteSize)
     {
-        indirectionBuffer = RHI::Factory::Get().CreateBuffer();
+        indirectionBuffer = aznew RHI::MultiDeviceBuffer();
         indirectionBuffer->SetName(bufferName);
-        RHI::SingleDeviceBufferInitRequest bufferRequest;
+        RHI::MultiDeviceBufferInitRequest bufferRequest;
         bufferRequest.m_descriptor.m_bindFlags = RHI::BufferBindFlags::ShaderRead;
         bufferRequest.m_descriptor.m_byteCount = byteSize;
         bufferRequest.m_buffer = indirectionBuffer.get();
@@ -282,14 +282,14 @@ namespace AtomSampleViewer
 
         RHI::BufferViewDescriptor viewDesc =
             RHI::BufferViewDescriptor::CreateRaw(0, aznumeric_cast<uint32_t>(bufferRequest.m_descriptor.m_byteCount));
-        bufferView = indirectionBuffer->GetBufferView(viewDesc);
+        bufferView = indirectionBuffer->BuildBufferView(viewDesc);
     }
 
     void BindlessPrototypeExampleComponent::CreateColorBuffer(
         const Name& bufferName,
         const AZ::Vector4& colorVal, 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer>& buffer, 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView>& bufferView)
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer>& buffer, 
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView>& bufferView)
     {
         AZStd::array<float, 4> randColors;
         randColors[0] = colorVal.GetX();
@@ -297,9 +297,9 @@ namespace AtomSampleViewer
         randColors[2] = colorVal.GetZ();
         randColors[3] = colorVal.GetW();
 
-        buffer = RHI::Factory::Get().CreateBuffer();
+        buffer = aznew RHI::MultiDeviceBuffer();
         buffer->SetName(bufferName);
-        RHI::SingleDeviceBufferInitRequest bufferRequest;
+        RHI::MultiDeviceBufferInitRequest bufferRequest;
         bufferRequest.m_descriptor.m_bindFlags = RHI::BufferBindFlags::ShaderRead;
         bufferRequest.m_descriptor.m_byteCount = sizeof(float) * 4;
         bufferRequest.m_buffer = buffer.get();
@@ -309,7 +309,7 @@ namespace AtomSampleViewer
 
         RHI::BufferViewDescriptor viewDesc =
             RHI::BufferViewDescriptor::CreateRaw(0, aznumeric_cast<uint32_t>(bufferRequest.m_descriptor.m_byteCount));
-        bufferView = buffer->GetBufferView(viewDesc);
+        bufferView = buffer->BuildBufferView(viewDesc);
     }
 
     void BindlessPrototypeExampleComponent::ClearObjects()
@@ -347,7 +347,7 @@ namespace AtomSampleViewer
             auto uvAssetBufferView{ m_model->GetModelAsset()->GetLodAssets()[lodModel]->GetMeshes()[subMeshIdx].GetSemanticBufferAssetView(
                 AZ::Name{ "UV" }) };
             auto rpiUVBuffer{ AZ::RPI::Buffer::FindOrCreate(uvAssetBufferView->GetBufferAsset()) };
-            const RHI::SingleDeviceBufferView* uvBufferView = rpiUVBuffer->GetBufferView();
+            const auto* uvBufferView = rpiUVBuffer->GetBufferView();
             uint32_t uvBufferByteOffset =
                 uvAssetBufferView->GetBufferViewDescriptor().m_elementSize * uvAssetBufferView->GetBufferViewDescriptor().m_elementOffset;
 
@@ -356,7 +356,7 @@ namespace AtomSampleViewer
 
             subMeshInstance.m_perSubMeshSrg = CreateShaderResourceGroup(m_shader, "HandleSrg", InternalBP::SampleName);
             subMeshInstance.m_mesh = &mesh;
-            subMeshInstance.m_uvBufferIndex = uvBufferView->GetBindlessReadIndex();
+            subMeshInstance.m_uvBufferIndex = uvBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex)->GetBindlessReadIndex();
             subMeshInstance.m_uvBufferByteOffset = uvBufferByteOffset;
 
             // Set the buffer stream
@@ -507,13 +507,9 @@ namespace AtomSampleViewer
             const uint32_t byteCount = m_bufferFloatCount * static_cast<uint32_t>(sizeof(float));
             m_floatBuffer = std::make_unique<FloatBuffer>(FloatBuffer(m_bufferPool, byteCount));
 
-            AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> bufferView = RHI::Factory::Get().CreateBufferView();
-            {
-                bufferView->SetName(Name(m_floatBufferSrgName));
-                RHI::BufferViewDescriptor bufferViewDesc = RHI::BufferViewDescriptor::CreateStructured(0u, m_bufferFloatCount, sizeof(float));
-                [[maybe_unused]] RHI::ResultCode resultCode = bufferView->Init(*m_floatBuffer->m_buffer, bufferViewDesc);
-                AZ_Assert(resultCode == RHI::ResultCode::Success, "Failed to initialize buffer view");
-            }
+            RHI::BufferViewDescriptor bufferViewDesc = RHI::BufferViewDescriptor::CreateStructured(0u, m_bufferFloatCount, sizeof(float));
+            AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> bufferView = m_floatBuffer->m_buffer->BuildBufferView(bufferViewDesc);
+            bufferView->SetName(Name(m_floatBufferSrgName));
             m_bindlessSrg->SetBufferView(m_floatBufferSrgName, floatBufferId, bufferView.get());
 
             // Compile the float buffer SRG
@@ -587,18 +583,18 @@ namespace AtomSampleViewer
 
         // Set the color multiplier buffer
         {
-            m_computeBuffer = RHI::Factory::Get().CreateBuffer();
+            m_computeBuffer = aznew RHI::MultiDeviceBuffer();
             m_computeBuffer->SetName(Name("m_colorBufferMultiplier"));
             uint32_t bufferSize = sizeof(uint32_t);//RHI ::GetFormatSize(RHI::Format::R32G32B32A32_FLOAT);
 
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_computeBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::ShaderReadWrite, bufferSize };
             [[maybe_unused]] RHI::ResultCode result = m_computeBufferPool->InitBuffer(request);
             AZ_Assert(result == RHI::ResultCode::Success, "Failed to initialized compute buffer");
 
             m_rwBufferViewDescriptor = RHI::BufferViewDescriptor::CreateRaw(0, bufferSize);
-            m_computeBufferView = m_computeBuffer->GetBufferView(m_rwBufferViewDescriptor);
+            m_computeBufferView = m_computeBuffer->BuildBufferView(m_rwBufferViewDescriptor);
         }
 
         // Set the image version of color multiplier buffer
@@ -748,9 +744,9 @@ namespace AtomSampleViewer
         // Indirect buffer that will contain indices for all read only textures and read write textures within the bindless heap
         {
             //Read only textures = InternalBP::Images , InternalBP::CubeMapImages, m_computeImageView
-            RHI::SingleDeviceBufferMapRequest mapRequest{ *m_imageIndirectionBuffer, 0,
+            RHI::MultiDeviceBufferMapRequest mapRequest{ *m_imageIndirectionBuffer, 0,
                                               sizeof(uint32_t) * (InternalBP::ImageCount + InternalBP::CubeMapImageCount + 1) };
-            RHI::SingleDeviceBufferMapResponse mapResponse;
+            RHI::MultiDeviceBufferMapResponse mapResponse;
             m_bufferPool->MapBuffer(mapRequest, mapResponse);
 
             AZStd::vector<const RHI::SingleDeviceImageView*> views;
@@ -778,7 +774,7 @@ namespace AtomSampleViewer
             uint32_t arrayIndex = 0;
             auto indirectionBufferIndex = indirectionBufferSrg->FindShaderInputBufferIndex(AZ::Name{ "m_imageIndirectionBuffer" });
             indirectionBufferSrg->SetBindlessViews(
-                indirectionBufferIndex, m_imageIndirectionBufferView.get(), views, static_cast<uint32_t*>(mapResponse.m_data),
+                indirectionBufferIndex, m_imageIndirectionBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get(), views, static_cast<uint32_t*>(mapResponse.m_data[RHI::MultiDevice::DefaultDeviceIndex]),
                 isViewReadOnly, arrayIndex);
 
             m_bufferPool->UnmapBuffer(*m_imageIndirectionBuffer);
@@ -786,28 +782,28 @@ namespace AtomSampleViewer
 
         // Indirect buffer that will contain indices for all read only buffers and read write buffers within the bindless heap
         {
-            RHI::SingleDeviceBufferMapRequest mapRequest{ *m_bufferIndirectionBuffer, 0, sizeof(uint32_t) * 3 };
-            RHI::SingleDeviceBufferMapResponse mapResponse;
+            RHI::MultiDeviceBufferMapRequest mapRequest{ *m_bufferIndirectionBuffer, 0, sizeof(uint32_t) * 3 };
+            RHI::MultiDeviceBufferMapResponse mapResponse;
             m_bufferPool->MapBuffer(mapRequest, mapResponse);
 
             AZStd::vector<const RHI::SingleDeviceBufferView*> views;
             AZStd::vector<bool> isViewReadOnly;
            
             // Add read only buffer views
-            views.push_back(m_colorBuffer1View.get());
+            views.push_back(m_colorBuffer1View->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get());
             isViewReadOnly.push_back(true);
-            views.push_back(m_colorBuffer2View.get());
+            views.push_back(m_colorBuffer2View->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get());
             isViewReadOnly.push_back(true);
 
             //Add read write buffer view
-            views.push_back(m_computeBufferView.get());
+            views.push_back(m_computeBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get());
             isViewReadOnly.push_back(false);
 
             //Populate the indirect buffer with indices of the views that reside within the bindless heap
             uint32_t arrayIndex = 0;
             auto indirectionBufferIndex = indirectionBufferSrg->FindShaderInputBufferIndex(AZ::Name{ "m_bufferIndirectionBuffer" });
             indirectionBufferSrg->SetBindlessViews(
-                indirectionBufferIndex, m_bufferIndirectionBufferView.get(), views, static_cast<uint32_t*>(mapResponse.m_data),
+                indirectionBufferIndex, m_bufferIndirectionBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get(), views, static_cast<uint32_t*>(mapResponse.m_data[RHI::MultiDevice::DefaultDeviceIndex]),
                 isViewReadOnly, arrayIndex);
 
             m_bufferPool->UnmapBuffer(*m_bufferIndirectionBuffer);
@@ -848,17 +844,17 @@ namespace AtomSampleViewer
         srg->Compile();
     }
 
-    bool BindlessPrototypeExampleComponent::BindlessSrg::SetBufferView(const AZStd::string srgName, const AZStd::string srgId, const AZ::RHI::SingleDeviceBufferView* bufferView)
+    bool BindlessPrototypeExampleComponent::BindlessSrg::SetBufferView(const AZStd::string srgName, const AZStd::string srgId, const AZ::RHI::MultiDeviceBufferView* bufferView)
     {
         AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> srg = GetSrg(srgName);
         const AZ::RHI::ShaderInputBufferIndex inputIndex = srg->FindShaderInputBufferIndex(AZ::Name(srgId));
-        [[maybe_unused]] bool set = srg->SetBufferView(inputIndex, bufferView);
+        [[maybe_unused]] bool set = srg->SetBufferView(inputIndex, bufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get());
         AZ_Assert(set, "Failed to set the buffer view");
 
         return false;
     }
 
-    BindlessPrototypeExampleComponent::FloatBuffer::FloatBuffer(RHI::Ptr<RHI::SingleDeviceBufferPool> bufferPool, const uint32_t sizeInBytes)
+    BindlessPrototypeExampleComponent::FloatBuffer::FloatBuffer(RHI::Ptr<RHI::MultiDeviceBufferPool> bufferPool, const uint32_t sizeInBytes)
     {
         m_bufferPool = bufferPool;
 
@@ -896,7 +892,7 @@ namespace AtomSampleViewer
         const uint32_t alignedDataSize = RHI::AlignUp(sizeInBytes, FloatSizeInBytes);
         AZ_Assert(m_allocatedInBytes + alignedDataSize < m_totalSizeInBytes, "Allocating too much data in the FLoatBuffer");
 
-        const RHI::SingleDeviceBufferMapRequest mapRequest(*m_buffer, m_allocatedInBytes, sizeInBytes);
+        const RHI::MultiDeviceBufferMapRequest mapRequest(*m_buffer, m_allocatedInBytes, sizeInBytes);
         MapData(mapRequest, data);
 
         // Create the handle
@@ -911,19 +907,19 @@ namespace AtomSampleViewer
 
     bool BindlessPrototypeExampleComponent::FloatBuffer::UpdateBuffer(const FloatBufferHandle& handle, const void* data, const uint32_t sizeInBytes)
     {
-        const RHI::SingleDeviceBufferMapRequest mapRequest(*m_buffer, handle.GetIndex() * FloatSizeInBytes, sizeInBytes);
+        const RHI::MultiDeviceBufferMapRequest mapRequest(*m_buffer, handle.GetIndex() * FloatSizeInBytes, sizeInBytes);
         return MapData(mapRequest, data);
     }
 
-    bool BindlessPrototypeExampleComponent::FloatBuffer::MapData(const RHI::SingleDeviceBufferMapRequest& mapRequest, const void* data)
+    bool BindlessPrototypeExampleComponent::FloatBuffer::MapData(const RHI::MultiDeviceBufferMapRequest& mapRequest, const void* data)
     {
-        RHI::SingleDeviceBufferMapResponse response;
+        RHI::MultiDeviceBufferMapResponse response;
         [[maybe_unused]] RHI::ResultCode result = m_bufferPool->MapBuffer(mapRequest, response);
         // ResultCode::Unimplemented is used by Null Renderer and hence is a valid use case
         AZ_Assert(result == RHI::ResultCode::Success || result == RHI::ResultCode::Unimplemented, "Failed to map object buffer]");
-        if (response.m_data)
+        if (!response.m_data.empty())
         {
-            memcpy(response.m_data, data, mapRequest.m_byteCount);
+            memcpy(response.m_data[RHI::MultiDevice::DefaultDeviceIndex], data, mapRequest.m_byteCount);
             m_bufferPool->UnmapBuffer(*m_buffer);
             return true;
         }
@@ -1019,7 +1015,7 @@ namespace AtomSampleViewer
             // attach compute buffer
             {
                 [[maybe_unused]] RHI::ResultCode result =
-                    frameGraph.GetAttachmentDatabase().ImportBuffer(m_bufferAttachmentId, m_computeBuffer);
+                    frameGraph.GetAttachmentDatabase().ImportBuffer(m_bufferAttachmentId, m_computeBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex));
                 AZ_Error(
                     InternalBP::SampleName, result == RHI::ResultCode::Success, "Failed to import compute buffer with error %d", result);
 
@@ -1035,7 +1031,7 @@ namespace AtomSampleViewer
                 AZ_Error(
                     InternalBP::SampleName, computeBufferIndex.IsValid(), "Failed to find shader input buffer %s.",
                     computeBufferId.GetCStr());
-                m_bufferDispatchSRG->SetBufferView(computeBufferIndex, m_computeBufferView.get());
+                m_bufferDispatchSRG->SetBufferView(computeBufferIndex, m_computeBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get());
                 m_bufferDispatchSRG->Compile();
             }
 

+ 21 - 21
Gem/Code/Source/RHI/BindlessPrototypeExampleComponent.h

@@ -59,7 +59,7 @@ namespace AtomSampleViewer
 
             AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> GetSrg(const AZStd::string srgName);
             void CompileSrg(const AZStd::string srgName);
-            bool SetBufferView(const AZStd::string srgName, const AZStd::string srgId, const AZ::RHI::SingleDeviceBufferView* bufferView);
+            bool SetBufferView(const AZStd::string srgName, const AZStd::string srgId, const AZ::RHI::MultiDeviceBufferView* bufferView);
 
         private:
             AZStd::unordered_map<AZ::Name, AZ::Data::Instance<AZ::RPI::ShaderResourceGroup>> m_srgMap;
@@ -90,7 +90,7 @@ namespace AtomSampleViewer
         {
             static const uint32_t FloatSizeInBytes = static_cast<uint32_t>(sizeof(float));
         public:
-            FloatBuffer(AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> bufferPool, const uint32_t sizeInBytes);
+            FloatBuffer(AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> bufferPool, const uint32_t sizeInBytes);
             ~FloatBuffer();
 
             // Allocates data if the provided handle is empty, else it updates it
@@ -103,14 +103,14 @@ namespace AtomSampleViewer
             bool UpdateBuffer(const FloatBufferHandle& handle, const void* data, const uint32_t sizeInBytes);
 
             // Maps host data to the device
-            bool MapData(const AZ::RHI::SingleDeviceBufferMapRequest& mapRequest, const void* data);
+            bool MapData(const AZ::RHI::MultiDeviceBufferMapRequest& mapRequest, const void* data);
 
             // Create the buffer
             void CreateBufferFromPool(const uint32_t byteCount);
 
             // Buffer resource
-            AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool = nullptr;
-            AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_buffer = nullptr;
+            AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool = nullptr;
+            AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_buffer = nullptr;
 
             // Number of bytes that are allocated
             uint32_t m_allocatedInBytes = 0;
@@ -180,14 +180,14 @@ namespace AtomSampleViewer
         void CreateColorBuffer(
             const AZ::Name& bufferName,
             const AZ::Vector4& colorVal,
-            AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer>& buffer,
-            AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView>& bufferView);
+            AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer>& buffer,
+            AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView>& bufferView);
 
         // Create indirect buffer that will contain index of the view into the bindless heap
         void CreateIndirectBuffer(
             const AZ::Name& bufferName,
-            AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer>& indirectionBuffer,
-            AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView>& bufferView,
+            AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer>& indirectionBuffer,
+            AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView>& bufferView,
             size_t byteSize);
 
         // Helper function to allocate or update data in the FloatBuffer
@@ -276,23 +276,23 @@ namespace AtomSampleViewer
         AZ::Data::Instance<AZ::RPI::Model> m_model = nullptr;
 
         // BufferPool used to allocate buffers in this example
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool = nullptr;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool = nullptr;
 
         // Indirection buffer holding uint indices of texture resources
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_imageIndirectionBuffer = nullptr;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_imageIndirectionBuffer = nullptr;
         // Indirection buffer holding uint indices of buffer resources
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_bufferIndirectionBuffer = nullptr;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_bufferIndirectionBuffer = nullptr;
         // View associated with the buffer holding indices to bindless images
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> m_imageIndirectionBufferView = nullptr;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> m_imageIndirectionBufferView = nullptr;
         // View associated with the buffer holding indices to bindless buffers
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> m_bufferIndirectionBufferView = nullptr;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> m_bufferIndirectionBufferView = nullptr;
 
         // Color buffer holding color related floats
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_colorBuffer1 = nullptr;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_colorBuffer2 = nullptr;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_colorBuffer1 = nullptr;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_colorBuffer2 = nullptr;
         // Views related to the buffers declared above
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> m_colorBuffer1View = nullptr;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> m_colorBuffer2View = nullptr;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> m_colorBuffer1View = nullptr;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> m_colorBuffer2View = nullptr;
 
         // Thread count for compute shaders.
         int m_bufferNumThreadsX = 1;
@@ -332,9 +332,9 @@ namespace AtomSampleViewer
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_imageDispatchPipelineState;
         
         // Compute pass related buffer pool which will create a rwbuffer
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_computeBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_computeBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> m_computeBufferView;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_computeBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_computeBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> m_computeBufferView;
         AZ::RHI::BufferViewDescriptor m_rwBufferViewDescriptor;
 
          // Compute pass related image pool which will create a rwimage

+ 16 - 16
Gem/Code/Source/RHI/ComputeExampleComponent.cpp

@@ -103,19 +103,19 @@ namespace AtomSampleViewer
         using namespace AZ;
         RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
 
-        m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+        m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         BufferData bufferData;
         SetFullScreenRect(bufferData.m_positions.data(), bufferData.m_uvs.data(), bufferData.m_indices.data());
 
-        m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_inputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
         request.m_initialData = &bufferData;
@@ -123,7 +123,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[0] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_positions),
             sizeof(BufferData::m_positions),
             sizeof(VertexPosition)
@@ -131,7 +131,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[1] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_uvs),
             sizeof(BufferData::m_uvs),
             sizeof(VertexUV)
@@ -139,7 +139,7 @@ namespace AtomSampleViewer
 
         m_indexBufferView =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_indices),
             sizeof(BufferData::m_indices),
             RHI::IndexFormat::Uint16
@@ -235,20 +235,20 @@ namespace AtomSampleViewer
         RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
 
         [[maybe_unused]] RHI::ResultCode result = RHI::ResultCode::Success;
-        m_computeBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_computeBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::ShaderReadWrite;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
         bufferPoolDesc.m_hostMemoryAccess = RHI::HostMemoryAccess::Write;
 
-        result = m_computeBufferPool->Init(*device, bufferPoolDesc);
+        result = m_computeBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
         AZ_Assert(result == RHI::ResultCode::Success, "Failed to initialized compute buffer pool");
 
-        m_computeBuffer = RHI::Factory::Get().CreateBuffer();
+        m_computeBuffer = aznew RHI::MultiDeviceBuffer();
         uint32_t bufferSize = m_bufferWidth * m_bufferHeight * RHI::GetFormatSize(RHI::Format::R32G32B32A32_FLOAT);
 
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_computeBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::ShaderReadWrite, bufferSize };
         result = m_computeBufferPool->InitBuffer(request);
@@ -256,13 +256,13 @@ namespace AtomSampleViewer
 
         
         m_bufferViewDescriptor = RHI::BufferViewDescriptor::CreateStructured(0, m_bufferWidth * m_bufferHeight, RHI::GetFormatSize(RHI::Format::R32G32B32A32_FLOAT));
-        m_computeBufferView = m_computeBuffer->GetBufferView(m_bufferViewDescriptor);
+        m_computeBufferView = m_computeBuffer->BuildBufferView(m_bufferViewDescriptor);
                   
         if(!m_computeBufferView.get())
         {
             AZ_Assert(false, "Failed to initialized compute buffer view");
         }
-        AZ_Assert(m_computeBufferView->IsFullView(), "compute Buffer View initialization failed to cover in full the Compute Buffer");
+        AZ_Assert(m_computeBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex)->IsFullView(), "compute Buffer View initialization failed to cover in full the Compute Buffer");
 
     }
 
@@ -279,7 +279,7 @@ namespace AtomSampleViewer
         {
             // attach compute buffer
             {
-                [[maybe_unused]] RHI::ResultCode result = frameGraph.GetAttachmentDatabase().ImportBuffer(m_bufferAttachmentId, m_computeBuffer);
+                [[maybe_unused]] RHI::ResultCode result = frameGraph.GetAttachmentDatabase().ImportBuffer(m_bufferAttachmentId, m_computeBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex));
                 AZ_Error(s_computeExampleName, result == RHI::ResultCode::Success, "Failed to import compute buffer with error %d", result);
 
                 RHI::BufferScopeAttachmentDescriptor desc;
@@ -292,7 +292,7 @@ namespace AtomSampleViewer
                 const Name computeBufferId{ "m_computeBuffer" };
                 RHI::ShaderInputBufferIndex computeBufferIndex = m_dispatchSRGs[1]->FindShaderInputBufferIndex(computeBufferId);
                 AZ_Error(s_computeExampleName, computeBufferIndex.IsValid(), "Failed to find shader input buffer %s.", computeBufferId.GetCStr());
-                m_dispatchSRGs[1]->SetBufferView(computeBufferIndex, m_computeBufferView.get());
+                m_dispatchSRGs[1]->SetBufferView(computeBufferIndex, m_computeBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get());
                 m_dispatchSRGs[1]->Compile();
             }
 
@@ -376,7 +376,7 @@ namespace AtomSampleViewer
                 const Name computeBufferId{ "m_computeBuffer" };
                 RHI::ShaderInputBufferIndex computeBufferIndex = m_drawSRGs[1]->FindShaderInputBufferIndex(computeBufferId);
                 AZ_Error(s_computeExampleName, computeBufferIndex.IsValid(), "Failed to find shader input buffer %s.", computeBufferId.GetCStr());
-                m_drawSRGs[1]->SetBufferView(computeBufferIndex, m_computeBufferView.get());
+                m_drawSRGs[1]->SetBufferView(computeBufferIndex, m_computeBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get());
                 m_drawSRGs[1]->Compile();
             }
 

+ 6 - 6
Gem/Code/Source/RHI/ComputeExampleComponent.h

@@ -8,7 +8,7 @@
 
 #pragma once
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/ScopeProducer.h>
 
@@ -80,8 +80,8 @@ namespace AtomSampleViewer
             AZStd::array<uint16_t, 6> m_indices;
         };
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         AZStd::array<AZ::RHI::SingleDeviceStreamBufferView, 2> m_streamBufferViews;
         AZ::RHI::SingleDeviceIndexBufferView m_indexBufferView;
@@ -90,9 +90,9 @@ namespace AtomSampleViewer
         // ----------------------------
         // Compute Buffer
         // ----------------------------
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_computeBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_computeBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> m_computeBufferView;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_computeBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_computeBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> m_computeBufferView;
         AZ::RHI::BufferViewDescriptor m_bufferViewDescriptor;
         AZ::RHI::AttachmentId m_bufferAttachmentId = AZ::RHI::AttachmentId("bufferAttachmentId");
 

+ 10 - 10
Gem/Code/Source/RHI/CopyQueueComponent.cpp

@@ -78,12 +78,12 @@ namespace AtomSampleViewer
         AZ::RHI::PipelineStateDescriptorForDraw pipelineStateDescriptor;
 
         {
-            m_bufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_bufferPool = aznew RHI::MultiDeviceBufferPool();
 
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-            m_bufferPool->Init(*device, bufferPoolDesc);
+            m_bufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
             UpdateVertexPositions(0);
 
@@ -94,12 +94,12 @@ namespace AtomSampleViewer
             SetVertexUV(m_bufferData.m_uvs.data(), 2, 1.0f, 1.0f);
             SetVertexUV(m_bufferData.m_uvs.data(), 3, 1.0f, 0.0f);
 
-            m_positionBuffer = RHI::Factory::Get().CreateBuffer();
-            m_indexBuffer = RHI::Factory::Get().CreateBuffer();
-            m_uvBuffer = RHI::Factory::Get().CreateBuffer();
+            m_positionBuffer = aznew RHI::MultiDeviceBuffer();
+            m_indexBuffer = aznew RHI::MultiDeviceBuffer();
+            m_uvBuffer = aznew RHI::MultiDeviceBuffer();
 
             RHI::ResultCode result = RHI::ResultCode::Success;
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             
             request.m_buffer = m_indexBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, indexBufSize };
@@ -139,14 +139,14 @@ namespace AtomSampleViewer
             }
 
             m_streamBufferViews[0] = {
-                *m_positionBuffer,
+                *m_positionBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 0,
                 positionBufSize,
                 sizeof(VertexPosition)
             };
 
             m_streamBufferViews[1] = {
-                *m_uvBuffer,
+                *m_uvBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 0,
                 uvBufSize,
                 sizeof(VertexUV)
@@ -228,7 +228,7 @@ namespace AtomSampleViewer
 
                 const RHI::SingleDeviceIndexBufferView indexBufferView =
                 {
-                    *m_indexBuffer,
+                    *m_indexBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     0,
                     indexBufSize,
                     RHI::IndexFormat::Uint16
@@ -328,7 +328,7 @@ namespace AtomSampleViewer
 
     void CopyQueueComponent::UploadVertexBuffer()
     {
-        AZ::RHI::SingleDeviceBufferStreamRequest request;
+        AZ::RHI::MultiDeviceBufferStreamRequest request;
         request.m_buffer = m_positionBuffer.get();
         request.m_byteCount = static_cast<uint32_t>(m_bufferData.m_positions.size() * sizeof(VertexPosition));
         request.m_sourceData = m_bufferData.m_positions.data();

+ 5 - 5
Gem/Code/Source/RHI/CopyQueueComponent.h

@@ -13,7 +13,7 @@
 #include <Atom/RPI.Public/Image/StreamingImage.h>
 #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/Factory.h>
@@ -60,10 +60,10 @@ namespace AtomSampleViewer
 
         AZ::RHI::ShaderInputImageIndex m_textureInputIndex;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_indexBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_positionBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_uvBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_indexBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_positionBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_uvBuffer;
 
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_pipelineState;
         AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> m_shaderResourceGroup;

+ 7 - 7
Gem/Code/Source/RHI/DualSourceBlendingComponent.cpp

@@ -74,12 +74,12 @@ namespace AtomSampleViewer
         using namespace AZ;
         RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
 
-        m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+        m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         BufferData bufferData;
         SetVertexPosition(bufferData.m_positions.data(), 0, -1.0f, -1.0f, 0.0f);
@@ -91,9 +91,9 @@ namespace AtomSampleViewer
         SetVertexColor(bufferData.m_colors.data(), 2, 0.0, 0.0, 1.0, 1.0);
 
         SetVertexIndexIncreasing(bufferData.m_indices.data(), bufferData.m_indices.size());
-        m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_inputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
         request.m_initialData = &bufferData;
@@ -101,7 +101,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[0] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_positions),
             sizeof(BufferData::m_positions),
             sizeof(VertexPosition)
@@ -109,7 +109,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[1] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_colors),
             sizeof(BufferData::m_colors),
             sizeof(VertexColor)
@@ -117,7 +117,7 @@ namespace AtomSampleViewer
 
         m_indexBufferView =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_indices),
             sizeof(BufferData::m_indices),
             RHI::IndexFormat::Uint16

+ 2 - 2
Gem/Code/Source/RHI/DualSourceBlendingComponent.h

@@ -60,8 +60,8 @@ namespace AtomSampleViewer
             AZStd::array<uint16_t, geometryIndexCount> m_indices;
         };
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         AZStd::array<AZ::RHI::SingleDeviceStreamBufferView, 2> m_streamBufferViews;
         AZ::RHI::SingleDeviceIndexBufferView m_indexBufferView;

+ 38 - 38
Gem/Code/Source/RHI/IndirectRenderingExampleComponent.cpp

@@ -134,12 +134,12 @@ namespace AtomSampleViewer
         layoutBuilder.AddBuffer(RHI::StreamStepFunction::PerInstance)->Channel("BLENDINDICES0", RHI::Format::R32_UINT);
         m_inputStreamLayout = layoutBuilder.End();
 
-        m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+        m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         {
             BufferData bufferData;
@@ -158,9 +158,9 @@ namespace AtomSampleViewer
                 bufferData.m_instanceIndices[i] = i;
             }
 
-            m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+            m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_inputAssemblyBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
             request.m_initialData = &bufferData;
@@ -176,7 +176,7 @@ namespace AtomSampleViewer
             {
                 triangleStreamBufferView =
                 {
-                    *m_inputAssemblyBuffer,
+                    *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_trianglePositions),
                     sizeof(BufferData::m_trianglePositions),
                     sizeof(VertexPosition)
@@ -184,7 +184,7 @@ namespace AtomSampleViewer
 
                 triangleIndexBufferView =
                 {
-                    *m_inputAssemblyBuffer,
+                    *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_triangleIndices),
                     sizeof(BufferData::m_triangleIndices),
                     RHI::IndexFormat::Uint16
@@ -192,7 +192,7 @@ namespace AtomSampleViewer
 
                 quadStreamBufferView =
                 {
-                    *m_inputAssemblyBuffer,
+                    *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_quadPositions),
                     sizeof(BufferData::m_quadPositions),
                     sizeof(VertexPosition)
@@ -200,7 +200,7 @@ namespace AtomSampleViewer
 
                 quadIndexBufferView =
                 {
-                    *m_inputAssemblyBuffer,
+                    *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_quadIndices),
                     sizeof(BufferData::m_quadIndices),
                     RHI::IndexFormat::Uint16
@@ -211,7 +211,7 @@ namespace AtomSampleViewer
             {
                 m_streamBufferViews[0] =
                 {
-                    *m_inputAssemblyBuffer,
+                    *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_trianglePositions),
                     sizeof(BufferData::m_trianglePositions) + sizeof(BufferData::m_quadPositions),
                     sizeof(VertexPosition)
@@ -219,7 +219,7 @@ namespace AtomSampleViewer
 
                 m_indexBufferViews[0] =
                 {
-                    *m_inputAssemblyBuffer,
+                    *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_triangleIndices), // Need to offset the index buffer to the proper location
                     sizeof(BufferData::m_triangleIndices) + sizeof(BufferData::m_quadIndices),
                     RHI::IndexFormat::Uint16
@@ -233,7 +233,7 @@ namespace AtomSampleViewer
 
             instancesIndicesStreamBufferView =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(BufferData, m_instanceIndices),
                 sizeof(BufferData::m_instanceIndices),
                 sizeof(uint32_t)
@@ -332,12 +332,12 @@ namespace AtomSampleViewer
         RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
         RHI::ResultCode result;
 
-        m_shaderBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_shaderBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::ShaderRead | RHI::BufferBindFlags::Indirect;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_shaderBufferPool->Init(*device, bufferPoolDesc);
+        m_shaderBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         // Create the layout depending on which commands are supported by the device.
         m_indirectDrawBufferLayout = RHI::IndirectBufferLayout();
@@ -369,10 +369,10 @@ namespace AtomSampleViewer
             return;
         }
 
-        m_sourceIndirectBuffer = RHI::Factory::Get().CreateBuffer();
+        m_sourceIndirectBuffer = aznew RHI::MultiDeviceBuffer();
 
         uint32_t commandsStride = m_indirectDrawBufferSignature->GetByteStride();
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_sourceIndirectBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor(
             bufferPoolDesc.m_bindFlags,
@@ -381,7 +381,7 @@ namespace AtomSampleViewer
 
         // Create a writer to populate the buffer with the commands.
         auto indirectBufferWriter = RHI::Factory::Get().CreateIndirectBufferWriter();
-        result = indirectBufferWriter->Init(*m_sourceIndirectBuffer, 0, commandsStride, s_maxNumberOfObjects, *m_indirectDrawBufferSignature);
+        result = indirectBufferWriter->Init(*m_sourceIndirectBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex), 0, commandsStride, s_maxNumberOfObjects, *m_indirectDrawBufferSignature);
         if (result != RHI::ResultCode::Success)
         {
             AZ_Assert(false, "Fail to initialize Indirect Buffer Writer");
@@ -450,7 +450,7 @@ namespace AtomSampleViewer
         indirectBufferWriter->Shutdown();
 
         auto viewDescriptor = RHI::BufferViewDescriptor::CreateStructured(0, s_maxNumberOfObjects, commandsStride);
-        m_sourceIndirectBufferView = m_sourceIndirectBuffer->GetBufferView(viewDescriptor);
+        m_sourceIndirectBufferView = m_sourceIndirectBuffer->BuildBufferView(viewDescriptor);
                   
         if(!m_sourceIndirectBufferView.get())
         {
@@ -459,7 +459,7 @@ namespace AtomSampleViewer
         }
 
         // Create the buffer that will contain the compute dispatch arguments.
-        m_indirectDispatchBuffer = RHI::Factory::Get().CreateBuffer();
+        m_indirectDispatchBuffer = aznew RHI::MultiDeviceBuffer();
         {
             m_indirectDispatchBufferLayout = RHI::IndirectBufferLayout();
             m_indirectDispatchBufferLayout.AddIndirectCommand(RHI::IndirectCommandDescriptor(RHI::IndirectCommandType::Dispatch));
@@ -490,7 +490,7 @@ namespace AtomSampleViewer
 
             m_indirectDispatchBufferView =
             {
-                *m_indirectDispatchBuffer,
+                *m_indirectDispatchBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 *m_indirectDispatchBufferSignature,
                 0,
                 indirectDispatchStride,
@@ -498,7 +498,7 @@ namespace AtomSampleViewer
             };
 
             m_indirectDispatchWriter = RHI::Factory::Get().CreateIndirectBufferWriter();
-            result = m_indirectDispatchWriter->Init(*m_indirectDispatchBuffer, 0, indirectDispatchStride, 1, *m_indirectDispatchBufferSignature);
+            result = m_indirectDispatchWriter->Init(*m_indirectDispatchBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex), 0, indirectDispatchStride, 1, *m_indirectDispatchBufferSignature);
             if (result != RHI::ResultCode::Success)
             {
                 AZ_Assert(false, "Fail to initialize Indirect Buffer Writer");
@@ -525,16 +525,16 @@ namespace AtomSampleViewer
             data.m_velocity.Set(GetRandomFloat(IndirectRendering::VelocityRange.GetX(), IndirectRendering::VelocityRange.GetY()));
         }
 
-        m_instancesBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_instancesBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::ShaderRead;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Host;
-        m_instancesBufferPool->Init(*device, bufferPoolDesc);
+        m_instancesBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
-        m_instancesDataBuffer = RHI::Factory::Get().CreateBuffer();
+        m_instancesDataBuffer = aznew RHI::MultiDeviceBuffer();
 
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_instancesDataBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{
             RHI::BufferBindFlags::ShaderRead,
@@ -543,7 +543,7 @@ namespace AtomSampleViewer
         m_instancesBufferPool->InitBuffer(request);
 
         auto descriptor = RHI::BufferViewDescriptor::CreateStructured(0, static_cast<uint32_t>(m_instancesData.size()), sizeof(InstanceData));
-        m_instancesDataBufferView = m_instancesDataBuffer->GetBufferView(descriptor);
+        m_instancesDataBufferView = m_instancesDataBuffer->BuildBufferView(descriptor);
                   
         if(!m_instancesDataBufferView.get())
         {
@@ -556,14 +556,14 @@ namespace AtomSampleViewer
         // the compute shader has culled the commands.
         if (m_deviceSupportsCountBuffer)
         {
-            m_copyBufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_copyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
             bufferPoolDesc = {};
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::CopyRead;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Host;
-            m_copyBufferPool->Init(*device, bufferPoolDesc);
+            m_copyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
-            m_resetCounterBuffer = RHI::Factory::Get().CreateBuffer();
+            m_resetCounterBuffer = aznew RHI::MultiDeviceBuffer();
 
             AZStd::vector<uint32_t> initData;
             initData.assign(static_cast<size_t>(std::ceil(float(s_maxNumberOfObjects) / maxIndirectDrawCount)), 0);
@@ -586,14 +586,14 @@ namespace AtomSampleViewer
             FindShaderInputIndex(&m_sceneInstancesDataBufferIndex, m_sceneShaderResourceGroup, instancesDataId, IndirectRendering::SampleName);
             FindShaderInputIndex(&m_sceneMatrixInputIndex, m_sceneShaderResourceGroup, matrixId, IndirectRendering::SampleName);
             float screenAspect = GetViewportWidth() / GetViewportHeight();
-            m_sceneShaderResourceGroup->SetBufferView(m_sceneInstancesDataBufferIndex, m_instancesDataBufferView.get());
+            m_sceneShaderResourceGroup->SetBufferView(m_sceneInstancesDataBufferIndex, m_instancesDataBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get());
             m_sceneShaderResourceGroup->SetConstant(m_sceneMatrixInputIndex, AZ::Matrix4x4::CreateScale(AZ::Vector3(1.f/ screenAspect, 1.f, 1.f)));
             m_sceneShaderResourceGroup->Compile();
         }
 
         {
             uint32_t sequenceTypeIndex = static_cast<uint32_t>(m_mode);
-            m_indirectCommandsShaderResourceGroups[sequenceTypeIndex]->SetBufferView(m_cullingInputIndirectBufferIndices[sequenceTypeIndex], m_sourceIndirectBufferView.get());
+            m_indirectCommandsShaderResourceGroups[sequenceTypeIndex]->SetBufferView(m_cullingInputIndirectBufferIndices[sequenceTypeIndex], m_sourceIndirectBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get());
         }
     }
 
@@ -619,8 +619,8 @@ namespace AtomSampleViewer
 
         const auto compileFunction = [this](const RHI::FrameGraphCompileContext& context, [[maybe_unused]] const ScopeData& scopeData)
         {
-            const RHI::SingleDeviceBufferView* countBufferView = context.GetBufferView(RHI::AttachmentId{ IndirectRendering::CountBufferAttachmentId });
-            m_copyDescriptor.m_sourceBuffer = m_resetCounterBuffer.get();
+            const auto* countBufferView = context.GetBufferView(RHI::AttachmentId{ IndirectRendering::CountBufferAttachmentId });
+            m_copyDescriptor.m_sourceBuffer = m_resetCounterBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex).get();
             m_copyDescriptor.m_sourceOffset = 0;
             m_copyDescriptor.m_destinationBuffer = &countBufferView->GetBuffer();
             m_copyDescriptor.m_destinationOffset = 0;
@@ -687,7 +687,7 @@ namespace AtomSampleViewer
         const auto compileFunction = [this, maxIndirectDrawCount](const RHI::FrameGraphCompileContext& context, [[maybe_unused]] const ScopeData& scopeData)
         {
 
-            const RHI::SingleDeviceBufferView* culledBufferView = context.GetBufferView(RHI::AttachmentId{ IndirectRendering::CulledIndirectBufferAttachmentId });
+            const auto* culledBufferView = context.GetBufferView(RHI::AttachmentId{ IndirectRendering::CulledIndirectBufferAttachmentId });
 
             uint32_t sequenceTypeIndex = static_cast<uint32_t>(m_mode);
             auto& indirectCommandsSRG = m_indirectCommandsShaderResourceGroups[sequenceTypeIndex];
@@ -696,7 +696,7 @@ namespace AtomSampleViewer
 
             if (m_deviceSupportsCountBuffer)
             {
-                const RHI::SingleDeviceBufferView* countBufferView = context.GetBufferView(RHI::AttachmentId{ IndirectRendering::CountBufferAttachmentId });
+                const auto* countBufferView = context.GetBufferView(RHI::AttachmentId{ IndirectRendering::CountBufferAttachmentId });
 
                 m_cullShaderResourceGroup->SetBufferView(m_cullingCountBufferIndex, countBufferView);
                 m_drawIndirect.m_countBuffer = &countBufferView->GetBuffer();
@@ -1029,13 +1029,13 @@ namespace AtomSampleViewer
             }
         }
 
-        RHI::SingleDeviceBufferMapRequest request(*m_instancesDataBuffer, 0, sizeof(InstanceData) * m_numObjects);
-        RHI::SingleDeviceBufferMapResponse response;
+        RHI::MultiDeviceBufferMapRequest request(*m_instancesDataBuffer, 0, sizeof(InstanceData) * m_numObjects);
+        RHI::MultiDeviceBufferMapResponse response;
 
         m_instancesBufferPool->MapBuffer(request, response);
-        if (response.m_data)
+        if (!response.m_data.empty())
         {
-            ::memcpy(response.m_data, m_instancesData.data(), request.m_byteCount);
+            ::memcpy(response.m_data[RHI::MultiDevice::DefaultDeviceIndex], m_instancesData.data(), request.m_byteCount);
             m_instancesBufferPool->UnmapBuffer(*m_instancesDataBuffer);
         }
     }

+ 12 - 12
Gem/Code/Source/RHI/IndirectRenderingExampleComponent.h

@@ -19,7 +19,7 @@
 #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
 #include <Atom/RPI.Public/Shader/ShaderReloadNotificationBus.h>
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/Factory.h>
@@ -152,16 +152,16 @@ namespace AtomSampleViewer
 
         AZ::RHI::InputStreamLayout m_inputStreamLayout;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_shaderBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_instancesBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_copyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_shaderBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_instancesBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_copyBufferPool;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_sourceIndirectBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_instancesDataBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_resetCounterBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_indirectDispatchBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_sourceIndirectBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_instancesDataBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_resetCounterBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_indirectDispatchBuffer;
 
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_drawPipelineState;
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_cullPipelineState;
@@ -176,8 +176,8 @@ namespace AtomSampleViewer
         AZ::RHI::SingleDeviceIndirectBufferView m_indirectDrawBufferView;
         AZ::RHI::SingleDeviceIndirectBufferView m_indirectDispatchBufferView;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> m_sourceIndirectBufferView;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> m_instancesDataBufferView;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> m_sourceIndirectBufferView;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> m_instancesDataBufferView;
 
         AZ::RHI::IndirectBufferLayout m_indirectDrawBufferLayout;
         AZ::RHI::IndirectBufferLayout m_indirectDispatchBufferLayout;

+ 9 - 9
Gem/Code/Source/RHI/InputAssemblyExampleComponent.cpp

@@ -66,7 +66,7 @@ namespace AtomSampleViewer
             }
 
             {
-                frameGraphBuilder.GetAttachmentDatabase().ImportBuffer(AZ::Name{ InputAssembly::ImportedInputAssemblyBufferAttachmentId }, m_inputAssemblyBuffer);
+                frameGraphBuilder.GetAttachmentDatabase().ImportBuffer(AZ::Name{ InputAssembly::ImportedInputAssemblyBufferAttachmentId }, m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex));
             }
 
             float aspectRatio = static_cast<float>(m_outputWidth / m_outputHeight);
@@ -145,16 +145,16 @@ namespace AtomSampleViewer
     {
         using namespace AZ;
         RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
-        m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly | RHI::BufferBindFlags::ShaderReadWrite;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+        m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
-        m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_inputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly | RHI::BufferBindFlags::ShaderReadWrite, sizeof(BufferData) };
         request.m_initialData = nullptr;
@@ -268,14 +268,14 @@ namespace AtomSampleViewer
         {
             AZ_UNUSED(scopeData);
             {
-                const RHI::SingleDeviceBufferView* inputAssemblyBufferView = context.GetBufferView(RHI::AttachmentId{ InputAssembly::InputAssemblyBufferAttachmentId });
+                const auto* inputAssemblyBufferView = context.GetBufferView(RHI::AttachmentId{ InputAssembly::InputAssemblyBufferAttachmentId });
                 m_dispatchSRG[0]->SetBufferView(m_dispatchIABufferIndex, inputAssemblyBufferView);
                 m_dispatchSRG[0]->SetConstant(m_dispatchTimeConstantIndex, m_time);
                 m_dispatchSRG[0]->Compile();
             }
 
             {
-                const RHI::SingleDeviceBufferView* inputAssemblyBufferView = context.GetBufferView(RHI::AttachmentId{ InputAssembly::ImportedInputAssemblyBufferAttachmentId });
+                const auto* inputAssemblyBufferView = context.GetBufferView(RHI::AttachmentId{ InputAssembly::ImportedInputAssemblyBufferAttachmentId });
                 m_dispatchSRG[1]->SetBufferView(m_dispatchIABufferIndex, inputAssemblyBufferView);
                 m_dispatchSRG[1]->SetConstant(m_dispatchTimeConstantIndex, m_time);
                 m_dispatchSRG[1]->Compile();
@@ -368,7 +368,7 @@ namespace AtomSampleViewer
         {
             AZ_UNUSED(scopeData);
             {
-                const RHI::SingleDeviceBufferView* inputAssemblyBufferView = context.GetBufferView(RHI::AttachmentId{ InputAssembly::InputAssemblyBufferAttachmentId });
+                const auto* inputAssemblyBufferView = context.GetBufferView(RHI::AttachmentId{ InputAssembly::InputAssemblyBufferAttachmentId });
                 if (inputAssemblyBufferView)
                 {
                     m_streamBufferView[0] = {inputAssemblyBufferView->GetBuffer(), 0, sizeof(BufferData), sizeof(BufferData::value_type)};
@@ -378,7 +378,7 @@ namespace AtomSampleViewer
             }
 
             {
-                const RHI::SingleDeviceBufferView* inputAssemblyBufferView = context.GetBufferView(RHI::AttachmentId{ InputAssembly::ImportedInputAssemblyBufferAttachmentId });
+                const auto* inputAssemblyBufferView = context.GetBufferView(RHI::AttachmentId{ InputAssembly::ImportedInputAssemblyBufferAttachmentId });
                 if (inputAssemblyBufferView)
                 {
                     m_streamBufferView[1] = {inputAssemblyBufferView->GetBuffer(), 0, sizeof(BufferData), sizeof(BufferData::value_type)};

+ 2 - 2
Gem/Code/Source/RHI/InputAssemblyExampleComponent.h

@@ -68,8 +68,8 @@ namespace AtomSampleViewer
         AZ::RHI::SingleDeviceStreamBufferView m_streamBufferView[2];
         AZ::RHI::InputStreamLayout m_inputStreamLayout;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         // ----------------------
         // Pipeline state and SRG

+ 7 - 7
Gem/Code/Source/RHI/MRTExampleComponent.cpp

@@ -172,18 +172,18 @@ namespace AtomSampleViewer
         using namespace AZ;
         const RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
 
-        m_bufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_bufferPool = aznew RHI::MultiDeviceBufferPool();
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_bufferPool->Init(*device, bufferPoolDesc);
+        m_bufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         BufferData bufferData;
         SetFullScreenRect(bufferData.m_positions.data(), bufferData.m_uvs.data(), bufferData.m_indices.data());
 
-        m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
         RHI::ResultCode result = RHI::ResultCode::Success;
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
 
         request.m_buffer = m_inputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
@@ -197,7 +197,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[0] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_positions),
             sizeof(BufferData::m_positions),
             sizeof(VertexPosition)
@@ -205,7 +205,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[1] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_uvs),
             sizeof(BufferData::m_uvs),
             sizeof(VertexUV)
@@ -213,7 +213,7 @@ namespace AtomSampleViewer
 
         m_indexBufferView =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_indices),
             sizeof(BufferData::m_indices),
             RHI::IndexFormat::Uint16

+ 3 - 3
Gem/Code/Source/RHI/MRTExampleComponent.h

@@ -8,7 +8,7 @@
 
 #pragma once
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/ScopeProducer.h>
 
@@ -57,8 +57,8 @@ namespace AtomSampleViewer
         void ReadRenderTargetShader();
         void ReadScreenShader();
         
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         AZStd::array<AZ::RHI::TransientImageDescriptor, 3> m_renderTargetImageDescriptors;
 

+ 12 - 12
Gem/Code/Source/RHI/MSAAExampleComponent.cpp

@@ -48,12 +48,12 @@ namespace AtomSampleViewer
     {
         using namespace AZ;
         RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
-        m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+        m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         AZStd::vector<RHI::SamplePosition> emptySamplePositions;
         AZStd::vector<RHI::SamplePosition> customSamplePositions = { RHI::SamplePosition(3, 3), RHI::SamplePosition(11, 3), RHI::SamplePosition(3, 11), RHI::SamplePosition(11, 11) };
@@ -136,9 +136,9 @@ namespace AtomSampleViewer
 
         SetVertexIndexIncreasing(bufferData.m_indices.data(), bufferData.m_indices.size());
 
-        m_triangleInputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_triangleInputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_triangleInputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
         request.m_initialData = &bufferData;
@@ -146,7 +146,7 @@ namespace AtomSampleViewer
 
         m_triangleStreamBufferViews[0] =
         {
-            *m_triangleInputAssemblyBuffer,
+            *m_triangleInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(TriangleBufferData, m_positions),
             sizeof(TriangleBufferData::m_positions),
             sizeof(VertexPosition)
@@ -154,7 +154,7 @@ namespace AtomSampleViewer
 
         m_triangleStreamBufferViews[1] =
         {
-            *m_triangleInputAssemblyBuffer,
+            *m_triangleInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(TriangleBufferData, m_colors),
             sizeof(TriangleBufferData::m_colors),
             sizeof(VertexColor)
@@ -189,10 +189,10 @@ namespace AtomSampleViewer
         QuadBufferData bufferData;
         SetFullScreenRect(bufferData.m_positions.data(), bufferData.m_uvs.data(), bufferData.m_indices.data());
 
-        m_quadInputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_quadInputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
         RHI::ResultCode result = RHI::ResultCode::Success;
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
 
         request.m_buffer = m_quadInputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
@@ -206,14 +206,14 @@ namespace AtomSampleViewer
         }
 
         m_quadStreamBufferViews[0] = {
-            *m_quadInputAssemblyBuffer,
+            *m_quadInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(QuadBufferData, m_positions),
             sizeof(QuadBufferData::m_positions),
             sizeof(VertexPosition)
         };
 
         m_quadStreamBufferViews[1] = {
-            *m_quadInputAssemblyBuffer,
+            *m_quadInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(QuadBufferData, m_uvs),
             sizeof(QuadBufferData::m_uvs),
             sizeof(VertexUV)
@@ -341,7 +341,7 @@ namespace AtomSampleViewer
 
             const RHI::SingleDeviceIndexBufferView indexBufferView =
             {
-                *m_triangleInputAssemblyBuffer,
+                *m_triangleInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(TriangleBufferData, m_indices),
                 sizeof(TriangleBufferData::m_indices),
                 RHI::IndexFormat::Uint16
@@ -454,7 +454,7 @@ namespace AtomSampleViewer
 
             const RHI::SingleDeviceIndexBufferView indexBufferView =
             {
-                *m_quadInputAssemblyBuffer,
+                *m_quadInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(QuadBufferData, m_indices),
                 sizeof(QuadBufferData::m_indices),
                 RHI::IndexFormat::Uint16

+ 5 - 5
Gem/Code/Source/RHI/MSAAExampleComponent.h

@@ -18,8 +18,8 @@
 #include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h>
 #include <Atom/RHI.Reflect/ScopeId.h>
 
-#include <Atom/RHI/SingleDeviceBuffer.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBuffer.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
 #include <Atom/RHI/SingleDeviceStreamBufferView.h>
@@ -103,9 +103,9 @@ namespace AtomSampleViewer
         void CreateCustomMSAAResolveScope();
 
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_triangleInputAssemblyBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_quadInputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_triangleInputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_quadInputAssemblyBuffer;
         
         AZStd::array<AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState>, s_numMSAAExamples> m_pipelineStates;
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_customResolveMSAAPipelineState;

+ 7 - 7
Gem/Code/Source/RHI/MatrixAlignmentTestExampleComponent.cpp

@@ -224,12 +224,12 @@ namespace AtomSampleViewer
         AZ::RHI::PipelineStateDescriptorForDraw pipelineStateDescriptor;
 
         {
-            m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-            m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+            m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
             BufferData bufferData;
 
@@ -241,9 +241,9 @@ namespace AtomSampleViewer
             SetVertexColor(bufferData.m_colors.data(), 2, 0.0, 0.0, 1.0, 1.0);
             SetVertexColor(bufferData.m_colors.data(), 3, 0.0, 0.0, 1.0, 1.0);
 
-            m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+            m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_inputAssemblyBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
             request.m_initialData = &bufferData;
@@ -251,7 +251,7 @@ namespace AtomSampleViewer
 
             m_streamBufferViews[0] =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(BufferData, m_positions),
                 sizeof(BufferData::m_positions),
                 sizeof(VertexPosition)
@@ -259,7 +259,7 @@ namespace AtomSampleViewer
 
             m_streamBufferViews[1] =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(BufferData, m_colors),
                 sizeof(BufferData::m_colors),
                 sizeof(VertexColor)
@@ -459,7 +459,7 @@ namespace AtomSampleViewer
 
                 const RHI::SingleDeviceIndexBufferView indexBufferView =
                 {
-                    *m_inputAssemblyBuffer,
+                    *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_indices),
                     sizeof(BufferData::m_indices),
                     RHI::IndexFormat::Uint16

+ 3 - 3
Gem/Code/Source/RHI/MatrixAlignmentTestExampleComponent.h

@@ -18,7 +18,7 @@
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/Factory.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 
 #include <RHI/BasicRHIComponent.h>
 
@@ -82,8 +82,8 @@ namespace AtomSampleViewer
             const AZ::RHI::ShaderInputConstantIndex& matrixConstantId);
 
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_pipelineState;
 

+ 7 - 7
Gem/Code/Source/RHI/MultiThreadComponent.cpp

@@ -149,11 +149,11 @@ namespace AtomSampleViewer
         const AZ::RHI::Ptr<AZ::RHI::Device> device = Utils::GetRHIDevice();
         AZ::RHI::ResultCode result = AZ::RHI::ResultCode::Success;
 
-        m_bufferPool = AZ::RHI::Factory::Get().CreateBufferPool();
+        m_bufferPool = aznew AZ::RHI::MultiDeviceBufferPool();
         AZ::RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = AZ::RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = AZ::RHI::HeapMemoryLevel::Device;
-        result = m_bufferPool->Init(*device, bufferPoolDesc);
+        result = m_bufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
         if (result != AZ::RHI::ResultCode::Success)
         {
             AZ_Error("MultiThreadComponent", false, "Failed to initialize buffer pool with error code %d", result);
@@ -162,8 +162,8 @@ namespace AtomSampleViewer
 
         SingleCubeBufferData bufferData = CreateSingleCubeBufferData(AZ::Vector4(1.0f, 0.0f, 0.0f, 0.0f));
 
-        m_inputAssemblyBuffer = AZ::RHI::Factory::Get().CreateBuffer();
-        AZ::RHI::SingleDeviceBufferInitRequest request;
+        m_inputAssemblyBuffer = aznew AZ::RHI::MultiDeviceBuffer();
+        AZ::RHI::MultiDeviceBufferInitRequest request;
 
         request.m_buffer = m_inputAssemblyBuffer.get();
         request.m_descriptor = AZ::RHI::BufferDescriptor{ AZ::RHI::BufferBindFlags::InputAssembly, sizeof(SingleCubeBufferData) };
@@ -177,7 +177,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[0] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(SingleCubeBufferData, m_positions),
             sizeof(SingleCubeBufferData::m_positions),
             sizeof(VertexPosition)
@@ -185,7 +185,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[1] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(SingleCubeBufferData, m_colors),
             sizeof(SingleCubeBufferData::m_colors),
             sizeof(VertexColor)
@@ -193,7 +193,7 @@ namespace AtomSampleViewer
 
         m_indexBufferView =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(SingleCubeBufferData, m_indices),
             sizeof(SingleCubeBufferData::m_indices),
             AZ::RHI::IndexFormat::Uint16

+ 4 - 4
Gem/Code/Source/RHI/MultiThreadComponent.h

@@ -9,8 +9,8 @@
 
 #include <RHI/BasicRHIComponent.h>
 
-#include <Atom/RHI/SingleDeviceBuffer.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBuffer.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
 #include <Atom/RHI.Reflect/InputStreamLayoutBuilder.h>
 #include <MultiThreadComponent_Traits_Platform.h>
@@ -75,8 +75,8 @@ namespace AtomSampleViewer
 
         AZStd::array<AZ::Matrix4x4, s_numberOfCubes> m_cubeTransforms;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         AZ::RHI::InputStreamLayout m_streamLayoutDescriptor;
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_pipelineState;

+ 9 - 9
Gem/Code/Source/RHI/MultipleViewsComponent.cpp

@@ -9,7 +9,7 @@
 
 #include <AzCore/Math/MatrixUtils.h>
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/Factory.h>
 #include <Atom/RHI/FrameAttachment.h>
 #include <Atom/RHI.Reflect/InputStreamLayoutBuilder.h>
@@ -235,17 +235,17 @@ namespace AtomSampleViewer
 
         const AZ::RHI::Ptr<AZ::RHI::Device> device = Utils::GetRHIDevice();
 
-        m_bufferPool = AZ::RHI::Factory::Get().CreateBufferPool();
+        m_bufferPool = aznew AZ::RHI::MultiDeviceBufferPool();
         AZ::RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = AZ::RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = AZ::RHI::HeapMemoryLevel::Device;
-        m_bufferPool->Init(*device, bufferPoolDesc);
+        m_bufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         BufferData bufferData = CreateBufferData();
 
-        m_inputAssemblyBuffer = AZ::RHI::Factory::Get().CreateBuffer();
+        m_inputAssemblyBuffer = aznew AZ::RHI::MultiDeviceBuffer();
         AZ::RHI::ResultCode result = AZ::RHI::ResultCode::Success;
-        AZ::RHI::SingleDeviceBufferInitRequest request;
+        AZ::RHI::MultiDeviceBufferInitRequest request;
 
         request.m_buffer = m_inputAssemblyBuffer.get();
         request.m_descriptor = AZ::RHI::BufferDescriptor{ AZ::RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
@@ -259,7 +259,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[0] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_positions),
             sizeof(BufferData::m_positions),
             sizeof(VertexPosition)
@@ -267,7 +267,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[1] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_colors),
             sizeof(BufferData::m_colors),
             sizeof(VertexColor)
@@ -275,7 +275,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[2] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_normals),
             sizeof(BufferData::m_normals),
             sizeof(VertexNormal)
@@ -283,7 +283,7 @@ namespace AtomSampleViewer
 
         m_indexBufferView =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_indices),
             sizeof(BufferData::m_indices),
             AZ::RHI::IndexFormat::Uint16

+ 4 - 4
Gem/Code/Source/RHI/MultipleViewsComponent.h

@@ -10,8 +10,8 @@
 
 #include <RHI/BasicRHIComponent.h>
 
-#include <Atom/RHI/SingleDeviceBuffer.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBuffer.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
 #include <Atom/RPI.Public/Image/AttachmentImage.h>
@@ -91,8 +91,8 @@ namespace AtomSampleViewer
         
         static const int s_shadowMapSize = 1024;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         AZ::RHI::InputStreamLayout m_inputStreamLayout;
         AZStd::array<AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState>, 2> m_pipelineStates;

+ 13 - 13
Gem/Code/Source/RHI/QueryExampleComponent.cpp

@@ -154,22 +154,22 @@ namespace AtomSampleViewer
     {
         using namespace AZ;
         RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
-        m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+        m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         {
             // Create quad buffer and views
             BufferData bufferData;
             SetFullScreenRect(bufferData.m_positions.data(), nullptr, bufferData.m_indices.data());
 
-            m_quadInputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+            m_quadInputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
             RHI::ResultCode result = RHI::ResultCode::Success;
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_quadInputAssemblyBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
             request.m_initialData = &bufferData;
@@ -182,7 +182,7 @@ namespace AtomSampleViewer
             }
 
             m_quadStreamBufferView = {
-                *m_quadInputAssemblyBuffer,
+                *m_quadInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(BufferData, m_positions),
                 sizeof(BufferData::m_positions),
                 sizeof(VertexPosition)
@@ -282,7 +282,7 @@ namespace AtomSampleViewer
                 return;
             }
             
-            [[maybe_unused]] RHI::ResultCode result = frameGraph.GetAttachmentDatabase().ImportBuffer(RHI::AttachmentId{QueryExample::PredicationBufferId}, m_predicationBuffer);
+            [[maybe_unused]] RHI::ResultCode result = frameGraph.GetAttachmentDatabase().ImportBuffer(RHI::AttachmentId{QueryExample::PredicationBufferId}, m_predicationBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex));
             AZ_Error(QueryExample::SampleName, result == RHI::ResultCode::Success, "Failed to import predication buffer with error %d", result);
 
             frameGraph.UseQueryPool(
@@ -309,7 +309,7 @@ namespace AtomSampleViewer
             descriptor.m_sourceQueryPool = m_occlusionQueryPool.get();
             descriptor.m_firstQuery = m_occlusionQueries[m_currentOcclusionQueryIndex].m_query->GetHandle();
             descriptor.m_queryCount = 1;
-            descriptor.m_destinationBuffer = m_predicationBuffer.get();
+            descriptor.m_destinationBuffer = m_predicationBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex).get();
             descriptor.m_destinationOffset = 0;
             descriptor.m_destinationStride = sizeof(uint64_t);
 
@@ -434,7 +434,7 @@ namespace AtomSampleViewer
             {
                 const RHI::SingleDeviceIndexBufferView quadIndexBufferView =
                 {
-                    *m_quadInputAssemblyBuffer,
+                    *m_quadInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_indices),
                     sizeof(BufferData::m_indices),
                     RHI::IndexFormat::Uint16
@@ -488,7 +488,7 @@ namespace AtomSampleViewer
                     }
                     case QueryType::Predication:
                     {
-                        commandList->BeginPredication(*m_predicationBuffer, 0, RHI::PredicationOp::EqualZero);
+                        commandList->BeginPredication(*m_predicationBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex), 0, RHI::PredicationOp::EqualZero);
                         commandList->Submit(drawItem, 0);
                         commandList->EndPredication();
                         break;
@@ -592,16 +592,16 @@ namespace AtomSampleViewer
             return;
         }
 
-        m_predicationBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_predicationBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::Predication | RHI::BufferBindFlags::CopyWrite;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_predicationBufferPool->Init(*device, bufferPoolDesc);
+        m_predicationBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
-        m_predicationBuffer = RHI::Factory::Get().CreateBuffer();
+        m_predicationBuffer = aznew RHI::MultiDeviceBuffer();
 
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_predicationBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::Predication | RHI::BufferBindFlags::CopyWrite, sizeof(uint64_t) };
         RHI::ResultCode result = m_predicationBufferPool->InitBuffer(request);

+ 6 - 6
Gem/Code/Source/RHI/QueryExampleComponent.h

@@ -16,8 +16,8 @@
 #include <Atom/RHI.Reflect/ShaderResourceGroupLayoutDescriptor.h>
 #include <Atom/RHI.Reflect/ScopeId.h>
 
-#include <Atom/RHI/SingleDeviceBuffer.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBuffer.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
 #include <Atom/RHI/SingleDeviceQueryPool.h>
@@ -92,8 +92,8 @@ namespace AtomSampleViewer
         void SetQueryType(QueryType type);
         void DrawSampleSettings();
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_quadInputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_quadInputAssemblyBuffer;
 
         struct BufferData
         {
@@ -128,8 +128,8 @@ namespace AtomSampleViewer
 
         QueryType m_currentType = QueryType::Occlusion;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_predicationBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_predicationBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_predicationBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_predicationBuffer;
         AZ::RHI::BufferScopeAttachmentDescriptor m_predicationBufferAttachmentDescriptor;
 
         bool m_timestampEnabled = false;

+ 17 - 17
Gem/Code/Source/RHI/RayTracingExampleComponent.cpp

@@ -68,12 +68,12 @@ namespace AtomSampleViewer
 
         // create input assembly buffer pool
         {
-            m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Host;
-            [[maybe_unused]] RHI::ResultCode resultCode = m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+            [[maybe_unused]] RHI::ResultCode resultCode = m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
             AZ_Assert(resultCode == RHI::ResultCode::Success, "Failed to initialize input assembly buffer pool");
         }
 
@@ -101,10 +101,10 @@ namespace AtomSampleViewer
             SetVertexPosition(m_triangleVertices.data(), 1, 0.5f, -0.5f, 1.0);
             SetVertexPosition(m_triangleVertices.data(), 2, -0.5f, -0.5f, 1.0);
 
-            m_triangleVB = RHI::Factory::Get().CreateBuffer();
+            m_triangleVB = aznew RHI::MultiDeviceBuffer();
             m_triangleVB->SetName(AZ::Name("Triangle VB"));
 
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_triangleVB.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(m_triangleVertices) };
             request.m_initialData = m_triangleVertices.data();
@@ -113,7 +113,7 @@ namespace AtomSampleViewer
             // index buffer
             SetVertexIndexIncreasing(m_triangleIndices.data(), m_triangleIndices.size());
 
-            m_triangleIB = RHI::Factory::Get().CreateBuffer();
+            m_triangleIB = aznew RHI::MultiDeviceBuffer();
             m_triangleIB->SetName(AZ::Name("Triangle IB"));
 
             request.m_buffer = m_triangleIB.get();
@@ -130,10 +130,10 @@ namespace AtomSampleViewer
             SetVertexPosition(m_rectangleVertices.data(), 2,  0.5f, -0.5f, 1.0);
             SetVertexPosition(m_rectangleVertices.data(), 3, -0.5f, -0.5f, 1.0);
 
-            m_rectangleVB = RHI::Factory::Get().CreateBuffer();
+            m_rectangleVB = aznew RHI::MultiDeviceBuffer();
             m_rectangleVB->SetName(AZ::Name("Rectangle VB"));
 
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_rectangleVB.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(m_rectangleVertices) };
             request.m_initialData = m_rectangleVertices.data();
@@ -147,7 +147,7 @@ namespace AtomSampleViewer
             m_rectangleIndices[4] = 2;
             m_rectangleIndices[5] = 3;
 
-            m_rectangleIB = RHI::Factory::Get().CreateBuffer();
+            m_rectangleIB = aznew RHI::MultiDeviceBuffer();
             m_rectangleIB->SetName(AZ::Name("Rectangle IB"));
 
             request.m_buffer = m_rectangleIB.get();
@@ -162,9 +162,9 @@ namespace AtomSampleViewer
         FullScreenBufferData bufferData;
         SetFullScreenRect(bufferData.m_positions.data(), bufferData.m_uvs.data(), bufferData.m_indices.data());
 
-        m_fullScreenInputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_fullScreenInputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_fullScreenInputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
         request.m_initialData = &bufferData;
@@ -172,7 +172,7 @@ namespace AtomSampleViewer
 
         m_fullScreenStreamBufferViews[0] =
         {
-            *m_fullScreenInputAssemblyBuffer,
+            *m_fullScreenInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(FullScreenBufferData, m_positions),
             sizeof(FullScreenBufferData::m_positions),
             sizeof(VertexPosition)
@@ -180,7 +180,7 @@ namespace AtomSampleViewer
 
         m_fullScreenStreamBufferViews[1] =
         {
-            *m_fullScreenInputAssemblyBuffer,
+            *m_fullScreenInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(FullScreenBufferData, m_uvs),
             sizeof(FullScreenBufferData::m_uvs),
             sizeof(VertexUV)
@@ -188,7 +188,7 @@ namespace AtomSampleViewer
 
         m_fullScreenIndexBufferView =
         {
-            *m_fullScreenInputAssemblyBuffer,
+            *m_fullScreenInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(FullScreenBufferData, m_indices),
             sizeof(FullScreenBufferData::m_indices),
             RHI::IndexFormat::Uint16
@@ -337,7 +337,7 @@ namespace AtomSampleViewer
             {
                 RHI::SingleDeviceStreamBufferView triangleVertexBufferView =
                 {
-                    *m_triangleVB,
+                    *m_triangleVB->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     0,
                     sizeof(m_triangleVertices),
                     sizeof(VertexPosition)
@@ -345,7 +345,7 @@ namespace AtomSampleViewer
 
                 RHI::SingleDeviceIndexBufferView triangleIndexBufferView =
                 {
-                    *m_triangleIB,
+                    *m_triangleIB->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     0,
                     sizeof(m_triangleIndices),
                     RHI::IndexFormat::Uint16
@@ -367,7 +367,7 @@ namespace AtomSampleViewer
             {
                 RHI::SingleDeviceStreamBufferView rectangleVertexBufferView =
                 {
-                    *m_rectangleVB,
+                    *m_rectangleVB->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     0,
                     sizeof(m_rectangleVertices),
                     sizeof(VertexPosition)
@@ -375,7 +375,7 @@ namespace AtomSampleViewer
 
                 RHI::SingleDeviceIndexBufferView rectangleIndexBufferView =
                 {
-                    *m_rectangleIB,
+                    *m_rectangleIB->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     0,
                     sizeof(m_rectangleIndices),
                     RHI::IndexFormat::Uint16

+ 7 - 7
Gem/Code/Source/RHI/RayTracingExampleComponent.h

@@ -18,7 +18,7 @@
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/Factory.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <RHI/BasicRHIComponent.h>
 #include <Atom/RHI/SingleDeviceRayTracingBufferPools.h>
 #include <Atom/RHI/SingleDeviceRayTracingAccelerationStructure.h>
@@ -66,7 +66,7 @@ namespace AtomSampleViewer
         static const uint32_t m_imageHeight = 1080;
 
         // resource pools
-        RHI::Ptr<RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
+        RHI::Ptr<RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
         RHI::Ptr<RHI::SingleDeviceImagePool> m_imagePool;
         RHI::Ptr<RHI::SingleDeviceRayTracingBufferPools> m_rayTracingBufferPools;
 
@@ -74,15 +74,15 @@ namespace AtomSampleViewer
         AZStd::array<VertexPosition, 3> m_triangleVertices;
         AZStd::array<uint16_t, 3> m_triangleIndices;
 
-        RHI::Ptr<RHI::SingleDeviceBuffer> m_triangleVB;
-        RHI::Ptr<RHI::SingleDeviceBuffer> m_triangleIB;
+        RHI::Ptr<RHI::MultiDeviceBuffer> m_triangleVB;
+        RHI::Ptr<RHI::MultiDeviceBuffer> m_triangleIB;
 
         // rectangle vertex/index buffers
         AZStd::array<VertexPosition, 4> m_rectangleVertices;
         AZStd::array<uint16_t, 6> m_rectangleIndices;
 
-        RHI::Ptr<RHI::SingleDeviceBuffer> m_rectangleVB;
-        RHI::Ptr<RHI::SingleDeviceBuffer> m_rectangleIB;
+        RHI::Ptr<RHI::MultiDeviceBuffer> m_rectangleVB;
+        RHI::Ptr<RHI::MultiDeviceBuffer> m_rectangleIB;
 
         // ray tracing acceleration structures
         RHI::Ptr<RHI::SingleDeviceRayTracingBlas> m_triangleRayTracingBlas;
@@ -133,7 +133,7 @@ namespace AtomSampleViewer
             AZStd::array<uint16_t, 6> m_indices;
         };
 
-        RHI::Ptr<RHI::SingleDeviceBuffer> m_fullScreenInputAssemblyBuffer;
+        RHI::Ptr<RHI::MultiDeviceBuffer> m_fullScreenInputAssemblyBuffer;
         AZStd::array<RHI::SingleDeviceStreamBufferView, 2> m_fullScreenStreamBufferViews;
         RHI::SingleDeviceIndexBufferView m_fullScreenIndexBufferView;
         RHI::InputStreamLayout m_fullScreenInputStreamLayout;

+ 9 - 9
Gem/Code/Source/RHI/SphericalHarmonicsExampleComponent.cpp

@@ -93,21 +93,21 @@ namespace AtomSampleViewer
         }
 
         {
-            m_bufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_bufferPool = aznew RHI::MultiDeviceBufferPool();
 
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-            m_bufferPool->Init(*device, bufferPoolDesc);
+            m_bufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
             SetFullScreenRect(bufferData.m_positions.data(), bufferData.m_uvs.data(), bufferData.m_indices.data());
 
-            m_positionBuffer = RHI::Factory::Get().CreateBuffer();
-            m_indexBuffer = RHI::Factory::Get().CreateBuffer();
-            m_uvBuffer = RHI::Factory::Get().CreateBuffer();
+            m_positionBuffer = aznew RHI::MultiDeviceBuffer();
+            m_indexBuffer = aznew RHI::MultiDeviceBuffer();
+            m_uvBuffer = aznew RHI::MultiDeviceBuffer();
 
             RHI::ResultCode result = RHI::ResultCode::Success;
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
 
             request.m_buffer = m_positionBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, positionBufSize };
@@ -143,14 +143,14 @@ namespace AtomSampleViewer
             }
 
             m_streamBufferViews[0] = {
-                *m_positionBuffer,
+                *m_positionBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 0,
                 positionBufSize,
                 sizeof(VertexPosition)
             };
 
             m_streamBufferViews[1] = {
-                *m_uvBuffer,
+                *m_uvBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 0,
                 uvBufSize,
                 sizeof(VertexUV)
@@ -311,7 +311,7 @@ namespace AtomSampleViewer
 
                 const RHI::SingleDeviceIndexBufferView indexBufferView =
                 {
-                    *m_indexBuffer,
+                    *m_indexBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     0,
                     indexBufSize,
                     RHI::IndexFormat::Uint16

+ 5 - 5
Gem/Code/Source/RHI/SphericalHarmonicsExampleComponent.h

@@ -12,7 +12,7 @@
 
 #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI.Reflect/SamplerState.h>
 
@@ -123,10 +123,10 @@ namespace AtomSampleViewer
 
 
         // ---------------- streaming buffer variables ----------------
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_indexBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_positionBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_uvBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_indexBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_positionBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_uvBuffer;
 
         struct BufferData
         {

+ 7 - 7
Gem/Code/Source/RHI/StencilExampleComponent.cpp

@@ -52,12 +52,12 @@ namespace AtomSampleViewer
         RHI::PipelineStateDescriptorForDraw pipelineStateDescriptor;
 
         {
-            m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-            m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+            m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
 
             BufferData bufferData;
@@ -96,9 +96,9 @@ namespace AtomSampleViewer
             // Triangles index
             SetVertexIndexIncreasing(bufferData.m_indices.data(), s_numberOfVertices);
 
-            m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+            m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_inputAssemblyBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
             request.m_initialData = &bufferData;
@@ -106,7 +106,7 @@ namespace AtomSampleViewer
 
             m_streamBufferViews[0] =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(BufferData, m_positions),
                 sizeof(BufferData::m_positions),
                 sizeof(VertexPosition)
@@ -114,7 +114,7 @@ namespace AtomSampleViewer
 
             m_streamBufferViews[1] =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(BufferData, m_colors),
                 sizeof(BufferData::m_colors),
                 sizeof(VertexColor)
@@ -207,7 +207,7 @@ namespace AtomSampleViewer
 
                 const RHI::SingleDeviceIndexBufferView indexBufferView =
                 {
-                    *m_inputAssemblyBuffer,
+                    *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_indices),
                     sizeof(BufferData::m_indices),
                     RHI::IndexFormat::Uint16

+ 3 - 3
Gem/Code/Source/RHI/StencilExampleComponent.h

@@ -11,7 +11,7 @@
 
 #include <AzCore/Math/Vector3.h>
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/SingleDeviceImagePool.h>
@@ -47,8 +47,8 @@ namespace AtomSampleViewer
         // Triangles setting
         void SetTriangleVertices(int startIndex, VertexPosition* vertexData, AZ::Vector3 center, float offset);
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_pipelineStateBasePass;
         AZStd::array<AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState>, 8> m_pipelineStateStencil;

+ 1 - 1
Gem/Code/Source/RHI/SubpassExampleComponent.h

@@ -17,7 +17,7 @@
 #include <Atom/RPI.Public/Model/Model.h>
 #include <Atom/RPI.Public/Model/ModelLod.h>
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/Factory.h>

+ 1 - 1
Gem/Code/Source/RHI/Texture3dExampleComponent.h

@@ -12,7 +12,7 @@
 
 #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI.Reflect/SamplerState.h>
 

+ 7 - 7
Gem/Code/Source/RHI/TextureArrayExampleComponent.cpp

@@ -59,7 +59,7 @@ namespace AtomSampleViewer
         };
 
         RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
-        m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
         // Load the shader
         {
@@ -132,11 +132,11 @@ namespace AtomSampleViewer
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-            m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
-            m_rectangleInputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+            m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
+            m_rectangleInputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
             RHI::ResultCode result = RHI::ResultCode::Success;
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_rectangleInputAssemblyBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
             request.m_initialData = &bufferData;
@@ -148,14 +148,14 @@ namespace AtomSampleViewer
             }
 
             m_rectangleStreamBufferViews[0u] = {
-                *m_rectangleInputAssemblyBuffer,
+                *m_rectangleInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(RectangleBufferData, m_positions),
                 sizeof(RectangleBufferData::m_positions),
                 sizeof(VertexPosition)
             };
 
             m_rectangleStreamBufferViews[1u] = {
-                *m_rectangleInputAssemblyBuffer,
+                *m_rectangleInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(RectangleBufferData, m_uvs),
                 sizeof(RectangleBufferData::m_uvs),
                 sizeof(VertexUV)
@@ -207,7 +207,7 @@ namespace AtomSampleViewer
 
                 const RHI::SingleDeviceIndexBufferView indexBufferView =
                 {
-                    *m_rectangleInputAssemblyBuffer,
+                    *m_rectangleInputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(RectangleBufferData, m_indices),
                     sizeof(RectangleBufferData::m_indices),
                     RHI::IndexFormat::Uint16

+ 2 - 2
Gem/Code/Source/RHI/TextureArrayExampleComponent.h

@@ -39,8 +39,8 @@ namespace AtomSampleViewer
         // AZ::TickBus::Handler overrides...
         void OnTick(float deltaTime, AZ::ScriptTimePoint scriptTime);
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_rectangleInputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_rectangleInputAssemblyBuffer;
         AZStd::array<AZ::RHI::SingleDeviceStreamBufferView, 2> m_rectangleStreamBufferViews;
         AZ::RHI::InputStreamLayout m_rectangleInputStreamLayout;
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_pipelineState;

+ 9 - 9
Gem/Code/Source/RHI/TextureExampleComponent.cpp

@@ -58,21 +58,21 @@ namespace AtomSampleViewer
         AZ::RHI::PipelineStateDescriptorForDraw pipelineStateDescriptor;
 
         {
-            m_bufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_bufferPool = aznew RHI::MultiDeviceBufferPool();
 
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-            m_bufferPool->Init(*device, bufferPoolDesc);
+            m_bufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
             SetFullScreenRect(bufferData.m_positions.data(), bufferData.m_uvs.data(), bufferData.m_indices.data());
 
-            m_positionBuffer = RHI::Factory::Get().CreateBuffer();
-            m_indexBuffer = RHI::Factory::Get().CreateBuffer();
-            m_uvBuffer = RHI::Factory::Get().CreateBuffer();
+            m_positionBuffer = aznew RHI::MultiDeviceBuffer();
+            m_indexBuffer = aznew RHI::MultiDeviceBuffer();
+            m_uvBuffer = aznew RHI::MultiDeviceBuffer();
 
             RHI::ResultCode result = RHI::ResultCode::Success;
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
 
             request.m_buffer = m_positionBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, positionBufSize };
@@ -108,14 +108,14 @@ namespace AtomSampleViewer
             }
 
             m_streamBufferViews[0] = {
-                *m_positionBuffer,
+                *m_positionBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 0,
                 positionBufSize,
                 sizeof(VertexPosition)
             };
 
             m_streamBufferViews[1] = {
-                *m_uvBuffer,
+                *m_uvBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 0,
                 uvBufSize,
                 sizeof(VertexUV)
@@ -228,7 +228,7 @@ namespace AtomSampleViewer
 
                 const RHI::SingleDeviceIndexBufferView indexBufferView =
                 {
-                    *m_indexBuffer,
+                    *m_indexBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     0,
                     indexBufSize,
                     RHI::IndexFormat::Uint16

+ 5 - 5
Gem/Code/Source/RHI/TextureExampleComponent.h

@@ -12,7 +12,7 @@
 
 #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI.Reflect/SamplerState.h>
 
@@ -53,10 +53,10 @@ namespace AtomSampleViewer
         AZ::RHI::ShaderInputConstantIndex m_objectMatrixInputIndex;
         AZ::RHI::ShaderInputConstantIndex m_uvMatrixInputIndex;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_indexBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_positionBuffer;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_uvBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_indexBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_positionBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_uvBuffer;
 
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_pipelineState;
         AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> m_shaderResourceGroup;

+ 9 - 9
Gem/Code/Source/RHI/TextureMapExampleComponent.cpp

@@ -206,12 +206,12 @@ namespace AtomSampleViewer
     void TextureMapExampleComponent::CreateInputAssemblyBufferPool()
     {
         const AZ::RHI::Ptr<AZ::RHI::Device> device = Utils::GetRHIDevice();
-        m_inputAssemblyBufferPool = AZ::RHI::Factory::Get().CreateBufferPool();
+        m_inputAssemblyBufferPool = aznew AZ::RHI::MultiDeviceBufferPool();
 
         AZ::RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = AZ::RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = AZ::RHI::HeapMemoryLevel::Device;
-        m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+        m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
     }
 
     void TextureMapExampleComponent::InitRenderTargetBufferView()
@@ -767,9 +767,9 @@ namespace AtomSampleViewer
         uint32_t uvSize, void* uvData, uint32_t uvTypeSize,
         uint32_t indexSize, void* indexData)
     {
-        m_positionBuffer[target] = AZ::RHI::Factory::Get().CreateBuffer();
+        m_positionBuffer[target] = aznew AZ::RHI::MultiDeviceBuffer();
         AZ::RHI::ResultCode result = AZ::RHI::ResultCode::Success;
-        AZ::RHI::SingleDeviceBufferInitRequest request;
+        AZ::RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_positionBuffer[target].get();
         request.m_descriptor = AZ::RHI::BufferDescriptor{ AZ::RHI::BufferBindFlags::InputAssembly, posSize };
         request.m_initialData = posData;
@@ -782,13 +782,13 @@ namespace AtomSampleViewer
 
         m_bufferViews[target].m_streamBufferViews[0] =
         {
-            *m_positionBuffer[target],
+            *m_positionBuffer[target]->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             0,
             posSize,
             sizeof(VertexPosition)
         };
 
-        m_uvBuffer[target] = AZ::RHI::Factory::Get().CreateBuffer();
+        m_uvBuffer[target] = aznew AZ::RHI::MultiDeviceBuffer();
         request.m_buffer = m_uvBuffer[target].get();
         request.m_descriptor = AZ::RHI::BufferDescriptor{ AZ::RHI::BufferBindFlags::InputAssembly, uvSize };
         request.m_initialData = uvData;
@@ -801,13 +801,13 @@ namespace AtomSampleViewer
 
         m_bufferViews[target].m_streamBufferViews[1] =
         {
-            *m_uvBuffer[target],
+            *m_uvBuffer[target]->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             0,
             uvSize,
             uvTypeSize
         };
 
-        m_indexBuffer[target] = AZ::RHI::Factory::Get().CreateBuffer();
+        m_indexBuffer[target] = aznew AZ::RHI::MultiDeviceBuffer();
         request.m_buffer = m_indexBuffer[target].get();
         request.m_descriptor = AZ::RHI::BufferDescriptor{ AZ::RHI::BufferBindFlags::InputAssembly, indexSize };
         request.m_initialData = indexData;
@@ -820,7 +820,7 @@ namespace AtomSampleViewer
 
         m_bufferViews[target].m_indexBufferView =
         {
-            *m_indexBuffer[target],
+            *m_indexBuffer[target]->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             0,
             indexSize,
             AZ::RHI::IndexFormat::Uint16

+ 4 - 4
Gem/Code/Source/RHI/TextureMapExampleComponent.h

@@ -115,11 +115,11 @@ namespace AtomSampleViewer
         // -------------------------------------
         // Input Assembly buffer and buffer view
         // -------------------------------------
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
         // array for buffer and buffer view ( all render targets + screen)
-        AZStd::array< AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer>, s_numOfTargets + 1> m_positionBuffer;
-        AZStd::array< AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer>, s_numOfTargets + 1> m_uvBuffer;
-        AZStd::array< AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer>, s_numOfTargets + 1> m_indexBuffer;
+        AZStd::array< AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer>, s_numOfTargets + 1> m_positionBuffer;
+        AZStd::array< AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer>, s_numOfTargets + 1> m_uvBuffer;
+        AZStd::array< AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer>, s_numOfTargets + 1> m_indexBuffer;
         AZStd::array<BufferViewData, s_numOfTargets + 1> m_bufferViews;
 
         // ---------------------------------------

+ 7 - 7
Gem/Code/Source/RHI/TriangleExampleComponent.cpp

@@ -66,12 +66,12 @@ namespace AtomSampleViewer
         AZ::RHI::PipelineStateDescriptorForDraw pipelineStateDescriptor;
 
         {
-            m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-            m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+            m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
             BufferData bufferData;
 
@@ -85,9 +85,9 @@ namespace AtomSampleViewer
 
             SetVertexIndexIncreasing(bufferData.m_indices.data(), bufferData.m_indices.size());
 
-            m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+            m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_inputAssemblyBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
             request.m_initialData = &bufferData;
@@ -95,7 +95,7 @@ namespace AtomSampleViewer
 
             m_streamBufferViews[0] =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(BufferData, m_positions),
                 sizeof(BufferData::m_positions),
                 sizeof(VertexPosition)
@@ -103,7 +103,7 @@ namespace AtomSampleViewer
 
             m_streamBufferViews[1] =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(BufferData, m_colors),
                 sizeof(BufferData::m_colors),
                 sizeof(VertexColor)
@@ -198,7 +198,7 @@ namespace AtomSampleViewer
 
                 const RHI::SingleDeviceIndexBufferView indexBufferView =
                 {
-                    *m_inputAssemblyBuffer,
+                    *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                     offsetof(BufferData, m_indices),
                     sizeof(BufferData::m_indices),
                     RHI::IndexFormat::Uint16

+ 3 - 3
Gem/Code/Source/RHI/TriangleExampleComponent.h

@@ -17,7 +17,7 @@
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/Factory.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 
 #include <AzCore/Math/Matrix4x4.h>
 
@@ -47,8 +47,8 @@ namespace AtomSampleViewer
         void OnFramePrepare(AZ::RHI::FrameGraphBuilder& frameGraphBuilder) override;
 
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_pipelineState;
         AZ::Data::Instance<AZ::RPI::ShaderResourceGroup> m_shaderResourceGroup;

+ 16 - 16
Gem/Code/Source/RHI/TrianglesConstantBufferExampleComponent.cpp

@@ -95,14 +95,14 @@ namespace AtomSampleViewer
 
     void TrianglesConstantBufferExampleComponent::UploadDataToConstantBuffer(InstanceInfo* data, uint32_t elementSize, uint32_t elementCount)
     {
-        AZ::RHI::SingleDeviceBufferMapRequest mapRequest;
+        AZ::RHI::MultiDeviceBufferMapRequest mapRequest;
         mapRequest.m_buffer = m_constantBuffer.get();
         mapRequest.m_byteCount = elementSize * elementCount;
-        AZ::RHI::SingleDeviceBufferMapResponse mapResponse;
+        AZ::RHI::MultiDeviceBufferMapResponse mapResponse;
         AZ::RHI::ResultCode resultCode = m_constantBufferPool->MapBuffer(mapRequest, mapResponse);
         if (resultCode == AZ::RHI::ResultCode::Success)
         {
-            memcpy(mapResponse.m_data, data, sizeof(InstanceInfo) * elementCount);
+            memcpy(mapResponse.m_data[AZ::RHI::MultiDevice::DefaultDeviceIndex], data, sizeof(InstanceInfo) * elementCount);
             m_constantBufferPool->UnmapBuffer(*mapRequest.m_buffer);
         }
     }
@@ -117,12 +117,12 @@ namespace AtomSampleViewer
 
         // Creates Input Assembly buffer and Streams/Index Views
         {
-            m_inputAssemblyBufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_inputAssemblyBufferPool = aznew RHI::MultiDeviceBufferPool();
 
             RHI::BufferPoolDescriptor bufferPoolDesc;
             bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
             bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-            m_inputAssemblyBufferPool->Init(*device, bufferPoolDesc);
+            m_inputAssemblyBufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
             IABufferData bufferData;
 
@@ -136,9 +136,9 @@ namespace AtomSampleViewer
 
             SetVertexIndexIncreasing(bufferData.m_indices.data(), bufferData.m_indices.size());
 
-            m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+            m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
 
-            RHI::SingleDeviceBufferInitRequest request;
+            RHI::MultiDeviceBufferInitRequest request;
             request.m_buffer = m_inputAssemblyBuffer.get();
             request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
             request.m_initialData = &bufferData;
@@ -146,7 +146,7 @@ namespace AtomSampleViewer
 
             m_streamBufferViews[0] =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(IABufferData, m_positions),
                 sizeof(IABufferData::m_positions),
                 sizeof(VertexPosition)
@@ -154,7 +154,7 @@ namespace AtomSampleViewer
 
             m_streamBufferViews[1] =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(IABufferData, m_colors),
                 sizeof(IABufferData::m_colors),
                 sizeof(VertexColor)
@@ -162,7 +162,7 @@ namespace AtomSampleViewer
 
             m_indexBufferView =
             {
-                *m_inputAssemblyBuffer,
+                *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
                 offsetof(IABufferData, m_indices),
                 sizeof(IABufferData::m_indices),
                 RHI::IndexFormat::Uint16
@@ -178,12 +178,12 @@ namespace AtomSampleViewer
 
         // Create the buffer pool where both buffers get allocated from
         {
-            m_constantBufferPool = RHI::Factory::Get().CreateBufferPool();
+            m_constantBufferPool = aznew RHI::MultiDeviceBufferPool();
             RHI::BufferPoolDescriptor constantBufferPoolDesc;
             constantBufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::Constant;
             constantBufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
             constantBufferPoolDesc.m_hostMemoryAccess = RHI::HostMemoryAccess::Write;
-            [[maybe_unused]] RHI::ResultCode result = m_constantBufferPool->Init(*device, constantBufferPoolDesc);
+            [[maybe_unused]] RHI::ResultCode result = m_constantBufferPool->Init(RHI::MultiDevice::DefaultDevice, constantBufferPoolDesc);
             AZ_Assert(result == RHI::ResultCode::Success, "Failed to initialized constant buffer pool");
         }
 
@@ -218,7 +218,7 @@ namespace AtomSampleViewer
             RHI::ShaderInputBufferIndex trianglesBufferIndex;
             FindShaderInputIndex(&trianglesBufferIndex, m_shaderResourceGroup, trianglesBufferId, s_trianglesConstantBufferExampleName);
 
-            [[maybe_unused]] bool set = m_shaderResourceGroup->SetBufferView(trianglesBufferIndex, m_constantBufferView.get(), 0);
+            [[maybe_unused]] bool set = m_shaderResourceGroup->SetBufferView(trianglesBufferIndex, m_constantBufferView->GetDeviceBufferView(RHI::MultiDevice::DefaultDeviceIndex).get(), 0);
             AZ_Assert(set, "Failed to set the buffer view");
 
             // All SRG data has been set already, it only had the buffer view to be set, we can compile now.
@@ -297,15 +297,15 @@ namespace AtomSampleViewer
         using namespace AZ;
         const uint32_t constantBufferSize = sizeof(InstanceInfo) * s_numberOfTrianglesTotal;
 
-        m_constantBuffer = RHI::Factory::Get().CreateBuffer();
-        RHI::SingleDeviceBufferInitRequest request;
+        m_constantBuffer = aznew RHI::MultiDeviceBuffer();
+        RHI::MultiDeviceBufferInitRequest request;
         request.m_buffer = m_constantBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::Constant, constantBufferSize };
         [[maybe_unused]] RHI::ResultCode result = m_constantBufferPool->InitBuffer(request);
         AZ_Assert(result == RHI::ResultCode::Success, "Failed to initialize constant buffer");
 
         RHI::BufferViewDescriptor bufferDesc = RHI::BufferViewDescriptor::CreateStructured(0, 1u, constantBufferSize);
-        m_constantBufferView = m_constantBuffer->GetBufferView(bufferDesc);
+        m_constantBufferView = m_constantBuffer->BuildBufferView(bufferDesc);
     }
 
     void TrianglesConstantBufferExampleComponent::Deactivate()

+ 6 - 6
Gem/Code/Source/RHI/TrianglesConstantBufferExampleComponent.h

@@ -22,7 +22,7 @@
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/Factory.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 
 #include <AzCore/Math/Matrix4x4.h>
 
@@ -91,17 +91,17 @@ namespace AtomSampleViewer
             AZStd::array<uint16_t, 3> m_indices;
         };
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_inputAssemblyBufferPool;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_inputAssemblyBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
 
         AZStd::array<AZ::RHI::SingleDeviceStreamBufferView, 2> m_streamBufferViews;
         AZ::RHI::SingleDeviceIndexBufferView m_indexBufferView;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_constantBufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_constantBufferPool;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_constantBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_constantBuffer;
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferView> m_constantBufferView;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferView> m_constantBufferView;
 
         // --------------------------------------------------------
         // Pipeline state and SRG to be constructed from the shader

+ 7 - 7
Gem/Code/Source/RHI/VariableRateShadingExampleComponent.cpp

@@ -446,11 +446,11 @@ namespace AtomSampleViewer
     {
         const RHI::Ptr<RHI::Device> device = Utils::GetRHIDevice();
 
-        m_bufferPool = RHI::Factory::Get().CreateBufferPool();
+        m_bufferPool = aznew RHI::MultiDeviceBufferPool();
         RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = RHI::HeapMemoryLevel::Device;
-        m_bufferPool->Init(*device, bufferPoolDesc);
+        m_bufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
 
         struct BufferData
         {
@@ -462,9 +462,9 @@ namespace AtomSampleViewer
         BufferData bufferData;
         SetFullScreenRect(bufferData.m_positions.data(), bufferData.m_uvs.data(), bufferData.m_indices.data());
 
-        m_inputAssemblyBuffer = RHI::Factory::Get().CreateBuffer();
+        m_inputAssemblyBuffer = aznew RHI::MultiDeviceBuffer();
         RHI::ResultCode result = RHI::ResultCode::Success;
-        RHI::SingleDeviceBufferInitRequest request;
+        RHI::MultiDeviceBufferInitRequest request;
 
         request.m_buffer = m_inputAssemblyBuffer.get();
         request.m_descriptor = RHI::BufferDescriptor{ RHI::BufferBindFlags::InputAssembly, sizeof(bufferData) };
@@ -478,7 +478,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[0] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_positions),
             sizeof(BufferData::m_positions),
             sizeof(VertexPosition)
@@ -486,7 +486,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[1] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_uvs),
             sizeof(BufferData::m_uvs),
             sizeof(VertexUV)
@@ -494,7 +494,7 @@ namespace AtomSampleViewer
 
         m_indexBufferView =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(BufferData, m_indices),
             sizeof(BufferData::m_indices),
             RHI::IndexFormat::Uint16

+ 3 - 3
Gem/Code/Source/RHI/VariableRateShadingExampleComponent.h

@@ -20,7 +20,7 @@
 #include <Atom/RPI.Public/Shader/Shader.h>
 #include <Atom/RPI.Public/Shader/ShaderResourceGroup.h>
 
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 #include <Atom/RHI/SingleDeviceDrawItem.h>
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/Factory.h>
@@ -133,9 +133,9 @@ namespace AtomSampleViewer
         int m_numThreadsZ = 1;
 
         // Bufferpool for creating the IA buffer
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool;
         // Buffer for the IA of the full screen quad.
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
         // Bufferviews into the full screen quad IA
         AZStd::array<AZ::RHI::SingleDeviceStreamBufferView, 2> m_streamBufferViews;
         // Indexview of the full screen quad index buffer

+ 7 - 7
Gem/Code/Source/RHI/XRExampleComponent.cpp

@@ -194,11 +194,11 @@ namespace AtomSampleViewer
         const AZ::RHI::Ptr<AZ::RHI::Device> device = Utils::GetRHIDevice();
         AZ::RHI::ResultCode result = AZ::RHI::ResultCode::Success;
 
-        m_bufferPool = AZ::RHI::Factory::Get().CreateBufferPool();
+        m_bufferPool = aznew AZ::RHI::MultiDeviceBufferPool();
         AZ::RHI::BufferPoolDescriptor bufferPoolDesc;
         bufferPoolDesc.m_bindFlags = AZ::RHI::BufferBindFlags::InputAssembly;
         bufferPoolDesc.m_heapMemoryLevel = AZ::RHI::HeapMemoryLevel::Device;
-        result = m_bufferPool->Init(*device, bufferPoolDesc);
+        result = m_bufferPool->Init(RHI::MultiDevice::DefaultDevice, bufferPoolDesc);
         if (result != AZ::RHI::ResultCode::Success)
         {
             AZ_Error("XRExampleComponent", false, "Failed to initialize buffer pool with error code %d", result);
@@ -207,8 +207,8 @@ namespace AtomSampleViewer
 
         SingleCubeBufferData bufferData = CreateSingleCubeBufferData();
 
-        m_inputAssemblyBuffer = AZ::RHI::Factory::Get().CreateBuffer();
-        AZ::RHI::SingleDeviceBufferInitRequest request;
+        m_inputAssemblyBuffer = aznew AZ::RHI::MultiDeviceBuffer();
+        AZ::RHI::MultiDeviceBufferInitRequest request;
 
         request.m_buffer = m_inputAssemblyBuffer.get();
         request.m_descriptor = AZ::RHI::BufferDescriptor{ AZ::RHI::BufferBindFlags::InputAssembly, sizeof(SingleCubeBufferData) };
@@ -222,7 +222,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[0] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(SingleCubeBufferData, m_positions),
             sizeof(SingleCubeBufferData::m_positions),
             sizeof(VertexPosition)
@@ -230,7 +230,7 @@ namespace AtomSampleViewer
 
         m_streamBufferViews[1] =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(SingleCubeBufferData, m_colors),
             sizeof(SingleCubeBufferData::m_colors),
             sizeof(VertexColor)
@@ -238,7 +238,7 @@ namespace AtomSampleViewer
 
         m_indexBufferView =
         {
-            *m_inputAssemblyBuffer,
+            *m_inputAssemblyBuffer->GetDeviceBuffer(RHI::MultiDevice::DefaultDeviceIndex),
             offsetof(SingleCubeBufferData, m_indices),
             sizeof(SingleCubeBufferData::m_indices),
             AZ::RHI::IndexFormat::Uint16

+ 3 - 3
Gem/Code/Source/RHI/XRExampleComponent.h

@@ -18,7 +18,7 @@
 #include <Atom/RHI/Device.h>
 #include <Atom/RHI/Factory.h>
 #include <Atom/RHI/SingleDevicePipelineState.h>
-#include <Atom/RHI/SingleDeviceBufferPool.h>
+#include <Atom/RHI/MultiDeviceBufferPool.h>
 
 #include <AzCore/Math/Matrix4x4.h>
 
@@ -94,9 +94,9 @@ namespace AtomSampleViewer
         //! Create the relevant Scope
         void CreateScope();
 
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBufferPool> m_bufferPool;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBufferPool> m_bufferPool;
         AZ::RHI::SingleDeviceIndexBufferView m_indexBufferView;
-        AZ::RHI::Ptr<AZ::RHI::SingleDeviceBuffer> m_inputAssemblyBuffer;
+        AZ::RHI::Ptr<AZ::RHI::MultiDeviceBuffer> m_inputAssemblyBuffer;
         AZ::RHI::InputStreamLayout m_streamLayoutDescriptor;
         AZ::RHI::ConstPtr<AZ::RHI::SingleDevicePipelineState> m_pipelineState;