Skip to content

Commit b3cccef

Browse files
Pass on Name to DeviceObjects (o3de#18126)
Signed-off-by: Martin Winter <[email protected]>
1 parent a844ead commit b3cccef

19 files changed

+136
-4
lines changed

Gems/Atom/RHI/Code/Include/Atom/RHI/MultiDeviceObject.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,9 @@ namespace AZ::RHI
159159
//! Returns the number of initialized devices
160160
int GetDeviceCount() const;
161161

162+
//! Pass on name to DeviceObjects
163+
virtual void SetNameInternal(const AZStd::string_view& name) override;
164+
162165
//! A bitmask denoting on which devices an object is present/valid/allocated
163166
MultiDevice::DeviceMask m_deviceMask{ 0u };
164167
};

Gems/Atom/RHI/Code/Source/RHI/BufferPool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,7 @@ namespace AZ::RHI
124124
auto* device = RHISystemInterface::Get()->GetDevice(deviceIndex);
125125

126126
m_deviceObjects[deviceIndex] = Factory::Get().CreateBufferPool();
127+
127128
result = GetDeviceBufferPool(deviceIndex)->Init(*device, descriptor);
128129

129130
return result == ResultCode::Success;

Gems/Atom/RHI/Code/Source/RHI/Fence.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ namespace AZ::RHI
5050
auto* device = RHISystemInterface::Get()->GetDevice(deviceIndex);
5151

5252
m_deviceObjects[deviceIndex] = Factory::Get().CreateFence();
53+
5354
resultCode = GetDeviceFence(deviceIndex)->Init(*device, initialState);
5455

5556
return resultCode == ResultCode::Success;
@@ -62,6 +63,11 @@ namespace AZ::RHI
6263
MultiDeviceObject::Init(static_cast<MultiDevice::DeviceMask>(0u));
6364
}
6465

66+
if (const auto& name = GetName(); !name.IsEmpty())
67+
{
68+
SetName(name);
69+
}
70+
6571
return resultCode;
6672
}
6773

Gems/Atom/RHI/Code/Source/RHI/ImagePool.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ namespace AZ::RHI
2929
auto* device = RHISystemInterface::Get()->GetDevice(deviceIndex);
3030

3131
m_deviceObjects[deviceIndex] = Factory::Get().CreateImagePool();
32+
3233
GetDeviceImagePool(deviceIndex)->Init(*device, descriptor);
3334

3435
return true;

Gems/Atom/RHI/Code/Source/RHI/IndirectBufferSignature.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ namespace AZ::RHI
3939
auto device = RHISystemInterface::Get()->GetDevice(deviceIndex);
4040

4141
m_deviceObjects[deviceIndex] = Factory::Get().CreateIndirectBufferSignature();
42+
4243
resultCode = GetDeviceIndirectBufferSignature(deviceIndex)->Init(
4344
*device, descriptor.GetDeviceIndirectBufferSignatureDescriptor(deviceIndex));
4445

@@ -51,6 +52,11 @@ namespace AZ::RHI
5152
return resultCode == ResultCode::Success;
5253
});
5354

55+
if (const auto& name = GetName(); !name.IsEmpty())
56+
{
57+
SetName(name);
58+
}
59+
5460
m_descriptor = descriptor;
5561

5662
return resultCode;

Gems/Atom/RHI/Code/Source/RHI/MultiDeviceObject.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,16 @@ namespace AZ::RHI
2626
m_deviceMask = deviceMask;
2727
}
2828

29+
void MultiDeviceObject::SetNameInternal(const AZStd::string_view& name)
30+
{
31+
IterateObjects<DeviceObject>(
32+
[&name]([[maybe_unused]] auto deviceIndex, auto deviceObject)
33+
{
34+
AZStd::string deviceName{ AZStd::string{ name } + AZStd::to_string(deviceIndex) };
35+
deviceObject->SetName(Name(deviceName));
36+
});
37+
}
38+
2939
void MultiDeviceObject::Shutdown()
3040
{
3141
m_deviceMask = static_cast<MultiDevice::DeviceMask>(0u);

Gems/Atom/RHI/Code/Source/RHI/PipelineLibrary.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ namespace AZ::RHI
5454
auto* device = RHISystemInterface::Get()->GetDevice(deviceIndex);
5555

5656
m_deviceObjects[deviceIndex] = Factory::Get().CreatePipelineLibrary();
57+
5758
resultCode = GetDevicePipelineLibrary(deviceIndex)->Init(*device, descriptor.GetDevicePipelineLibraryDescriptor(deviceIndex));
5859

5960
return resultCode == ResultCode::Success;
@@ -66,6 +67,10 @@ namespace AZ::RHI
6667
MultiDeviceObject::Init(static_cast<MultiDevice::DeviceMask>(0u));
6768
}
6869

