浏览代码

Fixed bindless example for a MultiGPU setup

Signed-off-by: Martin Sattlecker <[email protected]>
Martin Sattlecker 9 月之前
父节点
当前提交
5456706271
共有 1 个文件被更改,包括 14 次插入4 次删除
  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());
             views.push_back(m_computeImageView.get());
             isViewReadOnly.push_back(false);
             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
             // Populate the indirect buffer with indices of the views that reside within the bindless heap
             uint32_t arrayIndex = 0;
             uint32_t arrayIndex = 0;
             auto indirectionBufferIndex = indirectionBufferSrg->FindShaderInputBufferIndex(AZ::Name{ "m_imageIndirectionBuffer" });
             auto indirectionBufferIndex = indirectionBufferSrg->FindShaderInputBufferIndex(AZ::Name{ "m_imageIndirectionBuffer" });
             indirectionBufferSrg->SetBindlessViews(
             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);
             m_bufferPool->UnmapBuffer(*m_imageIndirectionBuffer);
         }
         }
@@ -796,12 +801,17 @@ namespace AtomSampleViewer
             views.push_back(m_computeBufferView.get());
             views.push_back(m_computeBufferView.get());
             isViewReadOnly.push_back(false);
             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
             //Populate the indirect buffer with indices of the views that reside within the bindless heap
             uint32_t arrayIndex = 0;
             uint32_t arrayIndex = 0;
             auto indirectionBufferIndex = indirectionBufferSrg->FindShaderInputBufferIndex(AZ::Name{ "m_bufferIndirectionBuffer" });
             auto indirectionBufferIndex = indirectionBufferSrg->FindShaderInputBufferIndex(AZ::Name{ "m_bufferIndirectionBuffer" });
             indirectionBufferSrg->SetBindlessViews(
             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);
             m_bufferPool->UnmapBuffer(*m_bufferIndirectionBuffer);
         }
         }