ATOM-15658 Better option of CreateCommonBuffer requires unique buffer name (#1133)
* ATOM-15658 Better option of CreateCommonBuffer requires unique buffer name - Change the CreateCommonBuffer function to not require an unique name by default. - Remove the code for generating unique buffer names. - Add buffer name to BufferAsset so it can be used for device object name instead of using asset file name. - Change RPI::Buffer to use BufferName_AssetUuid as attachment id.
This commit is contained in:
@@ -152,15 +152,22 @@ namespace AZ
|
||||
}
|
||||
|
||||
Data::Instance<Buffer> BufferSystem::CreateBufferFromCommonPool(const CommonBufferDescriptor& descriptor)
|
||||
{
|
||||
Uuid bufferId = Uuid::CreateName(descriptor.m_bufferName.c_str());
|
||||
|
||||
// Report error if there is a buffer with same name.
|
||||
// Note: this shouldn't return the existing buffer because users are expecting a newly created buffer.
|
||||
if (Data::InstanceDatabase<Buffer>::Instance().Find(Data::InstanceId(bufferId)))
|
||||
{
|
||||
Uuid bufferId;
|
||||
if (descriptor.m_isUniqueName)
|
||||
{
|
||||
AZ_Error("BufferSystem", false, "Buffer with same name '%s' already exist", descriptor.m_bufferName.c_str());
|
||||
return nullptr;
|
||||
bufferId = Uuid::CreateName(descriptor.m_bufferName.c_str());
|
||||
// Report error if there is a buffer with same name.
|
||||
// Note: this shouldn't return the existing buffer because users are expecting a newly created buffer.
|
||||
if (Data::InstanceDatabase<Buffer>::Instance().Find(Data::InstanceId(bufferId)))
|
||||
{
|
||||
AZ_Error("BufferSystem", false, "Buffer with same name '%s' already exist", descriptor.m_bufferName.c_str());
|
||||
return nullptr;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
bufferId = Uuid::CreateRandom();
|
||||
}
|
||||
|
||||
RHI::Ptr<RHI::BufferPool> bufferPool = GetCommonBufferPool(descriptor.m_poolType);
|
||||
@@ -207,9 +214,9 @@ namespace AZ
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
Data::Instance<Buffer> BufferSystem::FindCommonBuffer(AZStd::string_view bufferName)
|
||||
Data::Instance<Buffer> BufferSystem::FindCommonBuffer(AZStd::string_view uniqueBufferName)
|
||||
{
|
||||
Uuid bufferId = Uuid::CreateName(bufferName.data());
|
||||
Uuid bufferId = Uuid::CreateName(uniqueBufferName.data());
|
||||
return Data::InstanceDatabase<Buffer>::Instance().Find(Data::InstanceId(bufferId));
|
||||
}
|
||||
} // namespace RPI
|
||||
|
||||
Reference in New Issue
Block a user