70+
if (const auto& name = GetName(); !name.IsEmpty())
71+
{
72+
SetName(name);
73+
}
6974

7075
return resultCode;
7176
}

Gems/Atom/RHI/Code/Source/RHI/PipelineState.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,11 @@ namespace AZ::RHI
128128
MultiDeviceObject::Init(static_cast<MultiDevice::DeviceMask>(0u));
129129
}
130130

131+
if (const auto& name = GetName(); !name.IsEmpty())
132+
{
133+
SetName(name);
134+
}
135+
131136
return resultCode;
132137
}
133138

Gems/Atom/RHI/Code/Source/RHI/QueryPool.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ namespace AZ::RHI
5757
auto* device = RHISystemInterface::Get()->GetDevice(deviceIndex);
5858

5959
m_deviceObjects[deviceIndex] = Factory::Get().CreateQueryPool();
60+
61+
if (const auto& name = GetName(); !name.IsEmpty())
62+
{
63+
m_deviceObjects[deviceIndex]->SetName(name);
64+
}
65+
6066
resultCode = GetDeviceQueryPool(deviceIndex)->Init(*device, descriptor);
6167
return resultCode == ResultCode::Success;
6268
});
@@ -102,6 +108,11 @@ namespace AZ::RHI
102108
for (auto index{ 0u }; index < queryCount; ++index)
103109
{
104110
queries[index]->m_deviceObjects[deviceIndex] = deviceQueries[index];
111+
112+
if (const auto& name = queries[index]->GetName(); !name.IsEmpty())
113+
{
114+
queries[index]->m_deviceObjects[deviceIndex]->SetName(name);
115+
}
105116
}
106117

107118
return resultCode;

Gems/Atom/RHI/Code/Source/RHI/RayTracingAccelerationStructure.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,11 @@ namespace AZ::RHI
217217
MultiDeviceObject::Init(static_cast<MultiDevice::DeviceMask>(0u));
218218
}
219219

220+
if (const auto& name = GetName(); !name.IsEmpty())
221+
{
222+
SetName(name);
223+
}
224+
220225
return resultCode;
221226
}
222227

@@ -270,6 +275,11 @@ namespace AZ::RHI
270275
MultiDeviceObject::Init(static_cast<MultiDevice::DeviceMask>(0u));
271276
}
272277

278+
if (const auto& name = GetName(); !name.IsEmpty())
279+
{
280+
SetName(name);
281+
}
282+
273283
// Each call to CreateBuffers advances m_currentBufferIndex internally, reset buffers to always receive currently active
274284
m_tlasBuffer.reset();
275285
m_tlasInstancesBuffer.reset();
@@ -309,6 +319,11 @@ namespace AZ::RHI
309319
return ResultCode::Success;
310320
});
311321

322+
if (const auto& name = m_tlasBuffer->GetName(); !name.IsEmpty())
323+
{
324+
m_tlasBuffer->SetName(name);
325+
}
326+
312327
return m_tlasBuffer;
313328
}
314329

@@ -344,6 +359,11 @@ namespace AZ::RHI
344359
m_tlasInstancesBuffer->SetDescriptor(m_tlasInstancesBuffer->GetDeviceBuffer(deviceIndex)->GetDescriptor());
345360
return ResultCode::Success;
346361
});
362+
363+
if (const auto& name = m_tlasInstancesBuffer->GetName(); !name.IsEmpty())
364+
{
365+
m_tlasInstancesBuffer->SetName(name);
366+
}
347367
return m_tlasInstancesBuffer;
348368
}
349369
} // namespace AZ::RHI

