Sfoglia il codice sorgente

Fixed bindless example for a MultiGPU setup

Signed-off-by: Martin Sattlecker <[email protected]>
Martin Sattlecker 7 mesi fa
parent
commit
5456706271
1 ha cambiato i file con 14 aggiunte e 4 eliminazioni
  1. 14 4
      Gem/Code/Source/RHI/BindlessPrototypeExampleComponent.cpp

+ 14 - 4
Gem/Code/Source/RHI/BindlessPrototypeExampleComponent.cpp

@@ -767,12 +767,17 @@ namespace AtomSampleViewer
             views.push_back(m_computeImageView.get());
             isViewReadOnly.push_back(false);
 
+            AZStd::unordered_map<int, uint32_t*> mappedData;
+            for (auto [deviceIndex, data] : mapResponse.m_data)
+            {
+                mappedData[deviceIndex] = static_cast<uint32_t*>(data);
+            }
+
             // 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_imageIndirectionBuffer" });
             indirectionBufferSrg->SetBindlessViews(
-                indirectionBufferIndex, m_imageIndirectionBufferView.get(), views, static_cast<uint32_t*>(mapResponse.m_data[RHI::MultiDevice::DefaultDeviceIndex]),
-                isViewReadOnly, arrayIndex);
+                indirectionBufferIndex, m_imageIndirectionBufferView.get(), views, mappedData, isViewReadOnly, arrayIndex);
 
             m_bufferPool->UnmapBuffer(*m_imageIndirectionBuffer);
         }
@@ -796,12 +801,17 @@ namespace AtomSampleViewer
             views.push_back(m_computeBufferView.get());
             isViewReadOnly.push_back(false);
 
+            AZStd::unordered_map<int, uint32_t*> mappedData;
+            for (auto [deviceIndex, data] : mapResponse.m_data)
+            {
+                mappedData[deviceIndex] = static_cast<uint32_t*>(data);
+            }
+
             //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[RHI::MultiDevice::DefaultDeviceIndex]),
-                isViewReadOnly, arrayIndex);
+                indirectionBufferIndex, m_bufferIndirectionBufferView.get(), views, mappedData, isViewReadOnly, arrayIndex);
 
             m_bufferPool->UnmapBuffer(*m_bufferIndirectionBuffer);
         }