Gems/Atom/RHI/Code/Source/RHI/RayTracingBufferPools.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,16 @@ namespace AZ::RHI
6464
{
6565
RHI::Ptr<RHI::Device> device = RHISystemInterface::Get()->GetDevice(deviceIndex);
6666
m_deviceObjects[deviceIndex] = Factory::Get().CreateRayTracingBufferPools();
67+
6768
GetDeviceRayTracingBufferPools(deviceIndex)->Init(device);
6869
return true;
6970
});
7071

72+
if (const auto& name = GetName(); !name.IsEmpty())
73+
{
74+
SetName(name);
75+
}
76+
7177
m_shaderTableBufferPool = aznew RHI::BufferPool();
7278
m_shaderTableBufferPool->Init(
7379
deviceMask,

Gems/Atom/RHI/Code/Source/RHI/RayTracingPipelineState.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,11 @@ namespace AZ::RHI
132132
MultiDeviceObject::Init(static_cast<MultiDevice::DeviceMask>(0u));
133133
}
134134

135+
if (const auto& name = GetName(); !name.IsEmpty())
136+
{
137+
SetName(name);
138+
}
139+
135140
return resultCode;
136141
}
137142

Gems/Atom/RHI/Code/Source/RHI/RayTracingShaderTable.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,11 @@ namespace AZ::RHI
126126

127127
return true;
128128
});
129+
130+
if (const auto& name = GetName(); !name.IsEmpty())
131+
{
132+
SetName(name);
133+
}
129134
}
130135

131136
void RayTracingShaderTable::Build(const AZStd::shared_ptr<RayTracingShaderTableDescriptor> descriptor)

Gems/Atom/RHI/Code/Source/RHI/ResourcePool.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,11 @@ namespace AZ::RHI
100100

101101
ResultCode resultCode = platformInitMethod();
102102

103+
if (const auto& name = GetName(); !name.IsEmpty())
104+
{
105+
SetName(name);
106+
}
107+
103108
return resultCode;
104109
}
105110

@@ -135,6 +140,11 @@ namespace AZ::RHI
135140
{
136141
resource->Init(GetDeviceMask());
137142
Register(*resource);
143+
144+
if (const auto& name = resource->GetName(); !name.IsEmpty())
145+
{
146+
resource->SetName(name);
147+
}
138148
}
139149
return resultCode;
140150
}

Gems/Atom/RHI/Code/Source/RHI/ShaderResourceGroupPool.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ namespace AZ::RHI
3636
auto* device = RHISystemInterface::Get()->GetDevice(deviceIndex);
3737

3838
m_deviceObjects[deviceIndex] = Factory::Get().CreateShaderResourceGroupPool();
39+
3940
GetDeviceShaderResourceGroupPool(deviceIndex)->Init(*device, descriptor);
4041

4142
return true;
@@ -69,6 +70,7 @@ namespace AZ::RHI
6970
return IterateObjects<DeviceShaderResourceGroupPool>([this, &group](auto deviceIndex, [[maybe_unused]] auto deviceShaderResourceGroupPool)
7071
{
7172
group.m_deviceObjects[deviceIndex] = Factory::Get().CreateShaderResourceGroup();
73+
7274
return GetDeviceShaderResourceGroupPool(deviceIndex)->InitGroup(*group.GetDeviceShaderResourceGroup(deviceIndex));
7375
});
7476
});

Gems/Atom/RHI/Code/Source/RHI/StreamingImagePool.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,7 @@ namespace AZ::RHI
8383
auto* device = RHISystemInterface::Get()->GetDevice(deviceIndex);
8484

8585
m_deviceObjects[deviceIndex] = Factory::Get().CreateStreamingImagePool();
86+
8687
result = GetDeviceStreamingImagePool(deviceIndex)->Init(*device, descriptor);
8788

8889
return result == ResultCode::Success;
@@ -121,6 +122,7 @@ namespace AZ::RHI
121122
return IterateObjects<DeviceStreamingImagePool>([&initRequest](auto deviceIndex, auto deviceStreamingImagePool)
122123
{
123124
initRequest.m_image->m_deviceObjects[deviceIndex] = Factory::Get().CreateImage();
125+
124126
DeviceStreamingImageInitRequest streamingImageInitRequest(
125127
*initRequest.m_image->GetDeviceImage(deviceIndex), initRequest.m_descriptor, initRequest.m_tailMipSlices);
126128
return deviceStreamingImagePool->InitImage(streamingImageInitRequest);

Gems/Atom/RHI/Code/Source/RHI/SwapChain.cpp

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ namespace AZ::RHI
5757
auto* device = RHISystemInterface::Get()->GetDevice(deviceIndex);
5858

5959
m_deviceObjects[deviceIndex] = Factory::Get().CreateSwapChain();
60+
6061
result = GetDeviceSwapChain(deviceIndex)->Init(*device, descriptor);
6162
nativeDimensions = GetDeviceSwapChain(deviceIndex)->GetDescriptor().m_dimensions;
6263

@@ -74,6 +75,11 @@ namespace AZ::RHI
7475
m_descriptor.m_dimensions = nativeDimensions;
7576

7677
resultCode = InitImages();
78+
79+
if (const auto& name = GetName(); !name.IsEmpty())
80+
{
81+
SetName(name);
82+
}
7783
}
7884
else
7985
{
@@ -136,10 +142,11 @@ namespace AZ::RHI
136142
{
137143
ResultCode result = ResultCode::Success;
138144

139-
IterateObjects<DeviceSwapChain>([this, imageIdx](auto deviceIndex, auto deviceSwapChain)
140-
{
141-
m_images[imageIdx]->m_deviceObjects[deviceIndex] = deviceSwapChain->GetImage(imageIdx);
142-
});
145+
IterateObjects<DeviceSwapChain>(
146+
[this, imageIdx](auto deviceIndex, auto deviceSwapChain)
147+
{
148+
m_images[imageIdx]->m_deviceObjects[deviceIndex] = deviceSwapChain->GetImage(imageIdx);
149+
});
143150

144151
return result;
145152
});

Gems/Atom/RHI/Code/Source/RHI/TransientAttachmentPool.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,11 @@ namespace AZ::RHI
5454
MultiDeviceObject::Init(static_cast<MultiDevice::DeviceMask>(0u));
5555
}
5656

57+
if (const auto& name = GetName(); !name.IsEmpty())
58+
{
59+
SetName(name);
60+
}
61+
5762
return resultCode;
5863
}
5964

@@ -153,6 +158,11 @@ namespace AZ::RHI
153158
{
154159
image->m_deviceObjects[deviceIndex] = deviceImage;
155160
image->SetDescriptor(deviceImage->GetDescriptor());
161+
162+
if (const auto& name = image->GetName(); !name.IsEmpty())
163+
{
164+
image->m_deviceObjects[deviceIndex]->SetName(name);
165+
}
156166
}
157167
else
158168
{
@@ -213,6 +223,11 @@ namespace AZ::RHI
213223
{
214224
buffer->m_deviceObjects[deviceIndex] = deviceBuffer;
215225
buffer->SetDescriptor(deviceBuffer->GetDescriptor());
226+
227+
if (const auto& name = buffer->GetName(); !name.IsEmpty())
228+
{
229+
buffer->m_deviceObjects[deviceIndex]->SetName(name);
230+
}
216231
}
217232
else
218233
{

Gems/Atom/RHI/Code/Tests/MultiDeviceDrawPacketTests.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,15 @@ namespace UnitTest
7676
[this](int deviceIndex)
7777
{
7878
this->m_psoEmpty->m_deviceObjects[deviceIndex] = RHI::Factory::Get().CreatePipelineState();
79+
7980
return true;
8081
});
8182

83+
if (const auto& name = this->m_psoEmpty->GetName(); !name.IsEmpty())
84+
{
85+
this->m_psoEmpty->SetName(name);
86+
}
87+
8288
for (auto& srg : m_srgs)
8389
{
8490
srg = aznew RHI::ShaderResourceGroup;
@@ -87,8 +93,14 @@ namespace UnitTest
8793
[&srg](int deviceIndex)
8894
{
8995
srg->m_deviceObjects[deviceIndex] = RHI::Factory::Get().CreateShaderResourceGroup();
96+
9097
return true;
9198
});
99+
100+
if (const auto& name = srg->GetName(); !name.IsEmpty())
101+
{
102+
srg->SetName(name);
103+
}
92104
}
93105

94106
unsigned int* data = reinterpret_cast<unsigned int*>(m_rootConstants.data());

0 commit comments

Comments
 (0)