From 0ebe6c6079f391b53765a580fa0869585f9adb61 Mon Sep 17 00:00:00 2001 From: igarri Date: Thu, 22 Apr 2021 13:19:39 +0100 Subject: [PATCH 001/244] Setup Table model and Table view --- .../AzToolsFramework/AssetBrowserTableModel.h | 36 ++ .../AssetBrowser/AssetBrowserTableModel.cpp | 37 ++ .../AssetBrowser/AssetBrowserTableModel.h | 36 ++ .../Entries/AssetBrowserEntry.cpp | 5 +- .../AssetBrowser/Entries/AssetBrowserEntry.h | 2 + .../Entries/FolderAssetBrowserEntry.cpp | 1 + .../Entries/RootAssetBrowserEntry.cpp | 3 + .../Views/AssetBrowserTableView.cpp | 65 +++ .../Views/AssetBrowserTableView.h | 56 +++ .../AssetBrowser/Views/EntryDelegate.cpp | 44 +-- .../aztoolsframework_files.cmake | 4 + .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 17 + .../AzAssetBrowser/AzAssetBrowserWindow.h | 3 + .../AzAssetBrowser/AzAssetBrowserWindow.ui | 369 ++++++++++-------- 14 files changed, 492 insertions(+), 186 deletions(-) create mode 100644 Code/Framework/AzToolsFramework/AssetBrowserTableModel.h create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp create mode 100644 Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h diff --git a/Code/Framework/AzToolsFramework/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AssetBrowserTableModel.h new file mode 100644 index 0000000000..4e65b3921c --- /dev/null +++ b/Code/Framework/AzToolsFramework/AssetBrowserTableModel.h @@ -0,0 +1,36 @@ +#pragma once +#if !defined(Q_MOC_RUN) +#include +#include +#include + +#include +#include +#include + +AZ_PUSH_DISABLE_WARNING( + 4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' +#include +#include +#include +#endif +AZ_POP_DISABLE_WARNING +namespace AzToolsFramework +{ + namespace AssetBrowser + { + class AssetBrowserTableModel + : public QSortFilterProxyModel + { + Q_OBJECT + public: + AZ_CLASS_ALLOCATOR(AssetBrowserTableModel, AZ::SystemAllocator, 0); + explicit AssetBrowserTableModel(QObject* parent = nullptr); + + QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; + QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; + }; + } +} diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp new file mode 100644 index 0000000000..a6e5cde6d8 --- /dev/null +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -0,0 +1,37 @@ +#include "AssetBrowserTableModel.h" +namespace AzToolsFramework +{ + namespace AssetBrowser + { + AssetBrowserTableModel::AssetBrowserTableModel(QObject* parent /* = nullptr */) + : QSortFilterProxyModel(parent) + { + } + QModelIndex AssetBrowserTableModel::mapToSource(const QModelIndex& proxyIndex) const + { + AZ_UNUSED(proxyIndex); + return QModelIndex(); + } + QModelIndex AssetBrowserTableModel::mapFromSource(const QModelIndex& sourceIndex) const + { + AZ_UNUSED(sourceIndex); + return QModelIndex(); + } + QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const + { + AZ_UNUSED(row); + AZ_UNUSED(column); + AZ_UNUSED(parent); + + return QModelIndex(); + } + QVariant AssetBrowserTableModel::data(const QModelIndex& index, int role) const + { + AZ_UNUSED(index); + AZ_UNUSED(role); + + return QVariant(); + } + } // namespace AssetBrowser +} // namespace AzToolsFramework +#include "AssetBrowser/moc_AssetBrowserTableModel.cpp" diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h new file mode 100644 index 0000000000..4e65b3921c --- /dev/null +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -0,0 +1,36 @@ +#pragma once +#if !defined(Q_MOC_RUN) +#include +#include +#include + +#include +#include +#include + +AZ_PUSH_DISABLE_WARNING( + 4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' +#include +#include +#include +#endif +AZ_POP_DISABLE_WARNING +namespace AzToolsFramework +{ + namespace AssetBrowser + { + class AssetBrowserTableModel + : public QSortFilterProxyModel + { + Q_OBJECT + public: + AZ_CLASS_ALLOCATOR(AssetBrowserTableModel, AZ::SystemAllocator, 0); + explicit AssetBrowserTableModel(QObject* parent = nullptr); + + QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; + QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; + }; + } +} diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp index 85d5eaecea..8ee8f44137 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.cpp @@ -46,6 +46,7 @@ namespace AzToolsFramework const char* AssetBrowserEntry::m_columnNames[] = { "Name", + "Path", "Source ID", "Fingerprint", "Guid", @@ -128,6 +129,8 @@ namespace AzToolsFramework return QString::fromUtf8(m_name.c_str()); case Column::DisplayName: return m_displayName; + case Column::Path: + return m_displayPath; default: return QVariant(); } @@ -283,4 +286,4 @@ namespace AzToolsFramework } // namespace AssetBrowser } // namespace AzToolsFramework -#include "AssetBrowser/Entries/moc_AssetBrowserEntry.cpp" \ No newline at end of file +#include "AssetBrowser/Entries/moc_AssetBrowserEntry.cpp" diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.h index 6f0eceeeea..ac5470a136 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/AssetBrowserEntry.h @@ -68,6 +68,7 @@ namespace AzToolsFramework enum class Column { Name, + Path, SourceID, Fingerprint, Guid, @@ -135,6 +136,7 @@ namespace AzToolsFramework protected: AZStd::string m_name; QString m_displayName; + QString m_displayPath; AZStd::string m_relativePath; AZStd::string m_fullPath; AZStd::vector m_children; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/FolderAssetBrowserEntry.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/FolderAssetBrowserEntry.cpp index 88b26ad5ee..0312edbc51 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/FolderAssetBrowserEntry.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/FolderAssetBrowserEntry.cpp @@ -43,6 +43,7 @@ namespace AzToolsFramework void FolderAssetBrowserEntry::UpdateChildPaths(AssetBrowserEntry* child) const { child->m_relativePath = m_relativePath + AZ_CORRECT_DATABASE_SEPARATOR + child->m_name; + child->m_displayPath = QString::fromUtf8(child->m_relativePath.c_str()); child->m_fullPath = m_fullPath + AZ_CORRECT_DATABASE_SEPARATOR + child->m_name; AssetBrowserEntry::UpdateChildPaths(child); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp index ada961711a..2ee71c8719 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp @@ -292,6 +292,9 @@ namespace AzToolsFramework product->m_assetType = productWithUuidDatabaseEntry.second.m_assetType; product->m_assetType.ToString(product->m_assetTypeString); AZ::Data::AssetCatalogRequestBus::BroadcastResult(product->m_relativePath, &AZ::Data::AssetCatalogRequests::GetAssetPathById, assetId); + QString displayPath = QString::fromUtf8(product->m_relativePath.c_str()); + displayPath.remove(QString("/" + QString::fromUtf8(product->m_name.c_str()))); + product->m_displayPath = displayPath; EntryCache::GetInstance()->m_productAssetIdMap[assetId] = product; if (needsAdd) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp new file mode 100644 index 0000000000..ee86f372db --- /dev/null +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -0,0 +1,65 @@ +#include "AssetBrowserTableView.h" + +#pragma optimize("", off) +namespace AzToolsFramework +{ + namespace AssetBrowser + { + AssetBrowserTableView::AssetBrowserTableView(QWidget* parent) + : QTableView(parent) + { + AssetBrowserViewRequestBus::Handler::BusConnect(); + AssetBrowserComponentNotificationBus::Handler::BusConnect(); + } + AssetBrowserTableView::~AssetBrowserTableView() + { + AssetBrowserViewRequestBus::Handler::BusDisconnect(); + AssetBrowserComponentNotificationBus::Handler::BusDisconnect(); + } + void AssetBrowserTableView::setModel(QAbstractItemModel* model) + { + //m_assetBrowserSortFilterProxyModel = qobject_cast(model); + //AZ_Assert(m_assetBrowserSortFilterProxyModel, "Expecting AssetBrowserTableFilterModel"); + //m_assetBrowserModel = qobject_cast(m_assetBrowserSortFilterProxyModel->sourceModel()); + QTableView::setModel(model); + } + void AssetBrowserTableView::SetName(const QString& name) + { + m_name = name; + bool isAssetBrowserComponentReady = false; + AssetBrowserComponentRequestBus::BroadcastResult(isAssetBrowserComponentReady, &AssetBrowserComponentRequests::AreEntriesReady); + if (isAssetBrowserComponentReady) + { + OnAssetBrowserComponentReady(); + } + } + AZStd::vector AssetBrowserTableView::GetSelectedAssets() const + { + return AZStd::vector(); + } + + void AssetBrowserTableView::SelectProduct(AZ::Data::AssetId assetID) + { + AZ_UNUSED(assetID); + } + + void AssetBrowserTableView::SelectFileAtPath(const AZStd::string& assetPath) + { + AZ_UNUSED(assetPath); + } + + void AssetBrowserTableView::ClearFilter() + { + } + + void AssetBrowserTableView::Update() + { + } + + //void AssetBrowserTableView::OnAssetBrowserComponentReady() + //{ + //} + } // namespace AssetBrowser +} // namespace AzToolsFramework +#pragma optimize("", on) +#include "AssetBrowser/Views/moc_AssetBrowserTableView.cpp" diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h new file mode 100644 index 0000000000..04881aa782 --- /dev/null +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -0,0 +1,56 @@ +#pragma once +#if !defined(Q_MOC_RUN) +#include +#include +#include + +#include +//#include + +#include +#include +#include +#endif + +namespace AzToolsFramework +{ + namespace AssetBrowser + { + class AssetBrowserEntry; + class AssetBrowserModel; + class AssetBrowserFilterModel; + class EntryDelegate; + + class AssetBrowserTableView + : public QTableView + , public AssetBrowserViewRequestBus::Handler + , public AssetBrowserComponentNotificationBus::Handler + { + Q_OBJECT + public: + explicit AssetBrowserTableView(QWidget* parent = nullptr); + ~AssetBrowserTableView() override; + + void setModel(QAbstractItemModel *model) override; + void SetName(const QString& name); + + AZStd::vector GetSelectedAssets() const; + + ////////////////////////////////////////////////////////////////////////// + // AssetBrowserViewRequestBus + virtual void SelectProduct(AZ::Data::AssetId assetID) override; + virtual void SelectFileAtPath(const AZStd::string& assetPath) override; + virtual void ClearFilter() override; + virtual void Update() override; + + ////////////////////////////////////////////////////////////////////////// + // AssetBrowserComponentNotificationBus + //void OnAssetBrowserComponentReady() override; + ////////////////////////////////////////////////////////////////////////// + private: + QString m_name; + + + }; + } // namespace AssetBrowser +} // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp index abc290a406..42e161cf37 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp @@ -74,34 +74,34 @@ namespace AzToolsFramework QPoint iconTopLeft(remainingRect.x(), remainingRect.y() + (remainingRect.height() / 2) - (m_iconSize / 2)); auto sourceEntry = azrtti_cast(entry); - - int thumbX = DrawThumbnail(painter, iconTopLeft, iconSize, entry->GetThumbnailKey()); - QPalette actualPalette(option.palette); - - if (sourceEntry) + if (index.column() == static_cast(AssetBrowserEntry::Column::Name)) { - if (m_showSourceControl) + int thumbX = DrawThumbnail(painter, iconTopLeft, iconSize, entry->GetThumbnailKey()); + if (sourceEntry) { - DrawThumbnail(painter, iconTopLeft, iconSize, sourceEntry->GetSourceControlThumbnailKey()); - } - // sources with no children should be greyed out. - if (sourceEntry->GetChildCount() == 0) - { - isEnabled = false; // draw in disabled style. - actualPalette.setCurrentColorGroup(QPalette::Disabled); + if (m_showSourceControl) + { + DrawThumbnail(painter, iconTopLeft, iconSize, sourceEntry->GetSourceControlThumbnailKey()); + } + // sources with no children should be greyed out. + if (sourceEntry->GetChildCount() == 0) + { + isEnabled = false; // draw in disabled style. + actualPalette.setCurrentColorGroup(QPalette::Disabled); + } } + + remainingRect.adjust(thumbX, 0, 0, 0); // bump it to the right by the size of the thumbnail + remainingRect.adjust(ENTRY_SPACING_LEFT_PIXELS, 0, 0, 0); // bump it to the right by the spacing. } + QString displayString = qvariant_cast(index.data(index.column())); - remainingRect.adjust(thumbX, 0, 0, 0); // bump it to the right by the size of the thumbnail - remainingRect.adjust(ENTRY_SPACING_LEFT_PIXELS, 0, 0, 0); // bump it to the right by the spacing. - - style->drawItemText(painter, - remainingRect, - option.displayAlignment, - actualPalette, - isEnabled, - entry->GetDisplayName(), + style->drawItemText( + painter, remainingRect, option.displayAlignment, actualPalette, isEnabled, + index.column() == static_cast(AssetBrowserEntry::Column::Name) + ? qvariant_cast(entry->data(static_cast(AssetBrowserEntry::Column::Name))) + : qvariant_cast(entry->data(static_cast(AssetBrowserEntry::Column::Path))), isSelected ? QPalette::HighlightedText : QPalette::Text); } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake index 2939bb44ad..51ca1a3fdb 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/aztoolsframework_files.cmake @@ -545,6 +545,8 @@ set(FILES AssetBrowser/AssetBrowserEntry.h AssetBrowser/AssetBrowserFilterModel.cpp AssetBrowser/AssetBrowserFilterModel.h + AssetBrowser/AssetBrowserTableModel.cpp + AssetBrowser/AssetBrowserTableModel.h AssetBrowser/AssetBrowserModel.cpp AssetBrowser/AssetBrowserModel.h AssetBrowser/AssetEntryChange.h @@ -555,6 +557,8 @@ set(FILES AssetBrowser/EBusFindAssetTypeByName.h AssetBrowser/Views/AssetBrowserTreeView.cpp AssetBrowser/Views/AssetBrowserTreeView.h + AssetBrowser/Views/AssetBrowserTableView.cpp + AssetBrowser/Views/AssetBrowserTableView.h AssetBrowser/Views/EntryDelegate.cpp AssetBrowser/Views/EntryDelegate.h AssetBrowser/Views/AssetBrowserFolderWidget.cpp diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 0b23739bb8..733044746e 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -18,6 +18,7 @@ #include #include #include +#include #include // AzQtComponents @@ -66,6 +67,7 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) : QWidget(parent) , m_ui(new Ui::AzAssetBrowserWindowClass()) , m_filterModel(new AzToolsFramework::AssetBrowser::AssetBrowserFilterModel(parent)) + , m_tableModel(new AzToolsFramework::AssetBrowser::AssetBrowserTableModel(parent)) { m_ui->setupUi(this); m_ui->m_searchWidget->Setup(true, true); @@ -76,7 +78,12 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_filterModel->setSourceModel(m_assetBrowserModel); m_filterModel->SetFilter(m_ui->m_searchWidget->GetFilter()); + m_tableModel->setSourceModel(m_filterModel.data()); + m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); + m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); + + m_ui->m_assetBrowserTableViewWidget->setVisible(false); connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), &AssetBrowserFilterModel::filterUpdatedSlot); @@ -92,7 +99,11 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, &SearchWidget::ClearStringFilter); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); + m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main"); + m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main"); + + connect(m_ui->m_viewSwitcherCheckBox, &QCheckBox::stateChanged, this, &AzAssetBrowserWindow::SwitchDisplayView); } AzAssetBrowserWindow::~AzAssetBrowserWindow() @@ -220,4 +231,10 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& } +void AzAssetBrowserWindow::SwitchDisplayView(const int state) +{ + m_ui->m_assetBrowserTableViewWidget->setVisible(state); + m_ui->m_assetBrowserTreeViewWidget->setVisible(!state); +} + #include diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h index 263712dfe2..1a5604b98f 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h @@ -29,6 +29,7 @@ namespace AzToolsFramework namespace AssetBrowser { class AssetBrowserFilterModel; + class AssetBrowserTableModel; class AssetBrowserModel; } } @@ -53,6 +54,7 @@ private: QScopedPointer m_ui; QScopedPointer m_filterModel; + QScopedPointer m_tableModel; AzToolsFramework::AssetBrowser::AssetBrowserModel* m_assetBrowserModel; void UpdatePreview() const; @@ -60,6 +62,7 @@ private: private Q_SLOTS: void SelectionChangedSlot(const QItemSelection& selected, const QItemSelection& deselected) const; void DoubleClickedItem(const QModelIndex& element); + void SwitchDisplayView(const int state); }; extern const char* AZ_ASSET_BROWSER_PREVIEW_NAME; diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.ui b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.ui index d6a6b4b8df..d9e42ef906 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.ui +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.ui @@ -1,168 +1,211 @@ - AzAssetBrowserWindowClass - - - - 0 - 0 - 691 - 554 - - - - Asset Browser - - - - 0 - - - - - - 1 - 1 - - - - true - - - - - 0 - 0 - 671 - 534 - - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - - - 0 - 0 - - - - + AzAssetBrowserWindowClass + + + + 0 + 0 + 691 + 554 + + + + Asset Browser + + + + 0 + + + + + + 1 + 1 + + + + true + + + + + 0 + 0 + 671 + 534 + + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + + + 0 + 0 + + + + + + + + Switch View + + + + + + + + + + 0 + 0 + + + + Qt::Horizontal + + + false + + + + + 0 + 0 + + + + vertical-align: top + + + + 0 + + + 0 + + + 0 + + + 0 + + + 0 + + + + + + 0 + 0 + + + + QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed + + + QAbstractItemView::DropOnly + + + QAbstractItemView::SingleSelection + + + QAbstractItemView::SelectRows + + + QAbstractItemView::ScrollPerPixel + + + false + + + true + + + + + + + + 1 + 0 + + + + QAbstractItemView::DragOnly + + + + + + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + + + + + + - - - - - - 0 - 0 - - - - Qt::Horizontal - - - false - - - - - 0 - 0 - - - - vertical-align: top - - - - 0 - - - 0 - - - 0 - - - 0 - - - 0 - - - - - - 1 - 0 - - - - QAbstractItemView::DragOnly - - - - - - - - - - - QFrame::StyledPanel - - - QFrame::Raised - - - - - - - - - - - - - - - AzToolsFramework::AssetBrowser::SearchWidget - QWidget -
AzToolsFramework/AssetBrowser/Search/SearchWidget.h
- 1 -
- - AzToolsFramework::AssetBrowser::AssetBrowserTreeView - QTreeView -
AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.h
-
- - AzToolsFramework::AssetBrowser::PreviewerFrame - QFrame -
AzToolsFramework/AssetBrowser/Previewer/PreviewerFrame.h
- 1 -
-
- - + + + AzToolsFramework::AssetBrowser::SearchWidget + QWidget +
AzToolsFramework/AssetBrowser/Search/SearchWidget.h
+ 1 +
+ + AzToolsFramework::AssetBrowser::AssetBrowserTreeView + QTreeView +
AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.h
+
+ + AzToolsFramework::AssetBrowser::PreviewerFrame + QFrame +
AzToolsFramework/AssetBrowser/Previewer/PreviewerFrame.h
+ 1 +
+ + AzToolsFramework::AssetBrowser::AssetBrowserTableView + QTableView +
AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h
+
+
+ +
From b7c2495911484fa0e22a57e77534c3fffdb678d0 Mon Sep 17 00:00:00 2001 From: igarri Date: Wed, 28 Apr 2021 09:38:43 +0100 Subject: [PATCH 002/244] Working base --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 2 + .../AssetBrowser/AssetBrowserFilterModel.h | 1 + .../AssetBrowser/AssetBrowserTableModel.cpp | 94 ++++++++++++++++--- .../AssetBrowser/AssetBrowserTableModel.h | 18 +++- .../Views/AssetBrowserTableView.cpp | 74 +++++++++++++-- .../Views/AssetBrowserTableView.h | 17 +++- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 4 + 7 files changed, 184 insertions(+), 26 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 9c60b6cd35..42498eb76e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -62,6 +62,7 @@ namespace AzToolsFramework invalidateFilter(); m_invalidateFilter = false; } + Q_EMIT entriesUpdated(); } bool AssetBrowserFilterModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const @@ -162,6 +163,7 @@ namespace AzToolsFramework { m_alreadyRecomputingFilters = false; FilterUpdatedSlotImmediate(); + //beginInsertRows() } ); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h index f9423b2534..6aa1a08e45 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h @@ -53,6 +53,7 @@ namespace AzToolsFramework Q_SIGNALS: void filterChanged(); + void entriesUpdated(); ////////////////////////////////////////////////////////////////////////// //QSortFilterProxyModel diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index a6e5cde6d8..e7a49b2d99 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -6,31 +6,97 @@ namespace AzToolsFramework AssetBrowserTableModel::AssetBrowserTableModel(QObject* parent /* = nullptr */) : QSortFilterProxyModel(parent) { + m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); + m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); } QModelIndex AssetBrowserTableModel::mapToSource(const QModelIndex& proxyIndex) const { - AZ_UNUSED(proxyIndex); - return QModelIndex(); + Q_ASSERT(!proxyIndex.isValid() || proxyIndex.model() == this); + if (!proxyIndex.isValid()) + { + return QModelIndex(); + } + return m_indexMap[proxyIndex.row()]; } QModelIndex AssetBrowserTableModel::mapFromSource(const QModelIndex& sourceIndex) const { - AZ_UNUSED(sourceIndex); - return QModelIndex(); + Q_ASSERT(!sourceIndex.isValid() || sourceIndex.model() == sourceModel()); + if (!sourceIndex.isValid()) + { + return QModelIndex(); + } + return createIndex(m_rowMap[sourceIndex], sourceIndex.column(), sourceIndex.internalPointer()); } - QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const - { - AZ_UNUSED(row); - AZ_UNUSED(column); - AZ_UNUSED(parent); + //QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const + //{ - return QModelIndex(); - } + // //return parent.isValid() ? QModelIndex() : createIndex(row, column , m_indexMap[row].internalPointer()); + // if (!parent.isValid()) + // { + // QModelIndex(); + // } + // return createIndex(row, column, m_indexMap[row].internalPointer()); + //} QVariant AssetBrowserTableModel::data(const QModelIndex& index, int role) const { - AZ_UNUSED(index); - AZ_UNUSED(role); + //AZ_UNUSED(role); + auto sourceIndex = mapToSource(index); + if (!sourceIndex.isValid()) + return QVariant(); - return QVariant(); + AssetBrowserEntry* entry = GetAssetEntry(sourceIndex); // static_cast(sourceIndex.internalPointer()); + if (entry == nullptr) + { + AZ_Assert(false, "ERROR - index internal pointer not pointing to an AssetEntry. Tree provided by the AssetBrowser invalid?"); + return Qt::PartiallyChecked; + } + + return sourceIndex.data(role); //return entry->data(index.column()); + //return QVariant::fromValue(entry); + + } + bool AssetBrowserTableModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const + { + AZ_UNUSED(source_row); + AZ_UNUSED(source_parent); + return true; + } + bool AssetBrowserTableModel::filterAcceptsColumn(int source_column, const QModelIndex&) const + { + return m_showColumn.find(source_column) != m_showColumn.end(); + } + int AssetBrowserTableModel::BuildMap(const QAbstractItemModel* model, const QModelIndex& parent, int row) + { + int rows = model ? model->rowCount(parent) : 0; + for (int i = 0; i < rows; ++i) + { + auto index = model->index(i, 0, parent); + + m_rowMap[index] = row; + m_indexMap[row] = index; + row = row + 1; + if (model->hasChildren(index)) + { + row = BuildMap(model, index, row); + } + } + return row; + } + AssetBrowserEntry* AssetBrowserTableModel::GetAssetEntry(QModelIndex index) const + { + if (index.isValid()) + { + return static_cast(index.internalPointer()); + } + else + { + AZ_Error("AssetBrowser", false, "Invalid Source Index provided to GetAssetEntry."); + return nullptr; + } + } + void AssetBrowserTableModel::UpdateMap() + { + BuildMap(sourceModel()); } } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index 4e65b3921c..ef87ad8512 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -29,8 +29,24 @@ namespace AzToolsFramework QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; - QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + //QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; + + public Q_SLOTS: + void UpdateMap(); + + protected: + bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; + bool filterAcceptsColumn(int source_column, const QModelIndex& /*source_parent*/) const override; + + private: + int BuildMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0); + AssetBrowserEntry* GetAssetEntry(QModelIndex index) const; + + private: + AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn; + QMap m_indexMap; + QMap m_rowMap; }; } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index ee86f372db..927deb0039 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -1,5 +1,34 @@ -#include "AssetBrowserTableView.h" +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +AZ_PUSH_DISABLE_WARNING( + 4244 4251 4800, "-Wunknown-warning-option") // conversion from 'int' to 'float', possible loss of data, needs to have dll-interface to + // be used by clients of class 'QFlags::Int': forcing value to bool + // 'true' or 'false' (performance warning) +#include +#include +#include +#include +#include +#include +#include +AZ_POP_DISABLE_WARNING #pragma optimize("", off) namespace AzToolsFramework { @@ -7,7 +36,19 @@ namespace AzToolsFramework { AssetBrowserTableView::AssetBrowserTableView(QWidget* parent) : QTableView(parent) + , m_delegate(new EntryDelegate(this)) + { + setSortingEnabled(true); + setItemDelegate(m_delegate); + // header()->hide(); + setContextMenuPolicy(Qt::CustomContextMenu); + + setMouseTracking(true); + + connect(this, &QTableView::customContextMenuRequested, this, &AssetBrowserTableView::OnContextMenu); + //connect(m_scTimer, &QTimer::timeout, this, &AssetBrowserTreeView::OnUpdateSCThumbnailsList); + AssetBrowserViewRequestBus::Handler::BusConnect(); AssetBrowserComponentNotificationBus::Handler::BusConnect(); } @@ -18,9 +59,9 @@ namespace AzToolsFramework } void AssetBrowserTableView::setModel(QAbstractItemModel* model) { - //m_assetBrowserSortFilterProxyModel = qobject_cast(model); - //AZ_Assert(m_assetBrowserSortFilterProxyModel, "Expecting AssetBrowserTableFilterModel"); - //m_assetBrowserModel = qobject_cast(m_assetBrowserSortFilterProxyModel->sourceModel()); + m_sourceModel = qobject_cast(model); + AZ_Assert(m_sourceModel, "Expecting AssetBrowserTableModel"); + m_sourceFilterModel = qobject_cast(m_sourceModel->sourceModel()); QTableView::setModel(model); } void AssetBrowserTableView::SetName(const QString& name) @@ -54,11 +95,30 @@ namespace AzToolsFramework void AssetBrowserTableView::Update() { + update(); } - //void AssetBrowserTableView::OnAssetBrowserComponentReady() - //{ - //} + void AssetBrowserTableView::OnAssetBrowserComponentReady() + { + } + + void AssetBrowserTableView::OnContextMenu(const QPoint& point) + { + AZ_UNUSED(point); + + auto selectedAssets = GetSelectedAssets(); + if (selectedAssets.size() != 1) + { + return; + } + + QMenu menu(this); + AssetBrowserInteractionNotificationBus::Broadcast(&AssetBrowserInteractionNotificationBus::Events::AddContextMenuActions, this, &menu, selectedAssets); + if (!menu.isEmpty()) + { + menu.exec(QCursor::pos()); + } + } } // namespace AssetBrowser } // namespace AzToolsFramework #pragma optimize("", on) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index 04881aa782..bec24cca9b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -5,7 +5,7 @@ #include #include -//#include +#include #include #include @@ -17,7 +17,7 @@ namespace AzToolsFramework namespace AssetBrowser { class AssetBrowserEntry; - class AssetBrowserModel; + class AssetBrowserTableModel; class AssetBrowserFilterModel; class EntryDelegate; @@ -45,11 +45,20 @@ namespace AzToolsFramework ////////////////////////////////////////////////////////////////////////// // AssetBrowserComponentNotificationBus - //void OnAssetBrowserComponentReady() override; + void OnAssetBrowserComponentReady() override; ////////////////////////////////////////////////////////////////////////// + + private Q_SLOTS: + void OnContextMenu(const QPoint& point); + + //! Get all visible source entries and place them in a queue to update their source control status + //void OnUpdateSCThumbnailsList(); + private: QString m_name; - + QPointer m_sourceFilterModel = nullptr; + QPointer m_sourceModel = nullptr; + EntryDelegate* m_delegate = nullptr; }; } // namespace AssetBrowser diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 733044746e..d67ee0d0ca 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -78,13 +78,17 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_filterModel->setSourceModel(m_assetBrowserModel); m_filterModel->SetFilter(m_ui->m_searchWidget->GetFilter()); + m_tableModel->setFilterRole(Qt::DisplayRole); m_tableModel->setSourceModel(m_filterModel.data()); + //m_tableModel->setSourceModel(m_assetBrowserModel); m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); m_ui->m_assetBrowserTableViewWidget->setVisible(false); + connect(m_filterModel.data(), &AssetBrowserFilterModel::entriesUpdated, m_tableModel.data(), &AssetBrowserTableModel::UpdateMap); + connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), &AssetBrowserFilterModel::filterUpdatedSlot); connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, this, [this]() From 65550d3f1c3ec5d011485a8d9fdbe973b6789710 Mon Sep 17 00:00:00 2001 From: igarri Date: Mon, 10 May 2021 10:39:01 +0100 Subject: [PATCH 003/244] Entries updating on the table view --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 4 +- .../AssetBrowser/AssetBrowserModel.cpp | 3 +- .../AssetBrowser/AssetBrowserTableModel.cpp | 264 ++++++++++++++++-- .../AssetBrowser/AssetBrowserTableModel.h | 79 +++++- .../Views/AssetBrowserTableView.cpp | 48 +++- .../Views/AssetBrowserTableView.h | 22 +- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 27 +- .../AzAssetBrowser/AzAssetBrowserWindow.h | 2 + 8 files changed, 395 insertions(+), 54 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 42498eb76e..5e9203cc29 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -31,7 +31,8 @@ namespace AzToolsFramework AssetBrowserFilterModel::AssetBrowserFilterModel(QObject* parent) : QSortFilterProxyModel(parent) { - m_showColumn.insert(AssetBrowserModel::m_column); + m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); + m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); m_collator.setNumericMode(true); AssetBrowserComponentNotificationBus::Handler::BusConnect(); } @@ -163,7 +164,6 @@ namespace AzToolsFramework { m_alreadyRecomputingFilters = false; FilterUpdatedSlotImmediate(); - //beginInsertRows() } ); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp index d7c0164435..1101e11f3a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp @@ -144,7 +144,8 @@ namespace AzToolsFramework if (parent.isValid()) { if ((parent.column() != static_cast(AssetBrowserEntry::Column::DisplayName)) && - (parent.column() != static_cast(AssetBrowserEntry::Column::Name))) + (parent.column() != static_cast(AssetBrowserEntry::Column::Name)) && + (parent.column() != static_cast(AssetBrowserEntry::Column::Path))) { return 0; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index e7a49b2d99..7480d17d47 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -1,4 +1,16 @@ -#include "AssetBrowserTableModel.h" +#include +#include +#include +#include +AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") + +#include +#include + +#include +#include +#include +AZ_POP_DISABLE_WARNING namespace AzToolsFramework { namespace AssetBrowser @@ -6,9 +18,24 @@ namespace AzToolsFramework AssetBrowserTableModel::AssetBrowserTableModel(QObject* parent /* = nullptr */) : QSortFilterProxyModel(parent) { - m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); - m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); + sort(0); + setDynamicSortFilter(false); + setRecursiveFilteringEnabled(true); + AssetBrowserComponentNotificationBus::Handler::BusConnect(); } + AssetBrowserTableModel::~AssetBrowserTableModel() + { + AssetBrowserComponentNotificationBus::Handler::BusDisconnect(); + } + void AssetBrowserTableModel::OnAssetBrowserComponentReady() + { + BuildMap(sourceModel()); + } + void AssetBrowserTableModel::setSourceModel(QAbstractItemModel* sourceModel) + { + QSortFilterProxyModel::setSourceModel(sourceModel); + } + QModelIndex AssetBrowserTableModel::mapToSource(const QModelIndex& proxyIndex) const { Q_ASSERT(!proxyIndex.isValid() || proxyIndex.model() == this); @@ -18,6 +45,11 @@ namespace AzToolsFramework } return m_indexMap[proxyIndex.row()]; } + QModelIndex AssetBrowserTableModel::parent(const QModelIndex& child) const + { + AZ_UNUSED(child); + return QModelIndex(); + } QModelIndex AssetBrowserTableModel::mapFromSource(const QModelIndex& sourceIndex) const { Q_ASSERT(!sourceIndex.isValid() || sourceIndex.model() == sourceModel()); @@ -27,16 +59,14 @@ namespace AzToolsFramework } return createIndex(m_rowMap[sourceIndex], sourceIndex.column(), sourceIndex.internalPointer()); } - //QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const - //{ - // //return parent.isValid() ? QModelIndex() : createIndex(row, column , m_indexMap[row].internalPointer()); - // if (!parent.isValid()) - // { - // QModelIndex(); - // } - // return createIndex(row, column, m_indexMap[row].internalPointer()); - //} + QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const + { + /*AZ_UNUSED(row); + AZ_UNUSED(column);*/ + return parent.isValid() ? QModelIndex() : createIndex(row, column, m_indexMap[row].internalPointer()); + } + QVariant AssetBrowserTableModel::data(const QModelIndex& index, int role) const { //AZ_UNUSED(role); @@ -47,34 +77,67 @@ namespace AzToolsFramework AssetBrowserEntry* entry = GetAssetEntry(sourceIndex); // static_cast(sourceIndex.internalPointer()); if (entry == nullptr) { - AZ_Assert(false, "ERROR - index internal pointer not pointing to an AssetEntry. Tree provided by the AssetBrowser invalid?"); + AZ_Assert( + false, "ERROR - index internal pointer not pointing to an AssetEntry. Tree provided by the AssetBrowser invalid?"); return Qt::PartiallyChecked; } - return sourceIndex.data(role); //return entry->data(index.column()); + return sourceIndex.data(role); // return entry->data(index.column()); //return QVariant::fromValue(entry); + //AZ_UNUSED(role); + //if (index.isValid()) + //{ + // ////if (role == AssetBrowserModel::EntryRole) + // //{ + // QModelIndex modelIndex = mapFromSource(index); + // auto assetEntry = static_cast(index.internalPointer()); + // return QVariant::fromValue(assetEntry); + //} + //return QVariant(); // AzToolsFramework::AssetBrowser::AssetBrowserModel::data(index, role); } - bool AssetBrowserTableModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const + + + int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const { - AZ_UNUSED(source_row); - AZ_UNUSED(source_parent); - return true; - } - bool AssetBrowserTableModel::filterAcceptsColumn(int source_column, const QModelIndex&) const - { - return m_showColumn.find(source_column) != m_showColumn.end(); + return !parent.isValid() ? m_rowMap.size() : 0; } + int AssetBrowserTableModel::BuildMap(const QAbstractItemModel* model, const QModelIndex& parent, int row) { + //int rows = model ? model->rowCount(parent) : 0; + //for (int i = 0; i < rows; ++i) + //{ + // auto index = model->index(i, 0, parent); + // //if (!model->hasChildren(index)) + // //{ + // beginInsertRows(parent, row, row); + // m_rowMap[index] = row; + // m_indexMap[row] = index; + // endInsertRows(); + // Q_EMIT dataChanged(parent, parent); + // row = row + 1; + // //} + // if (model->hasChildren(index)) + // { + // row = BuildMap(model, index, row); + // } + //} + //return row; int rows = model ? model->rowCount(parent) : 0; for (int i = 0; i < rows; ++i) { auto index = model->index(i, 0, parent); + if (model->hasChildren(index) == false) + { + beginInsertRows(parent, row, row); + m_rowMap[index] = row; + m_indexMap[row] = index; + endInsertRows(); + Q_EMIT dataChanged(parent, parent); + row = row + 1; + } - m_rowMap[index] = row; - m_indexMap[row] = index; - row = row + 1; if (model->hasChildren(index)) { row = BuildMap(model, index, row); @@ -96,8 +159,159 @@ namespace AzToolsFramework } void AssetBrowserTableModel::UpdateMap() { + m_indexMap.clear(); + m_rowMap.clear(); BuildMap(sourceModel()); } + + //---------------------------------------AssetBrowserTableFilterModel-------------------------------------------- + AssetBrowserTableFilterModel::AssetBrowserTableFilterModel(QObject* parent) + : QSortFilterProxyModel(parent) + { + m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); + m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); + AssetBrowserComponentNotificationBus::Handler::BusConnect(); + } + + AssetBrowserTableFilterModel::~AssetBrowserTableFilterModel() + { + AssetBrowserComponentNotificationBus::Handler::BusDisconnect(); + } + + void AssetBrowserTableFilterModel::setSourceModel(QAbstractItemModel* sourceModel) + { + QSortFilterProxyModel::setSourceModel(sourceModel); + } + + void AssetBrowserTableFilterModel::SetFilter(FilterConstType filter) + { + connect(filter.data(), &AssetBrowserEntryFilter::updatedSignal, this, &AssetBrowserTableFilterModel::filterUpdatedSlot); + m_filter = filter; + m_invalidateFilter = true; + // asset browser entries are not guaranteed to have populated when the filter is set, delay filtering until they are + bool isAssetBrowserComponentReady = false; + AssetBrowserComponentRequestBus::BroadcastResult(isAssetBrowserComponentReady, &AssetBrowserComponentRequests::AreEntriesReady); + if (isAssetBrowserComponentReady) + { + OnAssetBrowserComponentReady(); + } + } + + void AssetBrowserTableFilterModel::FilterUpdatedSlotImmediate() + { + auto compFilter = qobject_cast>(m_filter); + if (compFilter) + { + auto& subFilters = compFilter->GetSubFilters(); + auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { + auto assetTypeFilter = qobject_cast>(filter); + return !assetTypeFilter.isNull(); + }); + if (it != subFilters.end()) + { + m_assetTypeFilter = qobject_cast>(*it); + } + it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { + auto stringFilter = qobject_cast>(filter); + return !stringFilter.isNull(); + }); + if (it != subFilters.end()) + { + m_stringFilter = qobject_cast>(*it); + } + } + invalidateFilter(); + Q_EMIT filterChanged(); + } + + void AssetBrowserTableFilterModel::OnAssetBrowserComponentReady() + { + if (m_invalidateFilter) + { + invalidateFilter(); + m_invalidateFilter = false; + } + Q_EMIT entriesUpdated(); + } + + bool AssetBrowserTableFilterModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const + { + AZ_UNUSED(source_row); + AZ_UNUSED(source_parent); + QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); + if (!idx.isValid()) + { + return false; + } + // no filter present, every entry is visible + if (!m_filter) + { + return true; + } + + //// the entry is the internal pointer of the index + //auto entry = static_cast(idx.internalPointer()); + + //if (entry) + //{ + // // root should return true even if its not displayed in the treeview + // if (entry && entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Root) + // { + // return true; + // } + // return m_filter->Match(entry); + //} + return true; + } + + bool AssetBrowserTableFilterModel::filterAcceptsColumn(int source_column, const QModelIndex&) const + { + return m_showColumn.find(source_column) != m_showColumn.end(); + } + + bool AssetBrowserTableFilterModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const + { + if (source_left.column() == source_right.column()) + { + QVariant leftData = sourceModel()->data(source_left, AssetBrowserModel::Roles::EntryRole); + QVariant rightData = sourceModel()->data(source_right, AssetBrowserModel::Roles::EntryRole); + if (leftData.canConvert() && rightData.canConvert()) + { + auto leftEntry = qvariant_cast(leftData); + auto rightEntry = qvariant_cast(rightData); + + // folders should always come first + if (azrtti_istypeof(leftEntry) && + azrtti_istypeof(rightEntry)) + { + return false; + } + if (azrtti_istypeof(leftEntry) && + azrtti_istypeof(rightEntry)) + { + return true; + } + + // if both entries are of same type, sort alphabetically + return m_collator.compare(leftEntry->GetDisplayName(), rightEntry->GetDisplayName()) > 0; + } + } + return QSortFilterProxyModel::lessThan(source_left, source_right); + } + + void AssetBrowserTableFilterModel::filterUpdatedSlot() + { + if (!m_alreadyRecomputingFilters) + { + m_alreadyRecomputingFilters = true; + // de-bounce it, since we may get many filter updates all at once. + QTimer::singleShot(0, this, [this]() { + m_alreadyRecomputingFilters = false; + FilterUpdatedSlotImmediate(); + }); + } + } + } // namespace AssetBrowser } // namespace AzToolsFramework #include "AssetBrowser/moc_AssetBrowserTableModel.cpp" diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index ef87ad8512..8ffd1a469e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -21,32 +21,87 @@ namespace AzToolsFramework { class AssetBrowserTableModel : public QSortFilterProxyModel + , public AssetBrowserComponentNotificationBus::Handler { Q_OBJECT + public: AZ_CLASS_ALLOCATOR(AssetBrowserTableModel, AZ::SystemAllocator, 0); explicit AssetBrowserTableModel(QObject* parent = nullptr); - - QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; - QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; - //QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; + ~AssetBrowserTableModel(); + //////////////////////////////////////////////////////////////////// + // AssetBrowserComponentNotificationBus + //////////////////////////////////////////////////////////////////// + void OnAssetBrowserComponentReady() override; + void setSourceModel(QAbstractItemModel* sourceModel) override; + //////////////////////////////////////////////////////////////////// + // QSortFilterProxyModel + QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; + QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override; + QModelIndex parent(const QModelIndex& child) const override; + QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; public Q_SLOTS: void UpdateMap(); - protected: - bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; - bool filterAcceptsColumn(int source_column, const QModelIndex& /*source_parent*/) const override; + int rowCount(const QModelIndex& parent = QModelIndex()) const override; + //QVariant headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const override; + //////////////////////////////////////////////////////////////////// private: - int BuildMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0); AssetBrowserEntry* GetAssetEntry(QModelIndex index) const; - + int BuildMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0); private: - AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn; QMap m_indexMap; QMap m_rowMap; }; - } -} + + class AssetBrowserTableFilterModel + : public QSortFilterProxyModel + , public AssetBrowserComponentNotificationBus::Handler + { + Q_OBJECT + public: + explicit AssetBrowserTableFilterModel(QObject* parent = nullptr); + ~AssetBrowserTableFilterModel(); + + void setSourceModel(QAbstractItemModel* sourceModel) override; + // asset type filtering + void SetFilter(FilterConstType filter); + void FilterUpdatedSlotImmediate(); + + ////////////////////////////////////////////////////////////////////////// + // AssetBrowserComponentNotificationBus + ////////////////////////////////////////////////////////////////////////// + void OnAssetBrowserComponentReady() override; + + Q_SIGNALS: + void filterChanged(); + void entriesUpdated(); + + ////////////////////////////////////////////////////////////////////////// + // QSortFilterProxyModel + protected: + bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; + bool filterAcceptsColumn(int source_column, const QModelIndex& /*source_parent*/) const override; + bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override; + ////////////////////////////////////////////////////////////////////////// + + public Q_SLOTS: + void filterUpdatedSlot(); + + private: + AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn; + bool m_alreadyRecomputingFilters = false; + // asset source name match filter + FilterConstType m_filter; + AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' + QWeakPointer m_stringFilter; + QWeakPointer m_assetTypeFilter; + QCollator m_collator; // cache the collator as its somewhat expensive to constantly create and destroy one. + AZ_POP_DISABLE_WARNING + bool m_invalidateFilter = false; + }; + } // namespace AssetBrowser +} // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index 927deb0039..aa35d99894 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -41,13 +41,13 @@ namespace AzToolsFramework { setSortingEnabled(true); setItemDelegate(m_delegate); - // header()->hide(); + //header()->hide(); setContextMenuPolicy(Qt::CustomContextMenu); setMouseTracking(true); connect(this, &QTableView::customContextMenuRequested, this, &AssetBrowserTableView::OnContextMenu); - //connect(m_scTimer, &QTimer::timeout, this, &AssetBrowserTreeView::OnUpdateSCThumbnailsList); + connect(m_scTimer, &QTimer::timeout, this, &AssetBrowserTableView::OnUpdateSCThumbnailsList); AssetBrowserViewRequestBus::Handler::BusConnect(); AssetBrowserComponentNotificationBus::Handler::BusConnect(); @@ -59,9 +59,9 @@ namespace AzToolsFramework } void AssetBrowserTableView::setModel(QAbstractItemModel* model) { - m_sourceModel = qobject_cast(model); - AZ_Assert(m_sourceModel, "Expecting AssetBrowserTableModel"); - m_sourceFilterModel = qobject_cast(m_sourceModel->sourceModel()); + m_filterModel = qobject_cast(model); + AZ_Assert(m_filterModel, "Expecting AssetBrowserTableModel"); + m_sourceModel = qobject_cast(m_filterModel->sourceModel()); QTableView::setModel(model); } void AssetBrowserTableView::SetName(const QString& name) @@ -76,9 +76,40 @@ namespace AzToolsFramework } AZStd::vector AssetBrowserTableView::GetSelectedAssets() const { - return AZStd::vector(); - } + QModelIndexList sourceIndexes{}; + //for (const auto& index : selectedIndexes()) + //{ + // sourceIndexes.push_back(m_sourceModel->mapToSource(index)); + //} + AZStd::vector entries; + //AssetBrowserModel::SourceIndexesToAssetDatabaseEntries(sourceIndexes, entries); + return entries; + } + void AssetBrowserTableView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) + { + AZ_UNUSED(selected); + AZ_UNUSED(deselected); + } + void AssetBrowserTableView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) + { + // if selected entry is being removed, clear selection so not to select (and attempt to preview) other entries potentially + // marked for deletion + if (selectionModel() && selectionModel()->selectedIndexes().size() == 1) + { + QModelIndex selectedIndex = selectionModel()->selectedIndexes().first(); + QModelIndex parentSelectedIndex = selectedIndex.parent(); + if (parentSelectedIndex == parent && selectedIndex.row() >= start && selectedIndex.row() <= end) + { + selectionModel()->clear(); + } + } + QTableView::rowsAboutToBeRemoved(parent, start, end); + } + void AssetBrowserTableView::OnUpdateSCThumbnailsList() + { + + } void AssetBrowserTableView::SelectProduct(AZ::Data::AssetId assetID) { AZ_UNUSED(assetID); @@ -91,6 +122,9 @@ namespace AzToolsFramework void AssetBrowserTableView::ClearFilter() { + emit ClearStringFilter(); + emit ClearTypeFilter(); + m_sourceModel->FilterUpdatedSlotImmediate(); } void AssetBrowserTableView::Update() diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index bec24cca9b..aef7353334 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -48,18 +48,32 @@ namespace AzToolsFramework void OnAssetBrowserComponentReady() override; ////////////////////////////////////////////////////////////////////////// - private Q_SLOTS: - void OnContextMenu(const QPoint& point); + + Q_SIGNALS: + void selectionChangedSignal(const QItemSelection& selected, const QItemSelection& deselected); + void ClearStringFilter(); + void ClearTypeFilter(); + + protected Q_SLOTS: + void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override; + void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override; //! Get all visible source entries and place them in a queue to update their source control status //void OnUpdateSCThumbnailsList(); private: QString m_name; - QPointer m_sourceFilterModel = nullptr; - QPointer m_sourceModel = nullptr; + QPointer m_filterModel = nullptr; + QPointer m_sourceModel = nullptr; EntryDelegate* m_delegate = nullptr; + QTimer* m_scTimer = nullptr; + const int m_scUpdateInterval = 100; + + private Q_SLOTS: + void OnContextMenu(const QPoint& point); + //! Get all visible source entries and place them in a queue to update their source control status + void OnUpdateSCThumbnailsList(); }; } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index d67ee0d0ca..fb850f4f26 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -68,6 +68,7 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) , m_ui(new Ui::AzAssetBrowserWindowClass()) , m_filterModel(new AzToolsFramework::AssetBrowser::AssetBrowserFilterModel(parent)) , m_tableModel(new AzToolsFramework::AssetBrowser::AssetBrowserTableModel(parent)) + , m_tableFilterModel(new AzToolsFramework::AssetBrowser::AssetBrowserTableFilterModel(parent)) { m_ui->setupUi(this); m_ui->m_searchWidget->Setup(true, true); @@ -82,12 +83,18 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_tableModel->setSourceModel(m_filterModel.data()); //m_tableModel->setSourceModel(m_assetBrowserModel); - m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); - m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); + m_tableFilterModel->setSourceModel(m_tableModel.data()); + m_tableFilterModel->SetFilter(m_ui->m_searchWidget->GetFilter()); + + m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); + m_ui->m_assetBrowserTreeViewWidget->hideColumn(static_cast(AssetBrowserEntry::Column::Path)); + + //m_ui->m_assetBrowserTableViewWidget->setModel(m_tableFilterModel.data()); + m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); m_ui->m_assetBrowserTableViewWidget->setVisible(false); - connect(m_filterModel.data(), &AssetBrowserFilterModel::entriesUpdated, m_tableModel.data(), &AssetBrowserTableModel::UpdateMap); + //connect(m_filterModel.data(), &AssetBrowserFilterModel::entriesUpdated, m_tableModel.data(), &AssetBrowserTableModel::UpdateMap); connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), &AssetBrowserFilterModel::filterUpdatedSlot); @@ -97,6 +104,17 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) const bool selectFirstFilteredIndex = false; m_ui->m_assetBrowserTreeViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex); }); + + //connect( m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_tableFilterModel.data(), + // &AssetBrowserTableFilterModel::filterUpdatedSlot); + //connect(m_tableFilterModel.data(), &AssetBrowserTableFilterModel::filterChanged, this, [this]() { + // const bool hasFilter = !m_ui->m_searchWidget->GetFilterString().isEmpty(); + // const bool selectFirstFilteredIndex = false; + // m_ui->m_assetBrowserTableViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex); + //}); + + connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, m_tableModel.data(), &AssetBrowserTableModel::UpdateMap); + connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); connect(m_ui->m_assetBrowserTreeViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); @@ -104,6 +122,9 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, &SearchWidget::ClearStringFilter); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); + connect(m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget, &SearchWidget::ClearStringFilter); + connect(m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); + m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main"); m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main"); diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h index 1a5604b98f..a8a8474ef8 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h @@ -31,6 +31,7 @@ namespace AzToolsFramework class AssetBrowserFilterModel; class AssetBrowserTableModel; class AssetBrowserModel; + class AssetBrowserTableFilterModel; } } @@ -55,6 +56,7 @@ private: QScopedPointer m_ui; QScopedPointer m_filterModel; QScopedPointer m_tableModel; + QScopedPointer m_tableFilterModel; AzToolsFramework::AssetBrowser::AssetBrowserModel* m_assetBrowserModel; void UpdatePreview() const; From 6e15e87e41d610391facaeb210bc0d5b484c1d1c Mon Sep 17 00:00:00 2001 From: igarri Date: Mon, 10 May 2021 15:52:35 +0100 Subject: [PATCH 004/244] Asset Browser Table view filtering --- .../AssetBrowser/AssetBrowserFilterModel.h | 2 +- .../AssetBrowser/AssetBrowserTableModel.cpp | 302 ++++++++++-------- .../AssetBrowser/AssetBrowserTableModel.h | 87 ++--- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 6 +- .../AzAssetBrowser/AzAssetBrowserWindow.h | 2 +- 5 files changed, 217 insertions(+), 182 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h index 6aa1a08e45..3fff43859f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h @@ -45,7 +45,7 @@ namespace AzToolsFramework //asset type filtering void SetFilter(FilterConstType filter); void FilterUpdatedSlotImmediate(); - + const FilterConstType& GetFilter() const { return m_filter; } ////////////////////////////////////////////////////////////////////////// // AssetBrowserComponentNotificationBus ////////////////////////////////////////////////////////////////////////// diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index 7480d17d47..b75d3e9400 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -5,7 +5,7 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") #include -#include +#include #include #include @@ -29,10 +29,12 @@ namespace AzToolsFramework } void AssetBrowserTableModel::OnAssetBrowserComponentReady() { - BuildMap(sourceModel()); + //BuildMap(sourceModel()); } void AssetBrowserTableModel::setSourceModel(QAbstractItemModel* sourceModel) { + m_filterModel = qobject_cast(sourceModel); + AZ_Assert(m_filterModel, "Expecting AssetBrowserFilterModel"); QSortFilterProxyModel::setSourceModel(sourceModel); } @@ -60,6 +62,18 @@ namespace AzToolsFramework return createIndex(m_rowMap[sourceIndex], sourceIndex.column(), sourceIndex.internalPointer()); } + bool AssetBrowserTableModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const + { + AZ_UNUSED(source_row); + AZ_UNUSED(source_parent); + // no filter present, every entry is not visible + if (!m_filterModel->GetFilter()) + { + return false; + } + return true; + } + QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const { /*AZ_UNUSED(row); @@ -159,158 +173,172 @@ namespace AzToolsFramework } void AssetBrowserTableModel::UpdateMap() { - m_indexMap.clear(); - m_rowMap.clear(); + //m_indexMap.clear(); + //m_rowMap.clear(); + + if (m_indexMap.size() > 0) + { + //beginRemoveRows(m_indexMap.first().parent(), m_indexMap.first().row(), m_indexMap.last().row()); + for (const auto& key : m_indexMap.keys()) + { + beginRemoveRows(m_indexMap[key], m_indexMap[key].row(), m_indexMap[key].row()); + m_rowMap.remove(m_indexMap[key]); + m_indexMap.remove(key); + endRemoveRows(); + } + //endRemoveRows(); + } + BuildMap(sourceModel()); } //---------------------------------------AssetBrowserTableFilterModel-------------------------------------------- - AssetBrowserTableFilterModel::AssetBrowserTableFilterModel(QObject* parent) - : QSortFilterProxyModel(parent) - { - m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); - m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); - AssetBrowserComponentNotificationBus::Handler::BusConnect(); - } + //AssetBrowserTableFilterModel::AssetBrowserTableFilterModel(QObject* parent) + // : QSortFilterProxyModel(parent) + //{ + // m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); + // m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); + // AssetBrowserComponentNotificationBus::Handler::BusConnect(); + //} - AssetBrowserTableFilterModel::~AssetBrowserTableFilterModel() - { - AssetBrowserComponentNotificationBus::Handler::BusDisconnect(); - } + //AssetBrowserTableFilterModel::~AssetBrowserTableFilterModel() + //{ + // AssetBrowserComponentNotificationBus::Handler::BusDisconnect(); + //} - void AssetBrowserTableFilterModel::setSourceModel(QAbstractItemModel* sourceModel) - { - QSortFilterProxyModel::setSourceModel(sourceModel); - } + //void AssetBrowserTableFilterModel::setSourceModel(QAbstractItemModel* sourceModel) + //{ + // QSortFilterProxyModel::setSourceModel(sourceModel); + //} - void AssetBrowserTableFilterModel::SetFilter(FilterConstType filter) - { - connect(filter.data(), &AssetBrowserEntryFilter::updatedSignal, this, &AssetBrowserTableFilterModel::filterUpdatedSlot); - m_filter = filter; - m_invalidateFilter = true; - // asset browser entries are not guaranteed to have populated when the filter is set, delay filtering until they are - bool isAssetBrowserComponentReady = false; - AssetBrowserComponentRequestBus::BroadcastResult(isAssetBrowserComponentReady, &AssetBrowserComponentRequests::AreEntriesReady); - if (isAssetBrowserComponentReady) - { - OnAssetBrowserComponentReady(); - } - } + //void AssetBrowserTableFilterModel::SetFilter(FilterConstType filter) + //{ + // connect(filter.data(), &AssetBrowserEntryFilter::updatedSignal, this, &AssetBrowserTableFilterModel::filterUpdatedSlot); + // m_filter = filter; + // m_invalidateFilter = true; + // // asset browser entries are not guaranteed to have populated when the filter is set, delay filtering until they are + // bool isAssetBrowserComponentReady = false; + // AssetBrowserComponentRequestBus::BroadcastResult(isAssetBrowserComponentReady, &AssetBrowserComponentRequests::AreEntriesReady); + // if (isAssetBrowserComponentReady) + // { + // OnAssetBrowserComponentReady(); + // } + //} - void AssetBrowserTableFilterModel::FilterUpdatedSlotImmediate() - { - auto compFilter = qobject_cast>(m_filter); - if (compFilter) - { - auto& subFilters = compFilter->GetSubFilters(); - auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { - auto assetTypeFilter = qobject_cast>(filter); - return !assetTypeFilter.isNull(); - }); - if (it != subFilters.end()) - { - m_assetTypeFilter = qobject_cast>(*it); - } - it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { - auto stringFilter = qobject_cast>(filter); - return !stringFilter.isNull(); - }); - if (it != subFilters.end()) - { - m_stringFilter = qobject_cast>(*it); - } - } - invalidateFilter(); - Q_EMIT filterChanged(); - } + //void AssetBrowserTableFilterModel::FilterUpdatedSlotImmediate() + //{ + // auto compFilter = qobject_cast>(m_filter); + // if (compFilter) + // { + // auto& subFilters = compFilter->GetSubFilters(); + // auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { + // auto assetTypeFilter = qobject_cast>(filter); + // return !assetTypeFilter.isNull(); + // }); + // if (it != subFilters.end()) + // { + // m_assetTypeFilter = qobject_cast>(*it); + // } + // it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { + // auto stringFilter = qobject_cast>(filter); + // return !stringFilter.isNull(); + // }); + // if (it != subFilters.end()) + // { + // m_stringFilter = qobject_cast>(*it); + // } + // } + // invalidateFilter(); + // Q_EMIT filterChanged(); + //} - void AssetBrowserTableFilterModel::OnAssetBrowserComponentReady() - { - if (m_invalidateFilter) - { - invalidateFilter(); - m_invalidateFilter = false; - } - Q_EMIT entriesUpdated(); - } + //void AssetBrowserTableFilterModel::OnAssetBrowserComponentReady() + //{ + // if (m_invalidateFilter) + // { + // invalidateFilter(); + // m_invalidateFilter = false; + // } + // Q_EMIT entriesUpdated(); + //} - bool AssetBrowserTableFilterModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const - { - AZ_UNUSED(source_row); - AZ_UNUSED(source_parent); - QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); - if (!idx.isValid()) - { - return false; - } - // no filter present, every entry is visible - if (!m_filter) - { - return true; - } + //bool AssetBrowserTableFilterModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const + //{ + // AZ_UNUSED(source_row); + // AZ_UNUSED(source_parent); + // QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); + // if (!idx.isValid()) + // { + // return false; + // } + // // no filter present, every entry is visible + // if (!m_filter) + // { + // return true; + // } - //// the entry is the internal pointer of the index - //auto entry = static_cast(idx.internalPointer()); + // //// the entry is the internal pointer of the index + // //auto entry = static_cast(idx.internalPointer()); - //if (entry) - //{ - // // root should return true even if its not displayed in the treeview - // if (entry && entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Root) - // { - // return true; - // } - // return m_filter->Match(entry); - //} - return true; - } + // //if (entry) + // //{ + // // // root should return true even if its not displayed in the treeview + // // if (entry && entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Root) + // // { + // // return true; + // // } + // // return m_filter->Match(entry); + // //} + // return true; + //} - bool AssetBrowserTableFilterModel::filterAcceptsColumn(int source_column, const QModelIndex&) const - { - return m_showColumn.find(source_column) != m_showColumn.end(); - } + //bool AssetBrowserTableFilterModel::filterAcceptsColumn(int source_column, const QModelIndex&) const + //{ + // return m_showColumn.find(source_column) != m_showColumn.end(); + //} - bool AssetBrowserTableFilterModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const - { - if (source_left.column() == source_right.column()) - { - QVariant leftData = sourceModel()->data(source_left, AssetBrowserModel::Roles::EntryRole); - QVariant rightData = sourceModel()->data(source_right, AssetBrowserModel::Roles::EntryRole); - if (leftData.canConvert() && rightData.canConvert()) - { - auto leftEntry = qvariant_cast(leftData); - auto rightEntry = qvariant_cast(rightData); + //bool AssetBrowserTableFilterModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const + //{ + // if (source_left.column() == source_right.column()) + // { + // QVariant leftData = sourceModel()->data(source_left, AssetBrowserModel::Roles::EntryRole); + // QVariant rightData = sourceModel()->data(source_right, AssetBrowserModel::Roles::EntryRole); + // if (leftData.canConvert() && rightData.canConvert()) + // { + // auto leftEntry = qvariant_cast(leftData); + // auto rightEntry = qvariant_cast(rightData); - // folders should always come first - if (azrtti_istypeof(leftEntry) && - azrtti_istypeof(rightEntry)) - { - return false; - } - if (azrtti_istypeof(leftEntry) && - azrtti_istypeof(rightEntry)) - { - return true; - } + // // folders should always come first + // if (azrtti_istypeof(leftEntry) && + // azrtti_istypeof(rightEntry)) + // { + // return false; + // } + // if (azrtti_istypeof(leftEntry) && + // azrtti_istypeof(rightEntry)) + // { + // return true; + // } - // if both entries are of same type, sort alphabetically - return m_collator.compare(leftEntry->GetDisplayName(), rightEntry->GetDisplayName()) > 0; - } - } - return QSortFilterProxyModel::lessThan(source_left, source_right); - } + // // if both entries are of same type, sort alphabetically + // return m_collator.compare(leftEntry->GetDisplayName(), rightEntry->GetDisplayName()) > 0; + // } + // } + // return QSortFilterProxyModel::lessThan(source_left, source_right); + //} - void AssetBrowserTableFilterModel::filterUpdatedSlot() - { - if (!m_alreadyRecomputingFilters) - { - m_alreadyRecomputingFilters = true; - // de-bounce it, since we may get many filter updates all at once. - QTimer::singleShot(0, this, [this]() { - m_alreadyRecomputingFilters = false; - FilterUpdatedSlotImmediate(); - }); - } - } + //void AssetBrowserTableFilterModel::filterUpdatedSlot() + //{ + // if (!m_alreadyRecomputingFilters) + // { + // m_alreadyRecomputingFilters = true; + // // de-bounce it, since we may get many filter updates all at once. + // QTimer::singleShot(0, this, [this]() { + // m_alreadyRecomputingFilters = false; + // FilterUpdatedSlotImmediate(); + // }); + // } + //} } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index 8ffd1a469e..34cf8432ff 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -7,6 +7,8 @@ #include #include #include +//#include +#include AZ_PUSH_DISABLE_WARNING( 4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' @@ -19,6 +21,9 @@ namespace AzToolsFramework { namespace AssetBrowser { + class AssetBrowserFilterModel; + + class AssetBrowserTableModel : public QSortFilterProxyModel , public AssetBrowserComponentNotificationBus::Handler @@ -38,6 +43,7 @@ namespace AzToolsFramework // QSortFilterProxyModel QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override; + bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; QModelIndex parent(const QModelIndex& child) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; @@ -53,55 +59,56 @@ namespace AzToolsFramework AssetBrowserEntry* GetAssetEntry(QModelIndex index) const; int BuildMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0); private: + QPointer m_filterModel; QMap m_indexMap; QMap m_rowMap; }; - class AssetBrowserTableFilterModel - : public QSortFilterProxyModel - , public AssetBrowserComponentNotificationBus::Handler - { - Q_OBJECT - public: - explicit AssetBrowserTableFilterModel(QObject* parent = nullptr); - ~AssetBrowserTableFilterModel(); + //class AssetBrowserTableFilterModel + // : public QSortFilterProxyModel + // , public AssetBrowserComponentNotificationBus::Handler + //{ + // Q_OBJECT + //public: + // explicit AssetBrowserTableFilterModel(QObject* parent = nullptr); + // ~AssetBrowserTableFilterModel(); - void setSourceModel(QAbstractItemModel* sourceModel) override; - // asset type filtering - void SetFilter(FilterConstType filter); - void FilterUpdatedSlotImmediate(); + // void setSourceModel(QAbstractItemModel* sourceModel) override; + // // asset type filtering + // void SetFilter(FilterConstType filter); + // void FilterUpdatedSlotImmediate(); - ////////////////////////////////////////////////////////////////////////// - // AssetBrowserComponentNotificationBus - ////////////////////////////////////////////////////////////////////////// - void OnAssetBrowserComponentReady() override; + // ////////////////////////////////////////////////////////////////////////// + // // AssetBrowserComponentNotificationBus + // ////////////////////////////////////////////////////////////////////////// + // void OnAssetBrowserComponentReady() override; - Q_SIGNALS: - void filterChanged(); - void entriesUpdated(); + //Q_SIGNALS: + // void filterChanged(); + // void entriesUpdated(); - ////////////////////////////////////////////////////////////////////////// - // QSortFilterProxyModel - protected: - bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; - bool filterAcceptsColumn(int source_column, const QModelIndex& /*source_parent*/) const override; - bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override; - ////////////////////////////////////////////////////////////////////////// + // ////////////////////////////////////////////////////////////////////////// + // // QSortFilterProxyModel + //protected: + // bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; + // bool filterAcceptsColumn(int source_column, const QModelIndex& /*source_parent*/) const override; + // bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override; + // ////////////////////////////////////////////////////////////////////////// - public Q_SLOTS: - void filterUpdatedSlot(); + //public Q_SLOTS: + // void filterUpdatedSlot(); - private: - AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn; - bool m_alreadyRecomputingFilters = false; - // asset source name match filter - FilterConstType m_filter; - AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' - QWeakPointer m_stringFilter; - QWeakPointer m_assetTypeFilter; - QCollator m_collator; // cache the collator as its somewhat expensive to constantly create and destroy one. - AZ_POP_DISABLE_WARNING - bool m_invalidateFilter = false; - }; + //private: + // AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn; + // bool m_alreadyRecomputingFilters = false; + // // asset source name match filter + // FilterConstType m_filter; + // AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' + // QWeakPointer m_stringFilter; + // QWeakPointer m_assetTypeFilter; + // QCollator m_collator; // cache the collator as its somewhat expensive to constantly create and destroy one. + // AZ_POP_DISABLE_WARNING + // bool m_invalidateFilter = false; + //}; } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index fb850f4f26..dd4b3b0cad 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -68,7 +68,7 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) , m_ui(new Ui::AzAssetBrowserWindowClass()) , m_filterModel(new AzToolsFramework::AssetBrowser::AssetBrowserFilterModel(parent)) , m_tableModel(new AzToolsFramework::AssetBrowser::AssetBrowserTableModel(parent)) - , m_tableFilterModel(new AzToolsFramework::AssetBrowser::AssetBrowserTableFilterModel(parent)) + /*, m_tableFilterModel(new AzToolsFramework::AssetBrowser::AssetBrowserTableFilterModel(parent))*/ { m_ui->setupUi(this); m_ui->m_searchWidget->Setup(true, true); @@ -83,8 +83,8 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_tableModel->setSourceModel(m_filterModel.data()); //m_tableModel->setSourceModel(m_assetBrowserModel); - m_tableFilterModel->setSourceModel(m_tableModel.data()); - m_tableFilterModel->SetFilter(m_ui->m_searchWidget->GetFilter()); + //m_tableFilterModel->setSourceModel(m_tableModel.data()); + //m_tableFilterModel->SetFilter(m_ui->m_searchWidget->GetFilter()); m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h index a8a8474ef8..801af3e2a8 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h @@ -56,7 +56,7 @@ private: QScopedPointer m_ui; QScopedPointer m_filterModel; QScopedPointer m_tableModel; - QScopedPointer m_tableFilterModel; + //QScopedPointer m_tableFilterModel; AzToolsFramework::AssetBrowser::AssetBrowserModel* m_assetBrowserModel; void UpdatePreview() const; From 1c990b2ef6b206c254e810d0301365c0a411ab88 Mon Sep 17 00:00:00 2001 From: igarri Date: Wed, 12 May 2021 11:03:02 +0100 Subject: [PATCH 005/244] Filter Sorting Working --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 3 +- .../AssetBrowser/AssetBrowserFilterModel.h | 1 - .../AssetBrowser/AssetBrowserTableModel.cpp | 234 ++---------------- .../AssetBrowser/AssetBrowserTableModel.h | 60 +---- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 20 +- 5 files changed, 33 insertions(+), 285 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 5e9203cc29..34f8b97b5a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -32,7 +32,7 @@ namespace AzToolsFramework : QSortFilterProxyModel(parent) { m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); - m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); + //m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); m_collator.setNumericMode(true); AssetBrowserComponentNotificationBus::Handler::BusConnect(); } @@ -63,7 +63,6 @@ namespace AzToolsFramework invalidateFilter(); m_invalidateFilter = false; } - Q_EMIT entriesUpdated(); } bool AssetBrowserFilterModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h index 3fff43859f..6cccc53eb6 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h @@ -53,7 +53,6 @@ namespace AzToolsFramework Q_SIGNALS: void filterChanged(); - void entriesUpdated(); ////////////////////////////////////////////////////////////////////////// //QSortFilterProxyModel diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index b75d3e9400..ce9e97520a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -7,9 +7,7 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") #include #include -#include #include -#include AZ_POP_DISABLE_WARNING namespace AzToolsFramework { @@ -18,18 +16,7 @@ namespace AzToolsFramework AssetBrowserTableModel::AssetBrowserTableModel(QObject* parent /* = nullptr */) : QSortFilterProxyModel(parent) { - sort(0); setDynamicSortFilter(false); - setRecursiveFilteringEnabled(true); - AssetBrowserComponentNotificationBus::Handler::BusConnect(); - } - AssetBrowserTableModel::~AssetBrowserTableModel() - { - AssetBrowserComponentNotificationBus::Handler::BusDisconnect(); - } - void AssetBrowserTableModel::OnAssetBrowserComponentReady() - { - //BuildMap(sourceModel()); } void AssetBrowserTableModel::setSourceModel(QAbstractItemModel* sourceModel) { @@ -69,86 +56,68 @@ namespace AzToolsFramework // no filter present, every entry is not visible if (!m_filterModel->GetFilter()) { - return false; + return true; } return true; } QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const { - /*AZ_UNUSED(row); - AZ_UNUSED(column);*/ return parent.isValid() ? QModelIndex() : createIndex(row, column, m_indexMap[row].internalPointer()); } QVariant AssetBrowserTableModel::data(const QModelIndex& index, int role) const { - //AZ_UNUSED(role); auto sourceIndex = mapToSource(index); if (!sourceIndex.isValid()) return QVariant(); - AssetBrowserEntry* entry = GetAssetEntry(sourceIndex); // static_cast(sourceIndex.internalPointer()); + AssetBrowserEntry* entry = GetAssetEntry(sourceIndex); if (entry == nullptr) { - AZ_Assert( - false, "ERROR - index internal pointer not pointing to an AssetEntry. Tree provided by the AssetBrowser invalid?"); + AZ_Assert(false, "ERROR - index internal pointer not pointing to an AssetEntry. Tree provided by the AssetBrowser invalid?"); return Qt::PartiallyChecked; } - return sourceIndex.data(role); // return entry->data(index.column()); - //return QVariant::fromValue(entry); - //AZ_UNUSED(role); - //if (index.isValid()) - //{ - // ////if (role == AssetBrowserModel::EntryRole) - // //{ - // QModelIndex modelIndex = mapFromSource(index); - // auto assetEntry = static_cast(index.internalPointer()); - // return QVariant::fromValue(assetEntry); - //} - //return QVariant(); // AzToolsFramework::AssetBrowser::AssetBrowserModel::data(index, role); - + return sourceIndex.data(role); } - int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const { return !parent.isValid() ? m_rowMap.size() : 0; } + QVariant AssetBrowserTableModel::headerData(int section, Qt::Orientation orientation, int role) const + { + if (role == Qt::DisplayRole && orientation == Qt::Horizontal) + { + switch (section) + { + case static_cast(AssetBrowserEntry::Column::Name): + return QString("Name"); + case static_cast(AssetBrowserEntry::Column::Path): + return QString("Path"); + default: + return QString::number(section); + } + } + return QSortFilterProxyModel::headerData(section, orientation, role); // QVariant(); + } + int AssetBrowserTableModel::BuildMap(const QAbstractItemModel* model, const QModelIndex& parent, int row) { - //int rows = model ? model->rowCount(parent) : 0; - //for (int i = 0; i < rows; ++i) - //{ - // auto index = model->index(i, 0, parent); - // //if (!model->hasChildren(index)) - // //{ - // beginInsertRows(parent, row, row); - // m_rowMap[index] = row; - // m_indexMap[row] = index; - // endInsertRows(); - // Q_EMIT dataChanged(parent, parent); - // row = row + 1; - // //} - // if (model->hasChildren(index)) - // { - // row = BuildMap(model, index, row); - // } - //} - //return row; int rows = model ? model->rowCount(parent) : 0; for (int i = 0; i < rows; ++i) { - auto index = model->index(i, 0, parent); + QModelIndex index = model->index(i, 0, parent); if (model->hasChildren(index) == false) { beginInsertRows(parent, row, row); m_rowMap[index] = row; m_indexMap[row] = index; endInsertRows(); - Q_EMIT dataChanged(parent, parent); + + Q_EMIT dataChanged(index, index); row = row + 1; } @@ -173,12 +142,12 @@ namespace AzToolsFramework } void AssetBrowserTableModel::UpdateMap() { + //Not properly clears the indexes. //m_indexMap.clear(); //m_rowMap.clear(); - + emit layoutAboutToBeChanged(); if (m_indexMap.size() > 0) { - //beginRemoveRows(m_indexMap.first().parent(), m_indexMap.first().row(), m_indexMap.last().row()); for (const auto& key : m_indexMap.keys()) { beginRemoveRows(m_indexMap[key], m_indexMap[key].row(), m_indexMap[key].row()); @@ -186,160 +155,11 @@ namespace AzToolsFramework m_indexMap.remove(key); endRemoveRows(); } - //endRemoveRows(); } BuildMap(sourceModel()); + sort(0); } - - //---------------------------------------AssetBrowserTableFilterModel-------------------------------------------- - //AssetBrowserTableFilterModel::AssetBrowserTableFilterModel(QObject* parent) - // : QSortFilterProxyModel(parent) - //{ - // m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); - // m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); - // AssetBrowserComponentNotificationBus::Handler::BusConnect(); - //} - - //AssetBrowserTableFilterModel::~AssetBrowserTableFilterModel() - //{ - // AssetBrowserComponentNotificationBus::Handler::BusDisconnect(); - //} - - //void AssetBrowserTableFilterModel::setSourceModel(QAbstractItemModel* sourceModel) - //{ - // QSortFilterProxyModel::setSourceModel(sourceModel); - //} - - //void AssetBrowserTableFilterModel::SetFilter(FilterConstType filter) - //{ - // connect(filter.data(), &AssetBrowserEntryFilter::updatedSignal, this, &AssetBrowserTableFilterModel::filterUpdatedSlot); - // m_filter = filter; - // m_invalidateFilter = true; - // // asset browser entries are not guaranteed to have populated when the filter is set, delay filtering until they are - // bool isAssetBrowserComponentReady = false; - // AssetBrowserComponentRequestBus::BroadcastResult(isAssetBrowserComponentReady, &AssetBrowserComponentRequests::AreEntriesReady); - // if (isAssetBrowserComponentReady) - // { - // OnAssetBrowserComponentReady(); - // } - //} - - //void AssetBrowserTableFilterModel::FilterUpdatedSlotImmediate() - //{ - // auto compFilter = qobject_cast>(m_filter); - // if (compFilter) - // { - // auto& subFilters = compFilter->GetSubFilters(); - // auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { - // auto assetTypeFilter = qobject_cast>(filter); - // return !assetTypeFilter.isNull(); - // }); - // if (it != subFilters.end()) - // { - // m_assetTypeFilter = qobject_cast>(*it); - // } - // it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { - // auto stringFilter = qobject_cast>(filter); - // return !stringFilter.isNull(); - // }); - // if (it != subFilters.end()) - // { - // m_stringFilter = qobject_cast>(*it); - // } - // } - // invalidateFilter(); - // Q_EMIT filterChanged(); - //} - - //void AssetBrowserTableFilterModel::OnAssetBrowserComponentReady() - //{ - // if (m_invalidateFilter) - // { - // invalidateFilter(); - // m_invalidateFilter = false; - // } - // Q_EMIT entriesUpdated(); - //} - - //bool AssetBrowserTableFilterModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const - //{ - // AZ_UNUSED(source_row); - // AZ_UNUSED(source_parent); - // QModelIndex idx = sourceModel()->index(source_row, 0, source_parent); - // if (!idx.isValid()) - // { - // return false; - // } - // // no filter present, every entry is visible - // if (!m_filter) - // { - // return true; - // } - - // //// the entry is the internal pointer of the index - // //auto entry = static_cast(idx.internalPointer()); - - // //if (entry) - // //{ - // // // root should return true even if its not displayed in the treeview - // // if (entry && entry->GetEntryType() == AssetBrowserEntry::AssetEntryType::Root) - // // { - // // return true; - // // } - // // return m_filter->Match(entry); - // //} - // return true; - //} - - //bool AssetBrowserTableFilterModel::filterAcceptsColumn(int source_column, const QModelIndex&) const - //{ - // return m_showColumn.find(source_column) != m_showColumn.end(); - //} - - //bool AssetBrowserTableFilterModel::lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const - //{ - // if (source_left.column() == source_right.column()) - // { - // QVariant leftData = sourceModel()->data(source_left, AssetBrowserModel::Roles::EntryRole); - // QVariant rightData = sourceModel()->data(source_right, AssetBrowserModel::Roles::EntryRole); - // if (leftData.canConvert() && rightData.canConvert()) - // { - // auto leftEntry = qvariant_cast(leftData); - // auto rightEntry = qvariant_cast(rightData); - - // // folders should always come first - // if (azrtti_istypeof(leftEntry) && - // azrtti_istypeof(rightEntry)) - // { - // return false; - // } - // if (azrtti_istypeof(leftEntry) && - // azrtti_istypeof(rightEntry)) - // { - // return true; - // } - - // // if both entries are of same type, sort alphabetically - // return m_collator.compare(leftEntry->GetDisplayName(), rightEntry->GetDisplayName()) > 0; - // } - // } - // return QSortFilterProxyModel::lessThan(source_left, source_right); - //} - - //void AssetBrowserTableFilterModel::filterUpdatedSlot() - //{ - // if (!m_alreadyRecomputingFilters) - // { - // m_alreadyRecomputingFilters = true; - // // de-bounce it, since we may get many filter updates all at once. - // QTimer::singleShot(0, this, [this]() { - // m_alreadyRecomputingFilters = false; - // FilterUpdatedSlotImmediate(); - // }); - // } - //} - } // namespace AssetBrowser } // namespace AzToolsFramework #include "AssetBrowser/moc_AssetBrowserTableModel.cpp" diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index 34cf8432ff..69b8ead7c5 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -1,9 +1,6 @@ #pragma once #if !defined(Q_MOC_RUN) -#include #include -#include - #include #include #include @@ -26,21 +23,15 @@ namespace AzToolsFramework class AssetBrowserTableModel : public QSortFilterProxyModel - , public AssetBrowserComponentNotificationBus::Handler { Q_OBJECT public: AZ_CLASS_ALLOCATOR(AssetBrowserTableModel, AZ::SystemAllocator, 0); explicit AssetBrowserTableModel(QObject* parent = nullptr); - ~AssetBrowserTableModel(); - //////////////////////////////////////////////////////////////////// - // AssetBrowserComponentNotificationBus - //////////////////////////////////////////////////////////////////// - void OnAssetBrowserComponentReady() override; - void setSourceModel(QAbstractItemModel* sourceModel) override; //////////////////////////////////////////////////////////////////// // QSortFilterProxyModel + void setSourceModel(QAbstractItemModel* sourceModel) override; QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override; bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; @@ -52,7 +43,7 @@ namespace AzToolsFramework void UpdateMap(); protected: int rowCount(const QModelIndex& parent = QModelIndex()) const override; - //QVariant headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const override; + QVariant headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const override; //////////////////////////////////////////////////////////////////// private: @@ -63,52 +54,5 @@ namespace AzToolsFramework QMap m_indexMap; QMap m_rowMap; }; - - //class AssetBrowserTableFilterModel - // : public QSortFilterProxyModel - // , public AssetBrowserComponentNotificationBus::Handler - //{ - // Q_OBJECT - //public: - // explicit AssetBrowserTableFilterModel(QObject* parent = nullptr); - // ~AssetBrowserTableFilterModel(); - - // void setSourceModel(QAbstractItemModel* sourceModel) override; - // // asset type filtering - // void SetFilter(FilterConstType filter); - // void FilterUpdatedSlotImmediate(); - - // ////////////////////////////////////////////////////////////////////////// - // // AssetBrowserComponentNotificationBus - // ////////////////////////////////////////////////////////////////////////// - // void OnAssetBrowserComponentReady() override; - - //Q_SIGNALS: - // void filterChanged(); - // void entriesUpdated(); - - // ////////////////////////////////////////////////////////////////////////// - // // QSortFilterProxyModel - //protected: - // bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; - // bool filterAcceptsColumn(int source_column, const QModelIndex& /*source_parent*/) const override; - // bool lessThan(const QModelIndex& source_left, const QModelIndex& source_right) const override; - // ////////////////////////////////////////////////////////////////////////// - - //public Q_SLOTS: - // void filterUpdatedSlot(); - - //private: - // AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn; - // bool m_alreadyRecomputingFilters = false; - // // asset source name match filter - // FilterConstType m_filter; - // AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' - // QWeakPointer m_stringFilter; - // QWeakPointer m_assetTypeFilter; - // QCollator m_collator; // cache the collator as its somewhat expensive to constantly create and destroy one. - // AZ_POP_DISABLE_WARNING - // bool m_invalidateFilter = false; - //}; } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index dd4b3b0cad..554c62a251 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -68,7 +68,6 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) , m_ui(new Ui::AzAssetBrowserWindowClass()) , m_filterModel(new AzToolsFramework::AssetBrowser::AssetBrowserFilterModel(parent)) , m_tableModel(new AzToolsFramework::AssetBrowser::AssetBrowserTableModel(parent)) - /*, m_tableFilterModel(new AzToolsFramework::AssetBrowser::AssetBrowserTableFilterModel(parent))*/ { m_ui->setupUi(this); m_ui->m_searchWidget->Setup(true, true); @@ -81,21 +80,13 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_tableModel->setFilterRole(Qt::DisplayRole); m_tableModel->setSourceModel(m_filterModel.data()); - //m_tableModel->setSourceModel(m_assetBrowserModel); - - //m_tableFilterModel->setSourceModel(m_tableModel.data()); - //m_tableFilterModel->SetFilter(m_ui->m_searchWidget->GetFilter()); - m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); m_ui->m_assetBrowserTreeViewWidget->hideColumn(static_cast(AssetBrowserEntry::Column::Path)); - //m_ui->m_assetBrowserTableViewWidget->setModel(m_tableFilterModel.data()); m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); m_ui->m_assetBrowserTableViewWidget->setVisible(false); - //connect(m_filterModel.data(), &AssetBrowserFilterModel::entriesUpdated, m_tableModel.data(), &AssetBrowserTableModel::UpdateMap); - connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), &AssetBrowserFilterModel::filterUpdatedSlot); connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, this, [this]() @@ -105,20 +96,15 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_ui->m_assetBrowserTreeViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex); }); - //connect( m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_tableFilterModel.data(), - // &AssetBrowserTableFilterModel::filterUpdatedSlot); - //connect(m_tableFilterModel.data(), &AssetBrowserTableFilterModel::filterChanged, this, [this]() { - // const bool hasFilter = !m_ui->m_searchWidget->GetFilterString().isEmpty(); - // const bool selectFirstFilteredIndex = false; - // m_ui->m_assetBrowserTableViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex); - //}); - connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, m_tableModel.data(), &AssetBrowserTableModel::UpdateMap); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); connect(m_ui->m_assetBrowserTreeViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); + connect(m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); + + connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, &SearchWidget::ClearStringFilter); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); From 80684b383b66b762dbc3e4537afb536c033a2caa Mon Sep 17 00:00:00 2001 From: igarri Date: Wed, 12 May 2021 11:42:39 +0100 Subject: [PATCH 006/244] Code cleanup --- .../AssetBrowser/AssetBrowserTableModel.cpp | 121 ++++++++---------- .../AssetBrowser/AssetBrowserTableModel.h | 22 +--- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 2 +- 3 files changed, 61 insertions(+), 84 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index ce9e97520a..724e7a54d9 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -1,14 +1,8 @@ -#include -#include -#include -#include -AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") #include #include +#include -#include -AZ_POP_DISABLE_WARNING namespace AzToolsFramework { namespace AssetBrowser @@ -34,11 +28,6 @@ namespace AzToolsFramework } return m_indexMap[proxyIndex.row()]; } - QModelIndex AssetBrowserTableModel::parent(const QModelIndex& child) const - { - AZ_UNUSED(child); - return QModelIndex(); - } QModelIndex AssetBrowserTableModel::mapFromSource(const QModelIndex& sourceIndex) const { Q_ASSERT(!sourceIndex.isValid() || sourceIndex.model() == sourceModel()); @@ -49,44 +38,6 @@ namespace AzToolsFramework return createIndex(m_rowMap[sourceIndex], sourceIndex.column(), sourceIndex.internalPointer()); } - bool AssetBrowserTableModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const - { - AZ_UNUSED(source_row); - AZ_UNUSED(source_parent); - // no filter present, every entry is not visible - if (!m_filterModel->GetFilter()) - { - return true; - } - return true; - } - - QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const - { - return parent.isValid() ? QModelIndex() : createIndex(row, column, m_indexMap[row].internalPointer()); - } - - QVariant AssetBrowserTableModel::data(const QModelIndex& index, int role) const - { - auto sourceIndex = mapToSource(index); - if (!sourceIndex.isValid()) - return QVariant(); - - AssetBrowserEntry* entry = GetAssetEntry(sourceIndex); - if (entry == nullptr) - { - AZ_Assert(false, "ERROR - index internal pointer not pointing to an AssetEntry. Tree provided by the AssetBrowser invalid?"); - return Qt::PartiallyChecked; - } - - return sourceIndex.data(role); - } - - int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const - { - return !parent.isValid() ? m_rowMap.size() : 0; - } - QVariant AssetBrowserTableModel::headerData(int section, Qt::Orientation orientation, int role) const { if (role == Qt::DisplayRole && orientation == Qt::Horizontal) @@ -104,7 +55,50 @@ namespace AzToolsFramework return QSortFilterProxyModel::headerData(section, orientation, role); // QVariant(); } - int AssetBrowserTableModel::BuildMap(const QAbstractItemModel* model, const QModelIndex& parent, int row) + QVariant AssetBrowserTableModel::data(const QModelIndex& index, int role) const + { + auto sourceIndex = mapToSource(index); + if (!sourceIndex.isValid()) + return QVariant(); + + AssetBrowserEntry* entry = GetAssetEntry(sourceIndex); + if (entry == nullptr) + { + AZ_Assert(false, "ERROR - index internal pointer not pointing to an AssetEntry. Tree provided by the AssetBrowser invalid?"); + return Qt::PartiallyChecked; + } + + return sourceIndex.data(role); + } + + QModelIndex AssetBrowserTableModel::index(int row, int column, const QModelIndex& parent) const + { + return parent.isValid() ? QModelIndex() : createIndex(row, column, m_indexMap[row].internalPointer()); + } + + QModelIndex AssetBrowserTableModel::parent(const QModelIndex& child) const + { + AZ_UNUSED(child); + return QModelIndex(); + } + bool AssetBrowserTableModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const + { + AZ_UNUSED(source_row); + AZ_UNUSED(source_parent); + // no filter present, every entry is not visible + if (!m_filterModel->GetFilter()) + { + return true; + } + return true; + } + + int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const + { + return !parent.isValid() ? m_rowMap.size() : 0; + } + + int AssetBrowserTableModel::BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent /*= QModelIndex()*/, int row /*= 0*/) { int rows = model ? model->rowCount(parent) : 0; for (int i = 0; i < rows; ++i) @@ -123,7 +117,7 @@ namespace AzToolsFramework if (model->hasChildren(index)) { - row = BuildMap(model, index, row); + row = BuildTableModelMap(model, index, row); } } return row; @@ -140,25 +134,18 @@ namespace AzToolsFramework return nullptr; } } - void AssetBrowserTableModel::UpdateMap() - { - //Not properly clears the indexes. - //m_indexMap.clear(); - //m_rowMap.clear(); + void AssetBrowserTableModel::UpdateTableModelMaps() +{ emit layoutAboutToBeChanged(); if (m_indexMap.size() > 0) { - for (const auto& key : m_indexMap.keys()) - { - beginRemoveRows(m_indexMap[key], m_indexMap[key].row(), m_indexMap[key].row()); - m_rowMap.remove(m_indexMap[key]); - m_indexMap.remove(key); - endRemoveRows(); - } + beginRemoveRows(m_indexMap.first(), m_indexMap.first().row(), m_indexMap.last().row()); + m_rowMap.clear(); + m_indexMap.clear(); + endRemoveRows(); } - - BuildMap(sourceModel()); - sort(0); + BuildTableModelMap(sourceModel()); + emit layoutChanged(); } } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index 69b8ead7c5..51976c3482 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -1,25 +1,16 @@ #pragma once #if !defined(Q_MOC_RUN) -#include #include -#include -#include -//#include -#include - -AZ_PUSH_DISABLE_WARNING( - 4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' -#include -#include #include +#include #endif -AZ_POP_DISABLE_WARNING + namespace AzToolsFramework { namespace AssetBrowser { class AssetBrowserFilterModel; - + class AssetBrowserEntry; class AssetBrowserTableModel : public QSortFilterProxyModel @@ -34,21 +25,20 @@ namespace AzToolsFramework void setSourceModel(QAbstractItemModel* sourceModel) override; QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override; - bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; QModelIndex parent(const QModelIndex& child) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - public Q_SLOTS: - void UpdateMap(); + void UpdateTableModelMaps(); protected: + bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const override; //////////////////////////////////////////////////////////////////// private: AssetBrowserEntry* GetAssetEntry(QModelIndex index) const; - int BuildMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0); + int BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent = QModelIndex(), int row = 0); private: QPointer m_filterModel; QMap m_indexMap; diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 554c62a251..f415e0a135 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -96,7 +96,7 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_ui->m_assetBrowserTreeViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex); }); - connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, m_tableModel.data(), &AssetBrowserTableModel::UpdateMap); + connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, m_tableModel.data(), &AssetBrowserTableModel::UpdateTableModelMaps); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); From c1e21185b43e7892973dc1055ae19d1b9099b5e1 Mon Sep 17 00:00:00 2001 From: igarri Date: Wed, 12 May 2021 12:20:23 +0100 Subject: [PATCH 007/244] Selecting correct indexes from Asset Browser Model --- .../Views/AssetBrowserTableView.cpp | 22 +++++------ .../Views/AssetBrowserTableView.h | 7 +--- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 39 ++++++++++++++++++- .../AzAssetBrowser/AzAssetBrowserWindow.h | 2 +- 4 files changed, 52 insertions(+), 18 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index aa35d99894..0a6aeed374 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -47,7 +47,7 @@ namespace AzToolsFramework setMouseTracking(true); connect(this, &QTableView::customContextMenuRequested, this, &AssetBrowserTableView::OnContextMenu); - connect(m_scTimer, &QTimer::timeout, this, &AssetBrowserTableView::OnUpdateSCThumbnailsList); + //connect(m_scTimer, &QTimer::timeout, this, &AssetBrowserTableView::OnUpdateSCThumbnailsList); AssetBrowserViewRequestBus::Handler::BusConnect(); AssetBrowserComponentNotificationBus::Handler::BusConnect(); @@ -59,9 +59,9 @@ namespace AzToolsFramework } void AssetBrowserTableView::setModel(QAbstractItemModel* model) { - m_filterModel = qobject_cast(model); - AZ_Assert(m_filterModel, "Expecting AssetBrowserTableModel"); - m_sourceModel = qobject_cast(m_filterModel->sourceModel()); + m_tableModel = qobject_cast(model); + AZ_Assert(m_tableModel, "Expecting AssetBrowserTableModel"); + m_sourceFilterModel = qobject_cast(m_tableModel->sourceModel()); QTableView::setModel(model); } void AssetBrowserTableView::SetName(const QString& name) @@ -76,14 +76,14 @@ namespace AzToolsFramework } AZStd::vector AssetBrowserTableView::GetSelectedAssets() const { - QModelIndexList sourceIndexes{}; - //for (const auto& index : selectedIndexes()) - //{ - // sourceIndexes.push_back(m_sourceModel->mapToSource(index)); - //} + QModelIndexList sourceIndexes; + for (const auto& index : selectedIndexes()) + { + sourceIndexes.push_back(m_sourceFilterModel->mapToSource(m_tableModel->mapToSource(index))); + } AZStd::vector entries; - //AssetBrowserModel::SourceIndexesToAssetDatabaseEntries(sourceIndexes, entries); + AssetBrowserModel::SourceIndexesToAssetDatabaseEntries(sourceIndexes, entries); return entries; } void AssetBrowserTableView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) @@ -124,7 +124,7 @@ namespace AzToolsFramework { emit ClearStringFilter(); emit ClearTypeFilter(); - m_sourceModel->FilterUpdatedSlotImmediate(); + m_sourceFilterModel->FilterUpdatedSlotImmediate(); } void AssetBrowserTableView::Update() diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index aef7353334..d1bab70104 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -63,13 +63,10 @@ namespace AzToolsFramework private: QString m_name; - QPointer m_filterModel = nullptr; - QPointer m_sourceModel = nullptr; + QPointer m_tableModel = nullptr; + QPointer m_sourceFilterModel = nullptr; EntryDelegate* m_delegate = nullptr; - QTimer* m_scTimer = nullptr; - const int m_scUpdateInterval = 100; - private Q_SLOTS: void OnContextMenu(const QPoint& point); //! Get all visible source entries and place them in a queue to update their source control status diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index f415e0a135..b59190d9a9 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -102,7 +102,7 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) this, &AzAssetBrowserWindow::SelectionChangedSlot); connect(m_ui->m_assetBrowserTreeViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); - connect(m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); + connect(m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItemTableModel); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, &SearchWidget::ClearStringFilter); @@ -242,6 +242,43 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& } +void AzAssetBrowserWindow::DoubleClickedItemTableModel([[maybe_unused]] const QModelIndex& element) +{ + using namespace AzToolsFramework; + using namespace AzToolsFramework::AssetBrowser; + // assumption: Double clicking an item selects it before telling us we double clicked it. + auto selectedAssets = m_ui->m_assetBrowserTableViewWidget->GetSelectedAssets(); + for (const AssetBrowserEntry* entry : selectedAssets) + { + AZ::Data::AssetId assetIdToOpen; + AZStd::string fullFilePath; + + if (const ProductAssetBrowserEntry* productEntry = azrtti_cast(entry)) + { + assetIdToOpen = productEntry->GetAssetId(); + fullFilePath = entry->GetFullPath(); + } + else if (const SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry)) + { + // manufacture an empty AssetID with the source's UUID + assetIdToOpen = AZ::Data::AssetId(sourceEntry->GetSourceUuid(), 0); + fullFilePath = entry->GetFullPath(); + } + + bool handledBySomeone = false; + if (assetIdToOpen.IsValid()) + { + AssetBrowserInteractionNotificationBus::Broadcast( + &AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); + } + + if (!handledBySomeone && !fullFilePath.empty()) + { + AzAssetBrowserRequestHandler::OpenWithOS(fullFilePath); + } + } +} + void AzAssetBrowserWindow::SwitchDisplayView(const int state) { m_ui->m_assetBrowserTableViewWidget->setVisible(state); diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h index 801af3e2a8..86d81ad873 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h @@ -56,7 +56,6 @@ private: QScopedPointer m_ui; QScopedPointer m_filterModel; QScopedPointer m_tableModel; - //QScopedPointer m_tableFilterModel; AzToolsFramework::AssetBrowser::AssetBrowserModel* m_assetBrowserModel; void UpdatePreview() const; @@ -64,6 +63,7 @@ private: private Q_SLOTS: void SelectionChangedSlot(const QItemSelection& selected, const QItemSelection& deselected) const; void DoubleClickedItem(const QModelIndex& element); + void DoubleClickedItemTableModel(const QModelIndex& element); void SwitchDisplayView(const int state); }; From d6868df735033804d51c52949bfcc87d1d6cbeb6 Mon Sep 17 00:00:00 2001 From: igarri Date: Thu, 13 May 2021 12:29:16 +0100 Subject: [PATCH 008/244] Expanding TableView Columns --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 2 +- .../AssetBrowser/AssetBrowserTableModel.cpp | 1 - .../AssetBrowser/Views/AssetBrowserTableView.cpp | 15 ++++----------- .../AssetBrowser/Views/AssetBrowserTableView.h | 5 ----- 4 files changed, 5 insertions(+), 18 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 34f8b97b5a..ee3aa04e27 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -32,7 +32,7 @@ namespace AzToolsFramework : QSortFilterProxyModel(parent) { m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); - //m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); + m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); m_collator.setNumericMode(true); AssetBrowserComponentNotificationBus::Handler::BusConnect(); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index 724e7a54d9..13b298cdec 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -1,4 +1,3 @@ - #include #include #include diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index 0a6aeed374..40e0b9db5e 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -1,7 +1,5 @@ #include -#include -#include #include #include @@ -14,8 +12,6 @@ #include #include #include -#include -#include AZ_PUSH_DISABLE_WARNING( 4244 4251 4800, "-Wunknown-warning-option") // conversion from 'int' to 'float', possible loss of data, needs to have dll-interface to @@ -37,17 +33,16 @@ namespace AzToolsFramework AssetBrowserTableView::AssetBrowserTableView(QWidget* parent) : QTableView(parent) , m_delegate(new EntryDelegate(this)) - { setSortingEnabled(true); setItemDelegate(m_delegate); - //header()->hide(); + verticalHeader()->hide(); setContextMenuPolicy(Qt::CustomContextMenu); setMouseTracking(true); + setSortingEnabled(false); connect(this, &QTableView::customContextMenuRequested, this, &AssetBrowserTableView::OnContextMenu); - //connect(m_scTimer, &QTimer::timeout, this, &AssetBrowserTableView::OnUpdateSCThumbnailsList); AssetBrowserViewRequestBus::Handler::BusConnect(); AssetBrowserComponentNotificationBus::Handler::BusConnect(); @@ -63,6 +58,8 @@ namespace AzToolsFramework AZ_Assert(m_tableModel, "Expecting AssetBrowserTableModel"); m_sourceFilterModel = qobject_cast(m_tableModel->sourceModel()); QTableView::setModel(model); + horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch); + horizontalHeader()->setSectionResizeMode(1,QHeaderView::ResizeMode::Stretch); } void AssetBrowserTableView::SetName(const QString& name) { @@ -105,10 +102,6 @@ namespace AzToolsFramework } } QTableView::rowsAboutToBeRemoved(parent, start, end); - } - void AssetBrowserTableView::OnUpdateSCThumbnailsList() - { - } void AssetBrowserTableView::SelectProduct(AZ::Data::AssetId assetID) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index d1bab70104..531e962297 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -58,9 +58,6 @@ namespace AzToolsFramework void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override; void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override; - //! Get all visible source entries and place them in a queue to update their source control status - //void OnUpdateSCThumbnailsList(); - private: QString m_name; QPointer m_tableModel = nullptr; @@ -69,8 +66,6 @@ namespace AzToolsFramework private Q_SLOTS: void OnContextMenu(const QPoint& point); - //! Get all visible source entries and place them in a queue to update their source control status - void OnUpdateSCThumbnailsList(); }; } // namespace AssetBrowser } // namespace AzToolsFramework From d7ca3f273bb656f0b162eeeede07ba87cafca22f Mon Sep 17 00:00:00 2001 From: igarri Date: Thu, 13 May 2021 13:25:03 +0100 Subject: [PATCH 009/244] croll to top on view when the filter updates --- .../AssetBrowser/AssetBrowserTableModel.cpp | 1 + .../AssetBrowser/Views/AssetBrowserTableView.cpp | 9 +++++++++ .../AssetBrowser/Views/AssetBrowserTableView.h | 1 + 3 files changed, 11 insertions(+) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index 13b298cdec..7991eb35d8 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -145,6 +145,7 @@ namespace AzToolsFramework } BuildTableModelMap(sourceModel()); emit layoutChanged(); + } } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index 40e0b9db5e..83a0f2ce9f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -58,6 +58,8 @@ namespace AzToolsFramework AZ_Assert(m_tableModel, "Expecting AssetBrowserTableModel"); m_sourceFilterModel = qobject_cast(m_tableModel->sourceModel()); QTableView::setModel(model); + connect(m_tableModel, &AssetBrowserTableModel::layoutChanged, this, &AssetBrowserTableView::layoutChangedSlot); + horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch); horizontalHeader()->setSectionResizeMode(1,QHeaderView::ResizeMode::Stretch); } @@ -103,6 +105,13 @@ namespace AzToolsFramework } QTableView::rowsAboutToBeRemoved(parent, start, end); } + void AssetBrowserTableView::layoutChangedSlot(const QList& parents, QAbstractItemModel::LayoutChangeHint hint) + { + AZ_UNUSED(parents); + AZ_UNUSED(hint); + + scrollToTop(); + } void AssetBrowserTableView::SelectProduct(AZ::Data::AssetId assetID) { AZ_UNUSED(assetID); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index 531e962297..b39d48c391 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -57,6 +57,7 @@ namespace AzToolsFramework protected Q_SLOTS: void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override; void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override; + void layoutChangedSlot(const QList &parents = QList(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint); private: QString m_name; From 33240c9f90fad3cf4c4e30ef1fcda909a0acad7b Mon Sep 17 00:00:00 2001 From: igarri Date: Thu, 13 May 2021 16:08:14 +0100 Subject: [PATCH 010/244] Selecting assets from tableview --- .../AssetBrowser/AssetBrowserTableModel.cpp | 13 +------------ .../AssetBrowser/AssetBrowserTableModel.h | 2 -- .../AssetBrowser/Views/AssetBrowserTableView.cpp | 12 ++++++++---- .../AssetBrowser/Views/AssetBrowserTreeView.cpp | 5 ++++- 4 files changed, 13 insertions(+), 19 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index 7991eb35d8..bebdf44c9a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -27,15 +27,6 @@ namespace AzToolsFramework } return m_indexMap[proxyIndex.row()]; } - QModelIndex AssetBrowserTableModel::mapFromSource(const QModelIndex& sourceIndex) const - { - Q_ASSERT(!sourceIndex.isValid() || sourceIndex.model() == sourceModel()); - if (!sourceIndex.isValid()) - { - return QModelIndex(); - } - return createIndex(m_rowMap[sourceIndex], sourceIndex.column(), sourceIndex.internalPointer()); - } QVariant AssetBrowserTableModel::headerData(int section, Qt::Orientation orientation, int role) const { @@ -94,7 +85,7 @@ namespace AzToolsFramework int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const { - return !parent.isValid() ? m_rowMap.size() : 0; + return !parent.isValid() ? m_indexMap.size() : 0; } int AssetBrowserTableModel::BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent /*= QModelIndex()*/, int row /*= 0*/) @@ -106,7 +97,6 @@ namespace AzToolsFramework if (model->hasChildren(index) == false) { beginInsertRows(parent, row, row); - m_rowMap[index] = row; m_indexMap[row] = index; endInsertRows(); @@ -139,7 +129,6 @@ namespace AzToolsFramework if (m_indexMap.size() > 0) { beginRemoveRows(m_indexMap.first(), m_indexMap.first().row(), m_indexMap.last().row()); - m_rowMap.clear(); m_indexMap.clear(); endRemoveRows(); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index 51976c3482..432300194b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -24,7 +24,6 @@ namespace AzToolsFramework // QSortFilterProxyModel void setSourceModel(QAbstractItemModel* sourceModel) override; QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; - QModelIndex mapFromSource(const QModelIndex& sourceIndex) const override; QModelIndex parent(const QModelIndex& child) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; @@ -42,7 +41,6 @@ namespace AzToolsFramework private: QPointer m_filterModel; QMap m_indexMap; - QMap m_rowMap; }; } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index 83a0f2ce9f..cb4a989043 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -41,6 +41,7 @@ namespace AzToolsFramework setMouseTracking(true); setSortingEnabled(false); + setSelectionMode(QAbstractItemView::SingleSelection); connect(this, &QTableView::customContextMenuRequested, this, &AssetBrowserTableView::OnContextMenu); @@ -61,7 +62,7 @@ namespace AzToolsFramework connect(m_tableModel, &AssetBrowserTableModel::layoutChanged, this, &AssetBrowserTableView::layoutChangedSlot); horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch); - horizontalHeader()->setSectionResizeMode(1,QHeaderView::ResizeMode::Stretch); + horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch); } void AssetBrowserTableView::SetName(const QString& name) { @@ -78,7 +79,10 @@ namespace AzToolsFramework QModelIndexList sourceIndexes; for (const auto& index : selectedIndexes()) { - sourceIndexes.push_back(m_sourceFilterModel->mapToSource(m_tableModel->mapToSource(index))); + if (index.column() == 0) + { + sourceIndexes.push_back(m_sourceFilterModel->mapToSource(m_tableModel->mapToSource(index))); + } } AZStd::vector entries; @@ -87,8 +91,8 @@ namespace AzToolsFramework } void AssetBrowserTableView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { - AZ_UNUSED(selected); - AZ_UNUSED(deselected); + QTableView::selectionChanged(selected, deselected); + Q_EMIT selectionChangedSignal(selected, deselected); } void AssetBrowserTableView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) { diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp index eeee433835..f2a5cc1a3a 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp @@ -101,7 +101,10 @@ namespace AzToolsFramework QModelIndexList sourceIndexes; for (const auto& index : selectedIndexes()) { - sourceIndexes.push_back(m_assetBrowserSortFilterProxyModel->mapToSource(index)); + if (index.column() == 0) + { + sourceIndexes.push_back(m_assetBrowserSortFilterProxyModel->mapToSource(index)); + } } AZStd::vector entries; From cff9fea535c91a08ce4d444c2a79823d53f2f75c Mon Sep 17 00:00:00 2001 From: igarri Date: Fri, 14 May 2021 13:09:14 +0100 Subject: [PATCH 011/244] Switching views with filters --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 6 ++++++ .../AssetBrowser/AssetBrowserFilterModel.h | 2 +- .../AzToolsFramework/AssetBrowser/Search/Filter.cpp | 5 +++++ .../AzToolsFramework/AssetBrowser/Search/Filter.h | 2 +- .../AssetBrowser/Views/AssetBrowserTreeView.cpp | 2 ++ .../Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp | 9 +++++++-- .../Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h | 2 +- 7 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index ee3aa04e27..b4728633d3 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -130,6 +130,9 @@ namespace AzToolsFramework if (compFilter) { auto& subFilters = compFilter->GetSubFilters(); + //bool bNoFilters = false; + + auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { auto assetTypeFilter = qobject_cast >(filter); @@ -147,8 +150,11 @@ namespace AzToolsFramework if (it != subFilters.end()) { m_stringFilter = qobject_cast >(*it); + emit switchFilterView(m_stringFilter.toStrongRef()->IsEmpty()); } } + + invalidateFilter(); Q_EMIT filterChanged(); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h index 6cccc53eb6..71689354d1 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h @@ -52,8 +52,8 @@ namespace AzToolsFramework void OnAssetBrowserComponentReady() override; Q_SIGNALS: + void switchFilterView(int); void filterChanged(); - ////////////////////////////////////////////////////////////////////////// //QSortFilterProxyModel protected: diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.cpp index ceda5f8e19..86315613ad 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.cpp @@ -233,6 +233,11 @@ namespace AzToolsFramework Q_EMIT updatedSignal(); } + bool StringFilter::IsEmpty() const + { + return m_filterString.isEmpty(); + } + QString StringFilter::GetNameInternal() const { return m_filterString; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h index b67b699862..6d19fb3b47 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h @@ -110,7 +110,7 @@ namespace AzToolsFramework ~StringFilter() override = default; void SetFilterString(const QString& filterString); - + bool IsEmpty() const; protected: QString GetNameInternal() const override; bool MatchInternal(const AssetBrowserEntry* entry) const override; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp index f2a5cc1a3a..e29607698d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp @@ -52,6 +52,7 @@ namespace AzToolsFramework setSortingEnabled(true); setItemDelegate(m_delegate); header()->hide(); + setContextMenuPolicy(Qt::CustomContextMenu); setMouseTracking(true); @@ -174,6 +175,7 @@ namespace AzToolsFramework void AssetBrowserTreeView::OnAssetBrowserComponentReady() { + hideColumn(static_cast(AssetBrowserEntry::Column::Path)); if (!m_name.isEmpty()) { auto crc = AZ::Crc32(m_name.toUtf8().data()); diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index b59190d9a9..d1bbbb1f9d 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -82,7 +82,7 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_tableModel->setSourceModel(m_filterModel.data()); m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); - m_ui->m_assetBrowserTreeViewWidget->hideColumn(static_cast(AssetBrowserEntry::Column::Path)); + //m_ui->m_assetBrowserTreeViewWidget->hideColumn(static_cast(AssetBrowserEntry::Column::Path)); m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); m_ui->m_assetBrowserTableViewWidget->setVisible(false); @@ -97,9 +97,14 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) }); connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, m_tableModel.data(), &AssetBrowserTableModel::UpdateTableModelMaps); + connect(m_filterModel.data(), &AssetBrowserFilterModel::switchFilterView, this, &AzAssetBrowserWindow::SwitchDisplayView); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); + + connect(m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::selectionChangedSignal, + this, &AzAssetBrowserWindow::SelectionChangedSlot); + connect(m_ui->m_assetBrowserTreeViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); connect(m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItemTableModel); @@ -279,7 +284,7 @@ void AzAssetBrowserWindow::DoubleClickedItemTableModel([[maybe_unused]] const QM } } -void AzAssetBrowserWindow::SwitchDisplayView(const int state) +void AzAssetBrowserWindow::SwitchDisplayView(bool state) { m_ui->m_assetBrowserTableViewWidget->setVisible(state); m_ui->m_assetBrowserTreeViewWidget->setVisible(!state); diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h index 86d81ad873..8c32a913ba 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h @@ -64,7 +64,7 @@ private Q_SLOTS: void SelectionChangedSlot(const QItemSelection& selected, const QItemSelection& deselected) const; void DoubleClickedItem(const QModelIndex& element); void DoubleClickedItemTableModel(const QModelIndex& element); - void SwitchDisplayView(const int state); + void SwitchDisplayView(bool state); }; extern const char* AZ_ASSET_BROWSER_PREVIEW_NAME; From b9c9811d3566a008feb330ef79d82b501bcd2ac3 Mon Sep 17 00:00:00 2001 From: igarri Date: Mon, 17 May 2021 14:06:01 +0100 Subject: [PATCH 012/244] Fixing qobject_cast to the StringFilter --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 33 ++++++++++++++----- .../AssetBrowser/AssetBrowserFilterModel.h | 2 +- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 2 +- 3 files changed, 26 insertions(+), 11 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index b4728633d3..9ee00a96ae 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -130,9 +130,7 @@ namespace AzToolsFramework if (compFilter) { auto& subFilters = compFilter->GetSubFilters(); - //bool bNoFilters = false; - auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { auto assetTypeFilter = qobject_cast >(filter); @@ -142,21 +140,38 @@ namespace AzToolsFramework { m_assetTypeFilter = qobject_cast >(*it); } - it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool + + it = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filter) -> bool { - auto stringFilter = qobject_cast >(filter); - return !stringFilter.isNull(); + auto stringCompositeFilter = qobject_cast >(filter); + bool isStringFilter = false; + if (stringCompositeFilter) + { + auto& subFilters = stringCompositeFilter->GetSubFilters(); + auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filt) -> bool + { + auto strFilter = qobject_cast>(filt); + return !strFilter.isNull(); + }); + if (it != subFilters.end()) + { + isStringFilter = true; + } + } + + return isStringFilter; }); if (it != subFilters.end()) { - m_stringFilter = qobject_cast >(*it); - emit switchFilterView(m_stringFilter.toStrongRef()->IsEmpty()); + auto compStringFilter = qobject_cast>(*it); + m_stringFilter = qobject_cast>(compStringFilter->GetSubFilters()[0]); } + } - - invalidateFilter(); Q_EMIT filterChanged(); + emit stringFilterPopulated(!m_stringFilter.isNull()); + } void AssetBrowserFilterModel::filterUpdatedSlot() diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h index 71689354d1..7a6faf9f18 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h @@ -52,7 +52,7 @@ namespace AzToolsFramework void OnAssetBrowserComponentReady() override; Q_SIGNALS: - void switchFilterView(int); + void stringFilterPopulated(bool); void filterChanged(); ////////////////////////////////////////////////////////////////////////// //QSortFilterProxyModel diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index d1bbbb1f9d..047d4d4dc2 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -97,7 +97,6 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) }); connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, m_tableModel.data(), &AssetBrowserTableModel::UpdateTableModelMaps); - connect(m_filterModel.data(), &AssetBrowserFilterModel::switchFilterView, this, &AzAssetBrowserWindow::SwitchDisplayView); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); @@ -119,6 +118,7 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main"); m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main"); + connect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); connect(m_ui->m_viewSwitcherCheckBox, &QCheckBox::stateChanged, this, &AzAssetBrowserWindow::SwitchDisplayView); } From 10ca002ced59314ac7e4bc01365a2fb7f4682ebe Mon Sep 17 00:00:00 2001 From: igarri Date: Mon, 17 May 2021 14:25:43 +0100 Subject: [PATCH 013/244] Checkbox to select view --- .../Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp | 13 ++++++++++++- .../Editor/AzAssetBrowser/AzAssetBrowserWindow.h | 1 + 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 047d4d4dc2..8c01f6841c 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -119,7 +119,7 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main"); connect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); - connect(m_ui->m_viewSwitcherCheckBox, &QCheckBox::stateChanged, this, &AzAssetBrowserWindow::SwitchDisplayView); + connect(m_ui->m_viewSwitcherCheckBox, &QCheckBox::stateChanged, this, &AzAssetBrowserWindow::LockToDefaultView); } AzAssetBrowserWindow::~AzAssetBrowserWindow() @@ -290,4 +290,15 @@ void AzAssetBrowserWindow::SwitchDisplayView(bool state) m_ui->m_assetBrowserTreeViewWidget->setVisible(!state); } +void AzAssetBrowserWindow::LockToDefaultView(bool state) +{ + using namespace AzToolsFramework; + using namespace AzToolsFramework::AssetBrowser; + SwitchDisplayView(!state); + if (state == true) + disconnect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); + else + connect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); +} + #include diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h index 8c32a913ba..1174335995 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.h @@ -65,6 +65,7 @@ private Q_SLOTS: void DoubleClickedItem(const QModelIndex& element); void DoubleClickedItemTableModel(const QModelIndex& element); void SwitchDisplayView(bool state); + void LockToDefaultView(bool state); }; extern const char* AZ_ASSET_BROWSER_PREVIEW_NAME; From 61ac423ebdc0c9865a95710d94f7f21c1c9ce463 Mon Sep 17 00:00:00 2001 From: igarri Date: Mon, 17 May 2021 16:04:43 +0100 Subject: [PATCH 014/244] Deleted unused files --- .../AzToolsFramework/AssetBrowserTableModel.h | 36 ------------------- 1 file changed, 36 deletions(-) delete mode 100644 Code/Framework/AzToolsFramework/AssetBrowserTableModel.h diff --git a/Code/Framework/AzToolsFramework/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AssetBrowserTableModel.h deleted file mode 100644 index 4e65b3921c..0000000000 --- a/Code/Framework/AzToolsFramework/AssetBrowserTableModel.h +++ /dev/null @@ -1,36 +0,0 @@ -#pragma once -#if !defined(Q_MOC_RUN) -#include -#include -#include - -#include -#include -#include - -AZ_PUSH_DISABLE_WARNING( - 4251, "-Wunknown-warning-option") // 4251: class '...' needs to have dll-interface to be used by clients of class '...' -#include -#include -#include -#endif -AZ_POP_DISABLE_WARNING -namespace AzToolsFramework -{ - namespace AssetBrowser - { - class AssetBrowserTableModel - : public QSortFilterProxyModel - { - Q_OBJECT - public: - AZ_CLASS_ALLOCATOR(AssetBrowserTableModel, AZ::SystemAllocator, 0); - explicit AssetBrowserTableModel(QObject* parent = nullptr); - - QModelIndex mapToSource(const QModelIndex &proxyIndex) const override; - QModelIndex mapFromSource(const QModelIndex &sourceIndex) const override; - QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; - QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; - }; - } -} From 1c2b8f91118f744314dc4f34ed33fc66245eea7c Mon Sep 17 00:00:00 2001 From: igarri Date: Tue, 18 May 2021 13:33:21 +0100 Subject: [PATCH 015/244] Adding AZ_CVAR for the new feature --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 10 +++- .../AssetBrowser/Search/Filter.cpp | 5 -- .../AssetBrowser/Search/Filter.h | 1 - .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 51 ++++++++++++------- 4 files changed, 43 insertions(+), 24 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 9ee00a96ae..5b820c4d06 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -12,6 +12,7 @@ #include #include #include +#include AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") #include @@ -22,6 +23,10 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") #include AZ_POP_DISABLE_WARNING +AZ_CVAR( + bool, ed_useNewAssetBrowserTableView, false, nullptr, AZ::ConsoleFunctorFlags::Null, + "Use the new AssetBrowser TableView for searching assets."); + namespace AzToolsFramework { namespace AssetBrowser @@ -32,7 +37,10 @@ namespace AzToolsFramework : QSortFilterProxyModel(parent) { m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); - m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); + if (ed_useNewAssetBrowserTableView) + { + m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); + } m_collator.setNumericMode(true); AssetBrowserComponentNotificationBus::Handler::BusConnect(); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.cpp index 86315613ad..ceda5f8e19 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.cpp @@ -233,11 +233,6 @@ namespace AzToolsFramework Q_EMIT updatedSignal(); } - bool StringFilter::IsEmpty() const - { - return m_filterString.isEmpty(); - } - QString StringFilter::GetNameInternal() const { return m_filterString; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h index 6d19fb3b47..135dd00925 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h @@ -110,7 +110,6 @@ namespace AzToolsFramework ~StringFilter() override = default; void SetFilterString(const QString& filterString); - bool IsEmpty() const; protected: QString GetNameInternal() const override; bool MatchInternal(const AssetBrowserEntry* entry) const override; diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 8c01f6841c..c4a79a9394 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -20,6 +20,7 @@ #include #include #include +#include // AzQtComponents #include @@ -32,6 +33,9 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING #include AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING +AZ_CVAR( + bool, ed_useNewAssetBrowserTableView, false, nullptr, AZ::ConsoleFunctorFlags::Null, + "Use the new AssetBrowser TableView for searching assets."); class ListenerForShowAssetEditorEvent : public QObject @@ -78,15 +82,40 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_filterModel->setSourceModel(m_assetBrowserModel); m_filterModel->SetFilter(m_ui->m_searchWidget->GetFilter()); - m_tableModel->setFilterRole(Qt::DisplayRole); - m_tableModel->setSourceModel(m_filterModel.data()); + m_ui->m_viewSwitcherCheckBox->setVisible(false); + m_ui->m_assetBrowserTableViewWidget->setVisible(false); + if (ed_useNewAssetBrowserTableView) + { + m_ui->m_viewSwitcherCheckBox->setVisible(true); + m_tableModel->setFilterRole(Qt::DisplayRole); + m_tableModel->setSourceModel(m_filterModel.data()); + m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); + connect( + m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, m_tableModel.data(), + &AssetBrowserTableModel::UpdateTableModelMaps); + connect( + m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::selectionChangedSignal, this, + &AzAssetBrowserWindow::SelectionChangedSlot); + connect( + m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, + &AzAssetBrowserWindow::DoubleClickedItemTableModel); + connect( + m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget, + &SearchWidget::ClearStringFilter); + connect( + m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget, + &SearchWidget::ClearTypeFilter); + + m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main"); + + connect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); + connect(m_ui->m_viewSwitcherCheckBox, &QCheckBox::stateChanged, this, &AzAssetBrowserWindow::LockToDefaultView); + + } m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); //m_ui->m_assetBrowserTreeViewWidget->hideColumn(static_cast(AssetBrowserEntry::Column::Path)); - m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); - m_ui->m_assetBrowserTableViewWidget->setVisible(false); - connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), &AssetBrowserFilterModel::filterUpdatedSlot); connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, this, [this]() @@ -96,30 +125,18 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_ui->m_assetBrowserTreeViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex); }); - connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, m_tableModel.data(), &AssetBrowserTableModel::UpdateTableModelMaps); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); - connect(m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::selectionChangedSignal, - this, &AzAssetBrowserWindow::SelectionChangedSlot); - connect(m_ui->m_assetBrowserTreeViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); - connect(m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItemTableModel); - connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, &SearchWidget::ClearStringFilter); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); - connect(m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget, &SearchWidget::ClearStringFilter); - connect(m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main"); - m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main"); - - connect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); - connect(m_ui->m_viewSwitcherCheckBox, &QCheckBox::stateChanged, this, &AzAssetBrowserWindow::LockToDefaultView); } AzAssetBrowserWindow::~AzAssetBrowserWindow() From f49e4b33337b47b6939f1df90c99696fd0e5efd5 Mon Sep 17 00:00:00 2001 From: igarri Date: Tue, 18 May 2021 15:26:05 +0100 Subject: [PATCH 016/244] modified code from feedback --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 33 +++++++++++-------- .../AssetBrowser/AssetBrowserModel.cpp | 10 +++--- .../AssetBrowser/AssetBrowserModel.h | 2 -- .../Views/AssetBrowserTreeView.cpp | 1 + .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 5 ++- 5 files changed, 26 insertions(+), 25 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 5b820c4d06..77e5523ee3 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -23,9 +23,7 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") #include AZ_POP_DISABLE_WARNING -AZ_CVAR( - bool, ed_useNewAssetBrowserTableView, false, nullptr, AZ::ConsoleFunctorFlags::Null, - "Use the new AssetBrowser TableView for searching assets."); +AZ_CVAR_EXTERNED(bool, ed_useNewAssetBrowserTableView); namespace AzToolsFramework { @@ -36,10 +34,10 @@ namespace AzToolsFramework AssetBrowserFilterModel::AssetBrowserFilterModel(QObject* parent) : QSortFilterProxyModel(parent) { - m_showColumn.insert(static_cast(AssetBrowserEntry::Column::DisplayName)); + m_showColumn.insert(aznumeric_cast(AssetBrowserEntry::Column::DisplayName)); if (ed_useNewAssetBrowserTableView) { - m_showColumn.insert(static_cast(AssetBrowserEntry::Column::Path)); + m_showColumn.insert(aznumeric_cast(AssetBrowserEntry::Column::Path)); } m_collator.setNumericMode(true); AssetBrowserComponentNotificationBus::Handler::BusConnect(); @@ -149,19 +147,23 @@ namespace AzToolsFramework m_assetTypeFilter = qobject_cast >(*it); } - it = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filter) -> bool + auto compStringFilterIter = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filter) -> bool { + //The real StringFilter is really a CompositeFilter with just one StringFilter in its subfilter list + //To know if it is actually a StringFilter we have to get that subfilter and check if it is a Stringfilter. auto stringCompositeFilter = qobject_cast >(filter); bool isStringFilter = false; if (stringCompositeFilter) { - auto& subFilters = stringCompositeFilter->GetSubFilters(); - auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filt) -> bool - { + const auto& stringSubfilters = stringCompositeFilter->GetSubFilters(); + auto canBeCasted = [](FilterConstType filt) -> bool { auto strFilter = qobject_cast>(filt); return !strFilter.isNull(); - }); - if (it != subFilters.end()) + }; + auto stringSubfliterConstIter = AZStd::find_if(stringSubfilters.begin(), stringSubfilters.end(), canBeCasted); + + //A Composite StringFilter will only have just one subfilter and nothing more. + if (stringSubfliterConstIter != stringSubfilters.end() && stringSubfilters.size() == 1) { isStringFilter = true; } @@ -169,10 +171,13 @@ namespace AzToolsFramework return isStringFilter; }); - if (it != subFilters.end()) + if (compStringFilterIter != subFilters.end()) { - auto compStringFilter = qobject_cast>(*it); - m_stringFilter = qobject_cast>(compStringFilter->GetSubFilters()[0]); + auto compStringFilter = qobject_cast>(*compStringFilterIter); + if (compStringFilter->GetSubFilters().size() > 0 && compStringFilter->GetSubFilters()[0]) + { + m_stringFilter = qobject_cast>(compStringFilter->GetSubFilters()[0]); + } } } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp index 1101e11f3a..a5cfad09ba 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp @@ -27,8 +27,6 @@ namespace AzToolsFramework { namespace AssetBrowser { - const int AssetBrowserModel::m_column = static_cast(AssetBrowserEntry::Column::DisplayName); - AssetBrowserModel::AssetBrowserModel(QObject* parent) : QAbstractItemModel(parent) , m_rootEntry(nullptr) @@ -143,9 +141,9 @@ namespace AzToolsFramework if (parent.isValid()) { - if ((parent.column() != static_cast(AssetBrowserEntry::Column::DisplayName)) && - (parent.column() != static_cast(AssetBrowserEntry::Column::Name)) && - (parent.column() != static_cast(AssetBrowserEntry::Column::Path))) + if ((parent.column() != aznumeric_cast(AssetBrowserEntry::Column::DisplayName)) && + (parent.column() != aznumeric_cast(AssetBrowserEntry::Column::Name)) && + (parent.column() != aznumeric_cast(AssetBrowserEntry::Column::Path))) { return 0; } @@ -394,7 +392,7 @@ namespace AzToolsFramework } int row = entry->row(); - index = createIndex(row, m_column, entry); + index = createIndex(row, aznumeric_cast(AssetBrowserEntry::Column::DisplayName), entry); return true; } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.h index 9e60c44dae..3c4cae5588 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.h @@ -91,8 +91,6 @@ namespace AzToolsFramework static void SourceIndexesToAssetIds(const QModelIndexList& indexes, AZStd::vector& assetIds); static void SourceIndexesToAssetDatabaseEntries(const QModelIndexList& indexes, AZStd::vector& entries); - const static int m_column; - private: AZStd::shared_ptr m_rootEntry; bool m_loaded; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp index e29607698d..660c04ccd4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp @@ -102,6 +102,7 @@ namespace AzToolsFramework QModelIndexList sourceIndexes; for (const auto& index : selectedIndexes()) { + //If we check for more than one column then the model will try to select the same entry several times. if (index.column() == 0) { sourceIndexes.push_back(m_assetBrowserSortFilterProxyModel->mapToSource(index)); diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index c4a79a9394..412dc61465 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -114,7 +114,6 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) } m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); - //m_ui->m_assetBrowserTreeViewWidget->hideColumn(static_cast(AssetBrowserEntry::Column::Path)); connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), &AssetBrowserFilterModel::filterUpdatedSlot); @@ -232,7 +231,7 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& using namespace AzToolsFramework; using namespace AzToolsFramework::AssetBrowser; // assumption: Double clicking an item selects it before telling us we double clicked it. - auto selectedAssets = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets(); + const auto& selectedAssets = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets(); for (const AssetBrowserEntry* entry : selectedAssets) { AZ::Data::AssetId assetIdToOpen; @@ -269,7 +268,7 @@ void AzAssetBrowserWindow::DoubleClickedItemTableModel([[maybe_unused]] const QM using namespace AzToolsFramework; using namespace AzToolsFramework::AssetBrowser; // assumption: Double clicking an item selects it before telling us we double clicked it. - auto selectedAssets = m_ui->m_assetBrowserTableViewWidget->GetSelectedAssets(); + const auto& selectedAssets = m_ui->m_assetBrowserTableViewWidget->GetSelectedAssets(); for (const AssetBrowserEntry* entry : selectedAssets) { AZ::Data::AssetId assetIdToOpen; From ec784b005ffdd39288097ed17f44612cf00b32a4 Mon Sep 17 00:00:00 2001 From: igarri Date: Tue, 18 May 2021 15:49:35 +0100 Subject: [PATCH 017/244] More Corrections --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 2 +- .../AssetBrowser/AssetBrowserTableModel.cpp | 44 ++++++++++--------- .../AssetBrowser/AssetBrowserTableModel.h | 13 +++++- .../Views/AssetBrowserTableView.cpp | 28 +++++++----- .../Views/AssetBrowserTableView.h | 11 +++++ 5 files changed, 64 insertions(+), 34 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 77e5523ee3..12b0256c5d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -174,7 +174,7 @@ namespace AzToolsFramework if (compStringFilterIter != subFilters.end()) { auto compStringFilter = qobject_cast>(*compStringFilterIter); - if (compStringFilter->GetSubFilters().size() > 0 && compStringFilter->GetSubFilters()[0]) + if (!compStringFilter->GetSubFilters().isEmpty() && compStringFilter->GetSubFilters()[0]) { m_stringFilter = qobject_cast>(compStringFilter->GetSubFilters()[0]); } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index bebdf44c9a..b9bfe1bea6 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -1,3 +1,14 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ #include #include #include @@ -32,24 +43,27 @@ namespace AzToolsFramework { if (role == Qt::DisplayRole && orientation == Qt::Horizontal) { - switch (section) + auto columnRole = aznumeric_cast(role); + switch (columnRole) { - case static_cast(AssetBrowserEntry::Column::Name): + case AssetBrowserEntry::Column::Name: return QString("Name"); - case static_cast(AssetBrowserEntry::Column::Path): + case AssetBrowserEntry::Column::Path: return QString("Path"); default: return QString::number(section); } } - return QSortFilterProxyModel::headerData(section, orientation, role); // QVariant(); + return QSortFilterProxyModel::headerData(section, orientation, role); } QVariant AssetBrowserTableModel::data(const QModelIndex& index, int role) const { auto sourceIndex = mapToSource(index); if (!sourceIndex.isValid()) + { return QVariant(); + } AssetBrowserEntry* entry = GetAssetEntry(sourceIndex); if (entry == nullptr) @@ -66,22 +80,10 @@ namespace AzToolsFramework return parent.isValid() ? QModelIndex() : createIndex(row, column, m_indexMap[row].internalPointer()); } - QModelIndex AssetBrowserTableModel::parent(const QModelIndex& child) const + QModelIndex AssetBrowserTableModel::parent([[maybe_unused]] const QModelIndex& child) const { - AZ_UNUSED(child); return QModelIndex(); } - bool AssetBrowserTableModel::filterAcceptsRow(int source_row, const QModelIndex& source_parent) const - { - AZ_UNUSED(source_row); - AZ_UNUSED(source_parent); - // no filter present, every entry is not visible - if (!m_filterModel->GetFilter()) - { - return true; - } - return true; - } int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const { @@ -94,14 +96,14 @@ namespace AzToolsFramework for (int i = 0; i < rows; ++i) { QModelIndex index = model->index(i, 0, parent); - if (model->hasChildren(index) == false) + if (!model->hasChildren(index)) { beginInsertRows(parent, row, row); m_indexMap[row] = index; endInsertRows(); Q_EMIT dataChanged(index, index); - row = row + 1; + ++row; } if (model->hasChildren(index)) @@ -124,9 +126,9 @@ namespace AzToolsFramework } } void AssetBrowserTableModel::UpdateTableModelMaps() -{ + { emit layoutAboutToBeChanged(); - if (m_indexMap.size() > 0) + if (!m_indexMap.isEmpty()) { beginRemoveRows(m_indexMap.first(), m_indexMap.first().row(), m_indexMap.last().row()); m_indexMap.clear(); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index 432300194b..b0497213a0 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -1,4 +1,16 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ #pragma once + #if !defined(Q_MOC_RUN) #include #include @@ -30,7 +42,6 @@ namespace AzToolsFramework public Q_SLOTS: void UpdateTableModelMaps(); protected: - bool filterAcceptsRow(int source_row, const QModelIndex& source_parent) const override; int rowCount(const QModelIndex& parent = QModelIndex()) const override; QVariant headerData(int section, Qt::Orientation orientation, int role /* = Qt::DisplayRole */) const override; //////////////////////////////////////////////////////////////////// diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index cb4a989043..df3b0b8644 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -1,3 +1,15 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ + #include #include @@ -109,21 +121,16 @@ namespace AzToolsFramework } QTableView::rowsAboutToBeRemoved(parent, start, end); } - void AssetBrowserTableView::layoutChangedSlot(const QList& parents, QAbstractItemModel::LayoutChangeHint hint) + void AssetBrowserTableView::layoutChangedSlot([[maybe_unused]] const QList& parents,[[maybe_unused]] QAbstractItemModel::LayoutChangeHint hint) { - AZ_UNUSED(parents); - AZ_UNUSED(hint); - scrollToTop(); } - void AssetBrowserTableView::SelectProduct(AZ::Data::AssetId assetID) + void AssetBrowserTableView::SelectProduct([[maybe_unused]] AZ::Data::AssetId assetID) { - AZ_UNUSED(assetID); } - void AssetBrowserTableView::SelectFileAtPath(const AZStd::string& assetPath) + void AssetBrowserTableView::SelectFileAtPath([[maybe_unused]] const AZStd::string& assetPath) { - AZ_UNUSED(assetPath); } void AssetBrowserTableView::ClearFilter() @@ -142,11 +149,10 @@ namespace AzToolsFramework { } - void AssetBrowserTableView::OnContextMenu(const QPoint& point) + void AssetBrowserTableView::OnContextMenu([[maybe_unused]] const QPoint& point) { - AZ_UNUSED(point); - auto selectedAssets = GetSelectedAssets(); + const auto& selectedAssets = GetSelectedAssets(); if (selectedAssets.size() != 1) { return; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index b39d48c391..482a072373 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -1,3 +1,14 @@ +/* + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ #pragma once #if !defined(Q_MOC_RUN) #include From 0b50b6cc63842c7537ff43609a039e39295f1a5d Mon Sep 17 00:00:00 2001 From: igarri Date: Wed, 19 May 2021 12:04:40 +0100 Subject: [PATCH 018/244] Fixed code Style and minor issues from feedback --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 1 - .../AssetBrowser/AssetBrowserTableModel.cpp | 13 ++++++++----- .../AssetBrowser/Views/AssetBrowserTableView.cpp | 8 ++++++++ .../AssetBrowser/Views/EntryDelegate.cpp | 6 +++--- .../Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp | 4 ++++ 5 files changed, 23 insertions(+), 9 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 12b0256c5d..c5723832c7 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -184,7 +184,6 @@ namespace AzToolsFramework invalidateFilter(); Q_EMIT filterChanged(); emit stringFilterPopulated(!m_stringFilter.isNull()); - } void AssetBrowserFilterModel::filterUpdatedSlot() diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index b9bfe1bea6..6d9803dfd4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -22,10 +22,11 @@ namespace AzToolsFramework { setDynamicSortFilter(false); } + void AssetBrowserTableModel::setSourceModel(QAbstractItemModel* sourceModel) { m_filterModel = qobject_cast(sourceModel); - AZ_Assert(m_filterModel, "Expecting AssetBrowserFilterModel"); + AZ_Assert(m_filterModel, "Error in AssetBrowserTableModel initialization, class expects source model to be an AssetBrowserFilterModel."); QSortFilterProxyModel::setSourceModel(sourceModel); } @@ -47,9 +48,9 @@ namespace AzToolsFramework switch (columnRole) { case AssetBrowserEntry::Column::Name: - return QString("Name"); + return tr("Name"); case AssetBrowserEntry::Column::Path: - return QString("Path"); + return tr("Path"); default: return QString::number(section); } @@ -68,8 +69,8 @@ namespace AzToolsFramework AssetBrowserEntry* entry = GetAssetEntry(sourceIndex); if (entry == nullptr) { - AZ_Assert(false, "ERROR - index internal pointer not pointing to an AssetEntry. Tree provided by the AssetBrowser invalid?"); - return Qt::PartiallyChecked; + AZ_Assert(false, "AssetBrowserTableModel - QModelIndex does not reference an AssetEntry. Source model is not valid."); + return QVariant(); } return sourceIndex.data(role); @@ -113,6 +114,7 @@ namespace AzToolsFramework } return row; } + AssetBrowserEntry* AssetBrowserTableModel::GetAssetEntry(QModelIndex index) const { if (index.isValid()) @@ -125,6 +127,7 @@ namespace AzToolsFramework return nullptr; } } + void AssetBrowserTableModel::UpdateTableModelMaps() { emit layoutAboutToBeChanged(); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index df3b0b8644..f7128cb504 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -60,11 +60,13 @@ namespace AzToolsFramework AssetBrowserViewRequestBus::Handler::BusConnect(); AssetBrowserComponentNotificationBus::Handler::BusConnect(); } + AssetBrowserTableView::~AssetBrowserTableView() { AssetBrowserViewRequestBus::Handler::BusDisconnect(); AssetBrowserComponentNotificationBus::Handler::BusDisconnect(); } + void AssetBrowserTableView::setModel(QAbstractItemModel* model) { m_tableModel = qobject_cast(model); @@ -76,6 +78,7 @@ namespace AzToolsFramework horizontalHeader()->setSectionResizeMode(0, QHeaderView::ResizeMode::Stretch); horizontalHeader()->setSectionResizeMode(1, QHeaderView::ResizeMode::Stretch); } + void AssetBrowserTableView::SetName(const QString& name) { m_name = name; @@ -86,6 +89,7 @@ namespace AzToolsFramework OnAssetBrowserComponentReady(); } } + AZStd::vector AssetBrowserTableView::GetSelectedAssets() const { QModelIndexList sourceIndexes; @@ -101,11 +105,13 @@ namespace AzToolsFramework AssetBrowserModel::SourceIndexesToAssetDatabaseEntries(sourceIndexes, entries); return entries; } + void AssetBrowserTableView::selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) { QTableView::selectionChanged(selected, deselected); Q_EMIT selectionChangedSignal(selected, deselected); } + void AssetBrowserTableView::rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) { // if selected entry is being removed, clear selection so not to select (and attempt to preview) other entries potentially @@ -121,10 +127,12 @@ namespace AzToolsFramework } QTableView::rowsAboutToBeRemoved(parent, start, end); } + void AssetBrowserTableView::layoutChangedSlot([[maybe_unused]] const QList& parents,[[maybe_unused]] QAbstractItemModel::LayoutChangeHint hint) { scrollToTop(); } + void AssetBrowserTableView::SelectProduct([[maybe_unused]] AZ::Data::AssetId assetID) { } diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp index b968f0480a..dff8a170c7 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp @@ -99,9 +99,9 @@ namespace AzToolsFramework style->drawItemText( painter, remainingRect, option.displayAlignment, actualPalette, isEnabled, - index.column() == static_cast(AssetBrowserEntry::Column::Name) - ? qvariant_cast(entry->data(static_cast(AssetBrowserEntry::Column::Name))) - : qvariant_cast(entry->data(static_cast(AssetBrowserEntry::Column::Path))), + index.column() == aznumeric_cast(AssetBrowserEntry::Column::Name) + ? qvariant_cast(entry->data(aznumeric_cast(AssetBrowserEntry::Column::Name))) + : qvariant_cast(entry->data(aznumeric_cast(AssetBrowserEntry::Column::Path))), isSelected ? QPalette::HighlightedText : QPalette::Text); } } diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 412dc61465..35734042a0 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -312,9 +312,13 @@ void AzAssetBrowserWindow::LockToDefaultView(bool state) using namespace AzToolsFramework::AssetBrowser; SwitchDisplayView(!state); if (state == true) + { disconnect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); + } else + { connect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); + } } #include From dfb0d7f9f567ec0d1d8cfa449b5619190296c231 Mon Sep 17 00:00:00 2001 From: igarri Date: Fri, 21 May 2021 12:33:55 +0100 Subject: [PATCH 019/244] Fixed numeric_cast, style, const variables --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 17 +++++++++-------- .../AssetBrowser/AssetBrowserFilterModel.h | 2 +- .../AssetBrowser/AssetBrowserModel.cpp | 2 +- .../AssetBrowser/AssetBrowserTableModel.cpp | 5 ----- .../AssetBrowser/AssetBrowserTableModel.h | 1 - .../AssetBrowser/Views/AssetBrowserTableView.h | 3 ++- .../AssetBrowser/Views/AssetBrowserTreeView.cpp | 2 +- .../AssetBrowser/Views/EntryDelegate.cpp | 2 +- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 4 ---- 9 files changed, 15 insertions(+), 23 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index c5723832c7..7c7f2aa601 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -135,28 +135,29 @@ namespace AzToolsFramework auto compFilter = qobject_cast >(m_filter); if (compFilter) { - auto& subFilters = compFilter->GetSubFilters(); + const auto& subFilters = compFilter->GetSubFilters(); - auto it = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool + auto compositeFilterIterator = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { - auto assetTypeFilter = qobject_cast >(filter); + const auto assetTypeFilter = qobject_cast >(filter); return !assetTypeFilter.isNull(); }); - if (it != subFilters.end()) + if (compositeFilterIterator != subFilters.end()) { - m_assetTypeFilter = qobject_cast >(*it); + m_assetTypeFilter = qobject_cast >(*compositeFilterIterator); } auto compStringFilterIter = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filter) -> bool { //The real StringFilter is really a CompositeFilter with just one StringFilter in its subfilter list //To know if it is actually a StringFilter we have to get that subfilter and check if it is a Stringfilter. - auto stringCompositeFilter = qobject_cast >(filter); + const auto stringCompositeFilter = qobject_cast >(filter); bool isStringFilter = false; if (stringCompositeFilter) { const auto& stringSubfilters = stringCompositeFilter->GetSubFilters(); - auto canBeCasted = [](FilterConstType filt) -> bool { + auto canBeCasted = [](FilterConstType filt) -> bool + { auto strFilter = qobject_cast>(filt); return !strFilter.isNull(); }; @@ -173,7 +174,7 @@ namespace AzToolsFramework }); if (compStringFilterIter != subFilters.end()) { - auto compStringFilter = qobject_cast>(*compStringFilterIter); + const auto compStringFilter = qobject_cast>(*compStringFilterIter); if (!compStringFilter->GetSubFilters().isEmpty() && compStringFilter->GetSubFilters()[0]) { m_stringFilter = qobject_cast>(compStringFilter->GetSubFilters()[0]); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h index 7a6faf9f18..5d22791699 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.h @@ -68,7 +68,7 @@ namespace AzToolsFramework protected: //set for filtering columns //if the column is in the set the column is not filtered and is shown - AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn; + AZStd::fixed_unordered_set(AssetBrowserEntry::Column::Count)> m_showColumn; bool m_alreadyRecomputingFilters = false; //asset source name match filter FilterConstType m_filter; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp index a5cfad09ba..c0f78baccb 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserModel.cpp @@ -163,7 +163,7 @@ namespace AzToolsFramework int AssetBrowserModel::columnCount(const QModelIndex& /*parent*/) const { - return static_cast(AssetBrowserEntry::Column::Count); + return aznumeric_cast(AssetBrowserEntry::Column::Count); } QVariant AssetBrowserModel::data(const QModelIndex& index, int role) const diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index 6d9803dfd4..40f8318a2d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -81,11 +81,6 @@ namespace AzToolsFramework return parent.isValid() ? QModelIndex() : createIndex(row, column, m_indexMap[row].internalPointer()); } - QModelIndex AssetBrowserTableModel::parent([[maybe_unused]] const QModelIndex& child) const - { - return QModelIndex(); - } - int AssetBrowserTableModel::rowCount(const QModelIndex& parent) const { return !parent.isValid() ? m_indexMap.size() : 0; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h index b0497213a0..6b64ceaf92 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.h @@ -36,7 +36,6 @@ namespace AzToolsFramework // QSortFilterProxyModel void setSourceModel(QAbstractItemModel* sourceModel) override; QModelIndex mapToSource(const QModelIndex& proxyIndex) const override; - QModelIndex parent(const QModelIndex& child) const override; QModelIndex index(int row, int column, const QModelIndex& parent = QModelIndex()) const override; QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const override; public Q_SLOTS: diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index 482a072373..65f97d1a6d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -68,7 +68,8 @@ namespace AzToolsFramework protected Q_SLOTS: void selectionChanged(const QItemSelection& selected, const QItemSelection& deselected) override; void rowsAboutToBeRemoved(const QModelIndex& parent, int start, int end) override; - void layoutChangedSlot(const QList &parents = QList(), QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint); + void layoutChangedSlot(const QList &parents = QList(), + QAbstractItemModel::LayoutChangeHint hint = QAbstractItemModel::NoLayoutChangeHint); private: QString m_name; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp index 660c04ccd4..b93caf85f7 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp @@ -176,7 +176,7 @@ namespace AzToolsFramework void AssetBrowserTreeView::OnAssetBrowserComponentReady() { - hideColumn(static_cast(AssetBrowserEntry::Column::Path)); + hideColumn(aznumeric_cast(AssetBrowserEntry::Column::Path)); if (!m_name.isEmpty()) { auto crc = AZ::Crc32(m_name.toUtf8().data()); diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp index dff8a170c7..c73c00981b 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp @@ -75,7 +75,7 @@ namespace AzToolsFramework auto sourceEntry = azrtti_cast(entry); QPalette actualPalette(option.palette); - if (index.column() == static_cast(AssetBrowserEntry::Column::Name)) + if (index.column() == aznumeric_cast(AssetBrowserEntry::Column::Name)) { int thumbX = DrawThumbnail(painter, iconTopLeft, iconSize, entry->GetThumbnailKey()); if (sourceEntry) diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 35734042a0..1b123dd000 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -110,7 +110,6 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) connect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); connect(m_ui->m_viewSwitcherCheckBox, &QCheckBox::stateChanged, this, &AzAssetBrowserWindow::LockToDefaultView); - } m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); @@ -124,17 +123,14 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_ui->m_assetBrowserTreeViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex); }); - connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); connect(m_ui->m_assetBrowserTreeViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); - connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, &SearchWidget::ClearStringFilter); connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); - m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main"); } From 6a0cf974560d5d617d601cc9c765d7de022be1ea Mon Sep 17 00:00:00 2001 From: igarri Date: Mon, 24 May 2021 13:19:35 +0100 Subject: [PATCH 020/244] Fixed Selection in AssetBrowserTreeView --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 5 +++-- .../AssetBrowser/Views/AssetBrowserTreeView.cpp | 4 +++- Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp | 5 ++--- .../Code/Editor/Model/UnitTestBrowserFilterModel.cpp | 2 +- 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 7c7f2aa601..fc2fc41656 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -23,8 +23,9 @@ AZ_PUSH_DISABLE_WARNING(4251, "-Wunknown-warning-option") #include AZ_POP_DISABLE_WARNING -AZ_CVAR_EXTERNED(bool, ed_useNewAssetBrowserTableView); - +AZ_CVAR( + bool, ed_useNewAssetBrowserTableView, false, nullptr, AZ::ConsoleFunctorFlags::Null, + "Use the new AssetBrowser TableView for searching assets."); namespace AzToolsFramework { namespace AssetBrowser diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp index b93caf85f7..52c785d678 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTreeView.cpp @@ -99,8 +99,10 @@ namespace AzToolsFramework AZStd::vector AssetBrowserTreeView::GetSelectedAssets() const { + + const QModelIndexList& selectedIndexes = selectionModel()->selectedRows(); QModelIndexList sourceIndexes; - for (const auto& index : selectedIndexes()) + for (const auto& index : selectedIndexes) { //If we check for more than one column then the model will try to select the same entry several times. if (index.column() == 0) diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 1b123dd000..e722d6d03e 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -33,9 +33,8 @@ AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING #include AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING -AZ_CVAR( - bool, ed_useNewAssetBrowserTableView, false, nullptr, AZ::ConsoleFunctorFlags::Null, - "Use the new AssetBrowser TableView for searching assets."); +AZ_CVAR_EXTERNED(bool, ed_useNewAssetBrowserTableView); + class ListenerForShowAssetEditorEvent : public QObject diff --git a/Gems/ScriptCanvas/Code/Editor/Model/UnitTestBrowserFilterModel.cpp b/Gems/ScriptCanvas/Code/Editor/Model/UnitTestBrowserFilterModel.cpp index 665c81fa57..1a4d95c585 100644 --- a/Gems/ScriptCanvas/Code/Editor/Model/UnitTestBrowserFilterModel.cpp +++ b/Gems/ScriptCanvas/Code/Editor/Model/UnitTestBrowserFilterModel.cpp @@ -34,7 +34,7 @@ namespace ScriptCanvasEditor { setDynamicSortFilter(true); - m_showColumn.insert(AssetBrowserModel::m_column); + m_showColumn.insert(aznumeric_cast(AssetBrowserEntry::Column::DisplayName)); UnitTestWidgetNotificationBus::Handler::BusConnect(); From 6ca37bbf84e14118ccb1000ea51eed2d887a3473 Mon Sep 17 00:00:00 2001 From: igarri Date: Thu, 27 May 2021 14:04:02 +0100 Subject: [PATCH 021/244] Checking variable constness --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index fc2fc41656..2660b660e4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -26,6 +26,7 @@ AZ_POP_DISABLE_WARNING AZ_CVAR( bool, ed_useNewAssetBrowserTableView, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Use the new AssetBrowser TableView for searching assets."); +#pragma optimize("", off) namespace AzToolsFramework { namespace AssetBrowser @@ -138,17 +139,18 @@ namespace AzToolsFramework { const auto& subFilters = compFilter->GetSubFilters(); - auto compositeFilterIterator = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool + const auto compositeFilterIterator = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool { const auto assetTypeFilter = qobject_cast >(filter); return !assetTypeFilter.isNull(); }); + if (compositeFilterIterator != subFilters.end()) { m_assetTypeFilter = qobject_cast >(*compositeFilterIterator); } - auto compStringFilterIter = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filter) -> bool + const auto compStringFilterIter = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filter) -> bool { //The real StringFilter is really a CompositeFilter with just one StringFilter in its subfilter list //To know if it is actually a StringFilter we have to get that subfilter and check if it is a Stringfilter. @@ -162,7 +164,7 @@ namespace AzToolsFramework auto strFilter = qobject_cast>(filt); return !strFilter.isNull(); }; - auto stringSubfliterConstIter = AZStd::find_if(stringSubfilters.begin(), stringSubfilters.end(), canBeCasted); + const auto stringSubfliterConstIter = AZStd::find_if(stringSubfilters.begin(), stringSubfilters.end(), canBeCasted); //A Composite StringFilter will only have just one subfilter and nothing more. if (stringSubfliterConstIter != stringSubfilters.end() && stringSubfilters.size() == 1) @@ -176,6 +178,7 @@ namespace AzToolsFramework if (compStringFilterIter != subFilters.end()) { const auto compStringFilter = qobject_cast>(*compStringFilterIter); + if (!compStringFilter->GetSubFilters().isEmpty() && compStringFilter->GetSubFilters()[0]) { m_stringFilter = qobject_cast>(compStringFilter->GetSubFilters()[0]); @@ -185,7 +188,8 @@ namespace AzToolsFramework } invalidateFilter(); Q_EMIT filterChanged(); - emit stringFilterPopulated(!m_stringFilter.isNull()); + bool isNullAB = m_stringFilter.isNull(); + emit stringFilterPopulated(!isNullAB); } void AssetBrowserFilterModel::filterUpdatedSlot() @@ -205,5 +209,6 @@ namespace AzToolsFramework } // namespace AssetBrowser } // namespace AzToolsFramework// namespace AssetBrowser +#pragma optimize("", on) #include "AssetBrowser/moc_AssetBrowserFilterModel.cpp" From 00a529ad74d139419ea2e4f331b21509a01dcf85 Mon Sep 17 00:00:00 2001 From: amzn-mike <80125227+amzn-mike@users.noreply.github.com> Date: Fri, 28 May 2021 14:56:52 -0500 Subject: [PATCH 022/244] Fix AssImpTransformImporter logic for bone nodes For bone nodes, the Transform is computed by multiplying the parent offsetMatrix by the inverse of the node's offsetMatrix Note that this currently disables the LimitBoneWeights option since that results in the removal of bone nodes that are not attached to a mesh. Without the bones there is no way to retrieve the offsetMatrix, so the Transform cannot be computed correctly Fixes LYN-3755 --- .../Importers/AssImpTransformImporter.cpp | 59 ++++++++++++++++--- .../SDKWrapper/AssImpSceneWrapper.cpp | 5 +- 2 files changed, 55 insertions(+), 9 deletions(-) diff --git a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTransformImporter.cpp b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTransformImporter.cpp index 5357c32fa9..bcc007e3a7 100644 --- a/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTransformImporter.cpp +++ b/Code/Tools/SceneAPI/FbxSceneBuilder/Importers/AssImpTransformImporter.cpp @@ -46,22 +46,69 @@ namespace AZ serializeContext->Class()->Version(1); } } - + + void GetAllBones(const aiScene* scene, AZStd::unordered_map& boneLookup) + { + for (unsigned meshIndex = 0; meshIndex < scene->mNumMeshes; ++meshIndex) + { + const aiMesh* mesh = scene->mMeshes[meshIndex]; + + for (unsigned boneIndex = 0; boneIndex < mesh->mNumBones; ++boneIndex) + { + const aiBone* bone = mesh->mBones[boneIndex]; + + boneLookup[bone->mName.C_Str()] = bone; + } + } + } + Events::ProcessingResult AssImpTransformImporter::ImportTransform(AssImpSceneNodeAppendedContext& context) { AZ_TraceContext("Importer", "transform"); const aiNode* currentNode = context.m_sourceNode.GetAssImpNode(); const aiScene* scene = context.m_sourceScene.GetAssImpScene(); - + if (currentNode == scene->mRootNode || IsPivotNode(currentNode->mName)) { return Events::ProcessingResult::Ignored; } - aiMatrix4x4 combinedTransform = GetConcatenatedLocalTransform(currentNode); + AZStd::unordered_map boneLookup; + GetAllBones(scene, boneLookup); + + auto boneIterator = boneLookup.find(currentNode->mName.C_Str()); + const bool isBone = boneIterator != boneLookup.end(); + + aiMatrix4x4 combinedTransform; + + if (isBone) + { + auto parentNode = currentNode->mParent; + + aiMatrix4x4 offsetMatrix = boneIterator->second->mOffsetMatrix; + aiMatrix4x4 parentOffset {}; + + auto parentBoneIterator = boneLookup.find(parentNode->mName.C_Str()); + + if (parentNode && parentBoneIterator != boneLookup.end()) + { + const auto& parentBone = parentBoneIterator->second; + + parentOffset = parentBone->mOffsetMatrix; + } + + auto inverseOffset = offsetMatrix; + inverseOffset.Inverse(); + + combinedTransform = parentOffset * inverseOffset; + } + else + { + combinedTransform = GetConcatenatedLocalTransform(currentNode); + } DataTypes::MatrixType localTransform = AssImpSDKWrapper::AssImpTypeConverter::ToTransform(combinedTransform); - + context.m_sourceSceneSystem.SwapTransformForUpAxis(localTransform); context.m_sourceSceneSystem.ConvertUnit(localTransform); @@ -105,9 +152,7 @@ namespace AZ } else { - bool addedData = context.m_scene.GetGraph().SetContent( - context.m_currentGraphPosition, - transformData); + bool addedData = context.m_scene.GetGraph().SetContent(context.m_currentGraphPosition, transformData); AZ_Error(SceneAPI::Utilities::ErrorWindow, addedData, "Failed to add node data"); return addedData ? Events::ProcessingResult::Success : Events::ProcessingResult::Failure; diff --git a/Code/Tools/SceneAPI/SDKWrapper/AssImpSceneWrapper.cpp b/Code/Tools/SceneAPI/SDKWrapper/AssImpSceneWrapper.cpp index 791af4bf68..9186a2fb7a 100644 --- a/Code/Tools/SceneAPI/SDKWrapper/AssImpSceneWrapper.cpp +++ b/Code/Tools/SceneAPI/SDKWrapper/AssImpSceneWrapper.cpp @@ -69,13 +69,14 @@ namespace AZ // aiProcess_JoinIdenticalVertices is not enabled because O3DE has a mesh optimizer that also does this, // this flag is disabled to keep AssImp output similar to FBX SDK to reduce downstream bugs for the initial AssImp release. // There's currently a minimum of properties and flags set to maximize compatibility with the existing node graph. + + // aiProcess_LimitBoneWeights is not enabled because it will remove bones which are not associated with a mesh. + // This results in the loss of the offset matrix data for nodes without a mesh which is required for the Transform Importer. m_importer.SetPropertyBool(AI_CONFIG_IMPORT_FBX_PRESERVE_PIVOTS, false); m_importer.SetPropertyBool(AI_CONFIG_IMPORT_FBX_OPTIMIZE_EMPTY_ANIMATION_CURVES, false); m_sceneFileName = fileName; m_assImpScene = m_importer.ReadFile(fileName, aiProcess_Triangulate //Triangulates all faces of all meshes - | aiProcess_LimitBoneWeights //Limits the number of bones that can affect a vertex to a maximum value - //dropping the least important and re-normalizing | aiProcess_GenNormals); //Generate normals for meshes #if AZ_TRAIT_COMPILER_SUPPORT_CSIGNAL From 0d5247be345493fb699e54dc0eaad41af35fa87b Mon Sep 17 00:00:00 2001 From: moudgils Date: Tue, 1 Jun 2021 09:58:45 -0700 Subject: [PATCH 023/244] Fix metal shader pipeline crashes for LuminanceHistogramGenerator and MorphTargetCS due to the use of atomic operations with typed buffers. Switching them to use Structured buffers. Plus misc cleanup --- .../Common/Assets/Shaders/MorphTargets/MorphTargetCS.shader | 4 +--- .../Common/Assets/Shaders/MorphTargets/MorphTargetSRG.azsli | 2 +- .../Assets/Shaders/PostProcessing/LuminanceHeatmap.azsl | 4 ++-- .../Shaders/PostProcessing/LuminanceHistogramGenerator.azsl | 2 +- .../PostProcessing/LuminanceHistogramGenerator.shader | 4 +--- .../Assets/Shaders/SkinnedMesh/LinearSkinningPassSRG.azsli | 2 +- .../PostProcessing/LuminanceHistogramGeneratorPass.cpp | 2 +- .../Source/SkinnedMesh/SkinnedMeshOutputStreamManager.cpp | 4 ++-- .../RHI/Code/Include/Atom/RHI/ShaderResourceGroupData.h | 1 - Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h | 6 ++++++ 10 files changed, 16 insertions(+), 15 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetCS.shader b/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetCS.shader index 95ffc36a11..08b1e7c298 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetCS.shader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetCS.shader @@ -10,7 +10,5 @@ "type": "Compute" } ] - }, - "DisabledRHIBackends": ["metal"] - + } } diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetSRG.azsli b/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetSRG.azsli index 7ec5b43368..171e803c2c 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetSRG.azsli +++ b/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetSRG.azsli @@ -16,7 +16,7 @@ ShaderResourceGroup MorphTargetPassSrg : SRG_PerPass { - RWBuffer m_accumulatedDeltas; + RWStruturedBuffer m_accumulatedDeltas; } // This class represents the data that is passed to the morph target compute shader of an individual delta diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHeatmap.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHeatmap.azsl index df92e36f9a..4559b6c9ef 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHeatmap.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHeatmap.azsl @@ -1,4 +1,4 @@ -/* + /* * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or * its licensors. * @@ -37,7 +37,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass Texture2D m_sceneLuminance; // This should be of size NUM_HISTOGRAM_BINS. - Buffer m_histogram; + StructuredBuffer m_histogram; Sampler LinearSampler { diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHistogramGenerator.azsl b/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHistogramGenerator.azsl index 05cc870eea..9d01a12fd6 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHistogramGenerator.azsl +++ b/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHistogramGenerator.azsl @@ -20,7 +20,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass { Texture2D m_inputTexture; - RWBuffer m_outputTexture; + RWStructuredBuffer m_outputTexture; } groupshared uint shared_histogramBins[NUM_HISTOGRAM_BINS]; diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHistogramGenerator.shader b/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHistogramGenerator.shader index 566144bab8..f3dd11e11a 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHistogramGenerator.shader +++ b/Gems/Atom/Feature/Common/Assets/Shaders/PostProcessing/LuminanceHistogramGenerator.shader @@ -12,7 +12,5 @@ "type": "Compute" } ] - }, - "DisabledRHIBackends": ["metal"] - + } } diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/SkinnedMesh/LinearSkinningPassSRG.azsli b/Gems/Atom/Feature/Common/Assets/Shaders/SkinnedMesh/LinearSkinningPassSRG.azsli index 5a9e44bade..e5407d2d9e 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/SkinnedMesh/LinearSkinningPassSRG.azsli +++ b/Gems/Atom/Feature/Common/Assets/Shaders/SkinnedMesh/LinearSkinningPassSRG.azsli @@ -16,7 +16,7 @@ ShaderResourceGroup PassSrg : SRG_PerPass { - RWBuffer m_skinnedMeshOutputStream; + RWStructuredBuffer m_skinnedMeshOutputStream; } ShaderResourceGroup InstanceSrg : SRG_PerDraw diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp index 758c21bc4e..a3c494dee9 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp @@ -72,7 +72,7 @@ namespace AZ desc.m_bufferName = AZStd::string::format("LuminanceHistogramBuffer_%s", uuidString.c_str()); desc.m_elementSize = sizeof(uint32_t); desc.m_byteCount = NumHistogramBins * sizeof(uint32_t); - desc.m_elementFormat = RHI::Format::R32_UINT; + desc.m_elementFormat = RHI::Format::Unknown; m_histogram = RPI::BufferSystemInterface::Get()->CreateBufferFromCommonPool(desc); AZ_Assert(m_histogram != nullptr, "Unable to allocate buffer"); } diff --git a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshOutputStreamManager.cpp b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshOutputStreamManager.cpp index 1cb782d8b1..1b14611e84 100644 --- a/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshOutputStreamManager.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/SkinnedMesh/SkinnedMeshOutputStreamManager.cpp @@ -67,8 +67,8 @@ namespace AZ creator.SetBuffer(nullptr, 0, bufferDescriptor); RHI::BufferViewDescriptor viewDescriptor; - viewDescriptor.m_elementFormat = RHI::Format::R32_FLOAT; - viewDescriptor.m_elementSize = RHI::GetFormatSize(viewDescriptor.m_elementFormat); + viewDescriptor.m_elementFormat = RHI::Format::Unknown; + viewDescriptor.m_elementSize = sizeof(float); viewDescriptor.m_elementCount = aznumeric_cast(m_sizeInBytes) / viewDescriptor.m_elementSize; viewDescriptor.m_elementOffset = 0; creator.SetBufferViewDescriptor(viewDescriptor); diff --git a/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupData.h b/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupData.h index ce2c6c77ec..afcab28a1d 100644 --- a/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupData.h +++ b/Gems/Atom/RHI/Code/Include/Atom/RHI/ShaderResourceGroupData.h @@ -410,7 +410,6 @@ namespace AZ // For any other type the buffer view's element size should match the stride. if (shaderInputBuffer.m_strideSize != bufferViewDescriptor.m_elementSize) { - // [GFX TODO][ATOM-5735][AZSL] ByteAddressBuffer shader input is setting a stride of 16 instead of 4 AZ_Error("ShaderResourceGroupData", false, "Buffer Input '%s[%d]': Does not match expected stride size %d", shaderInputBuffer.m_name.GetCStr(), arrayIndex, bufferViewDescriptor.m_elementSize); return false; diff --git a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h index a6fe57f6d8..6f09ea1d5f 100644 --- a/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h +++ b/Gems/Atom/RHI/DX12/Code/Source/RHI/CommandList.h @@ -271,6 +271,12 @@ namespace AZ ShaderResourceBindings& bindings = GetShaderResourceBindingsByPipelineType(pipelineType); const PipelineState* pipelineState = static_cast(item.m_pipelineState); + if(!pipelineState) + { + AZ_Assert(false, "Pipeline state not provided"); + return false; + } + bool updatePipelineState = m_state.m_pipelineState != pipelineState; // The pipeline state gets set first. if (updatePipelineState) From 485a45d3c2a12bd7194210939ca75a58f9640bd2 Mon Sep 17 00:00:00 2001 From: igarri Date: Wed, 2 Jun 2021 15:32:03 +0100 Subject: [PATCH 024/244] Made some corrections --- .../AssetBrowser/AssetBrowserFilterModel.cpp | 11 +-- .../AssetBrowser/AssetBrowserTableModel.cpp | 10 ++- .../Views/AssetBrowserTableView.cpp | 9 +- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 83 ++++++++++--------- 4 files changed, 60 insertions(+), 53 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp index 2660b660e4..adb4ae66c4 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserFilterModel.cpp @@ -26,7 +26,6 @@ AZ_POP_DISABLE_WARNING AZ_CVAR( bool, ed_useNewAssetBrowserTableView, false, nullptr, AZ::ConsoleFunctorFlags::Null, "Use the new AssetBrowser TableView for searching assets."); -#pragma optimize("", off) namespace AzToolsFramework { namespace AssetBrowser @@ -139,7 +138,7 @@ namespace AzToolsFramework { const auto& subFilters = compFilter->GetSubFilters(); - const auto compositeFilterIterator = AZStd::find_if(subFilters.begin(), subFilters.end(), [subFilters](FilterConstType filter) -> bool + const auto compositeFilterIterator = AZStd::find_if(subFilters.cbegin(), subFilters.cend(), [subFilters](FilterConstType filter) -> bool { const auto assetTypeFilter = qobject_cast >(filter); return !assetTypeFilter.isNull(); @@ -150,7 +149,7 @@ namespace AzToolsFramework m_assetTypeFilter = qobject_cast >(*compositeFilterIterator); } - const auto compStringFilterIter = AZStd::find_if(subFilters.begin(), subFilters.end(), [](FilterConstType filter) -> bool + const auto compStringFilterIter = AZStd::find_if(subFilters.cbegin(), subFilters.cend(), [](FilterConstType filter) -> bool { //The real StringFilter is really a CompositeFilter with just one StringFilter in its subfilter list //To know if it is actually a StringFilter we have to get that subfilter and check if it is a Stringfilter. @@ -164,7 +163,7 @@ namespace AzToolsFramework auto strFilter = qobject_cast>(filt); return !strFilter.isNull(); }; - const auto stringSubfliterConstIter = AZStd::find_if(stringSubfilters.begin(), stringSubfilters.end(), canBeCasted); + const auto stringSubfliterConstIter = AZStd::find_if(stringSubfilters.cbegin(), stringSubfilters.cend(), canBeCasted); //A Composite StringFilter will only have just one subfilter and nothing more. if (stringSubfliterConstIter != stringSubfilters.end() && stringSubfilters.size() == 1) @@ -188,8 +187,7 @@ namespace AzToolsFramework } invalidateFilter(); Q_EMIT filterChanged(); - bool isNullAB = m_stringFilter.isNull(); - emit stringFilterPopulated(!isNullAB); + emit stringFilterPopulated(!m_stringFilter.isNull()); } void AssetBrowserFilterModel::filterUpdatedSlot() @@ -209,6 +207,5 @@ namespace AzToolsFramework } // namespace AssetBrowser } // namespace AzToolsFramework// namespace AssetBrowser -#pragma optimize("", on) #include "AssetBrowser/moc_AssetBrowserFilterModel.cpp" diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp index 40f8318a2d..70d66f4e1f 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/AssetBrowserTableModel.cpp @@ -9,8 +9,8 @@ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * */ -#include #include +#include #include namespace AzToolsFramework @@ -26,7 +26,9 @@ namespace AzToolsFramework void AssetBrowserTableModel::setSourceModel(QAbstractItemModel* sourceModel) { m_filterModel = qobject_cast(sourceModel); - AZ_Assert(m_filterModel, "Error in AssetBrowserTableModel initialization, class expects source model to be an AssetBrowserFilterModel."); + AZ_Assert( + m_filterModel, + "Error in AssetBrowserTableModel initialization, class expects source model to be an AssetBrowserFilterModel."); QSortFilterProxyModel::setSourceModel(sourceModel); } @@ -86,7 +88,8 @@ namespace AzToolsFramework return !parent.isValid() ? m_indexMap.size() : 0; } - int AssetBrowserTableModel::BuildTableModelMap(const QAbstractItemModel* model, const QModelIndex& parent /*= QModelIndex()*/, int row /*= 0*/) + int AssetBrowserTableModel::BuildTableModelMap( + const QAbstractItemModel* model, const QModelIndex& parent /*= QModelIndex()*/, int row /*= 0*/) { int rows = model ? model->rowCount(parent) : 0; for (int i = 0; i < rows; ++i) @@ -134,7 +137,6 @@ namespace AzToolsFramework } BuildTableModelMap(sourceModel()); emit layoutChanged(); - } } // namespace AssetBrowser } // namespace AzToolsFramework diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp index f7128cb504..894bbd8700 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.cpp @@ -37,7 +37,6 @@ AZ_PUSH_DISABLE_WARNING( #include #include AZ_POP_DISABLE_WARNING -#pragma optimize("", off) namespace AzToolsFramework { namespace AssetBrowser @@ -128,7 +127,8 @@ namespace AzToolsFramework QTableView::rowsAboutToBeRemoved(parent, start, end); } - void AssetBrowserTableView::layoutChangedSlot([[maybe_unused]] const QList& parents,[[maybe_unused]] QAbstractItemModel::LayoutChangeHint hint) + void AssetBrowserTableView::layoutChangedSlot( + [[maybe_unused]] const QList& parents, [[maybe_unused]] QAbstractItemModel::LayoutChangeHint hint) { scrollToTop(); } @@ -159,7 +159,6 @@ namespace AzToolsFramework void AssetBrowserTableView::OnContextMenu([[maybe_unused]] const QPoint& point) { - const auto& selectedAssets = GetSelectedAssets(); if (selectedAssets.size() != 1) { @@ -167,7 +166,8 @@ namespace AzToolsFramework } QMenu menu(this); - AssetBrowserInteractionNotificationBus::Broadcast(&AssetBrowserInteractionNotificationBus::Events::AddContextMenuActions, this, &menu, selectedAssets); + AssetBrowserInteractionNotificationBus::Broadcast( + &AssetBrowserInteractionNotificationBus::Events::AddContextMenuActions, this, &menu, selectedAssets); if (!menu.isEmpty()) { menu.exec(QCursor::pos()); @@ -175,5 +175,4 @@ namespace AzToolsFramework } } // namespace AssetBrowser } // namespace AzToolsFramework -#pragma optimize("", on) #include "AssetBrowser/Views/moc_AssetBrowserTableView.cpp" diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index e722d6d03e..90b597e273 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -1,26 +1,26 @@ /* -* All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or -* its licensors. -* -* For complete copyright and license terms please see the LICENSE at the root of this -* distribution (the "License"). All use of this software is governed by the License, -* or, if provided, by the license below or the license accompanying this file. Do not -* remove or modify any license notices. This file is distributed on an "AS IS" BASIS, -* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -* -*/ + * All or portions of this file Copyright (c) Amazon.com, Inc. or its affiliates or + * its licensors. + * + * For complete copyright and license terms please see the LICENSE at the root of this + * distribution (the "License"). All use of this software is governed by the License, + * or, if provided, by the license below or the license accompanying this file. Do not + * remove or modify any license notices. This file is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * + */ #include "EditorDefs.h" #include "AzAssetBrowserWindow.h" // AzToolsFramework +#include #include #include +#include #include #include -#include -#include // AzQtComponents #include @@ -35,7 +35,6 @@ AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING AZ_CVAR_EXTERNED(bool, ed_useNewAssetBrowserTableView); - class ListenerForShowAssetEditorEvent : public QObject , private AzToolsFramework::EditorEvents::Bus::Handler @@ -113,22 +112,29 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); - connect(m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, - m_filterModel.data(), &AssetBrowserFilterModel::filterUpdatedSlot); - connect(m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, this, [this]() - { - const bool hasFilter = !m_ui->m_searchWidget->GetFilterString().isEmpty(); - const bool selectFirstFilteredIndex = false; - m_ui->m_assetBrowserTreeViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex); - }); + connect( + m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), + &AssetBrowserFilterModel::filterUpdatedSlot); + connect( + m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, this, + [this]() + { + const bool hasFilter = !m_ui->m_searchWidget->GetFilterString().isEmpty(); + const bool selectFirstFilteredIndex = false; + m_ui->m_assetBrowserTreeViewWidget->UpdateAfterFilter(hasFilter, selectFirstFilteredIndex); + }); - connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, - this, &AzAssetBrowserWindow::SelectionChangedSlot); + connect( + m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, this, + &AzAssetBrowserWindow::SelectionChangedSlot); connect(m_ui->m_assetBrowserTreeViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); - connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, &SearchWidget::ClearStringFilter); - connect(m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); + connect( + m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, + &SearchWidget::ClearStringFilter); + connect( + m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main"); } @@ -199,18 +205,21 @@ void AzAssetBrowserWindow::SelectAsset(const QString& assetPath) // interferes with the update from the select and expand, and if you don't // queue it, the tree doesn't expand reliably. - QTimer::singleShot(0, this, [this, filteredIndex = index] { - // the treeview has a filter model so we have to backwards go from that - QModelIndex index = m_filterModel->mapFromSource(filteredIndex); + QTimer::singleShot( + 0, this, + [this, filteredIndex = index] + { + // the treeview has a filter model so we have to backwards go from that + QModelIndex index = m_filterModel->mapFromSource(filteredIndex); - QTreeView* treeView = m_ui->m_assetBrowserTreeViewWidget; - ExpandTreeToIndex(treeView, index); + QTreeView* treeView = m_ui->m_assetBrowserTreeViewWidget; + ExpandTreeToIndex(treeView, index); - treeView->scrollTo(index); - treeView->setCurrentIndex(index); + treeView->scrollTo(index); + treeView->setCurrentIndex(index); - treeView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect); - }); + treeView->selectionModel()->select(index, QItemSelectionModel::ClearAndSelect); + }); } } @@ -243,11 +252,12 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& assetIdToOpen = AZ::Data::AssetId(sourceEntry->GetSourceUuid(), 0); fullFilePath = entry->GetFullPath(); } - + bool handledBySomeone = false; if (assetIdToOpen.IsValid()) { - AssetBrowserInteractionNotificationBus::Broadcast(&AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); + AssetBrowserInteractionNotificationBus::Broadcast( + &AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); } if (!handledBySomeone && !fullFilePath.empty()) @@ -255,7 +265,6 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& AzAssetBrowserRequestHandler::OpenWithOS(fullFilePath); } } - } void AzAssetBrowserWindow::DoubleClickedItemTableModel([[maybe_unused]] const QModelIndex& element) From eb67b6b452a768c10e2a905711e2ab1710bcbc4a Mon Sep 17 00:00:00 2001 From: igarri Date: Thu, 3 Jun 2021 13:36:47 +0100 Subject: [PATCH 025/244] Adding namespace aliases and API comments --- .../Views/AssetBrowserTableView.h | 2 +- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 71 +++++++++---------- 2 files changed, 36 insertions(+), 37 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h index 65f97d1a6d..15bc95f13c 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/AssetBrowserTableView.h @@ -32,7 +32,7 @@ namespace AzToolsFramework class AssetBrowserFilterModel; class EntryDelegate; - class AssetBrowserTableView + class AssetBrowserTableView //! Table view that displays the asset browser entries in a list. : public QTableView , public AssetBrowserViewRequestBus::Handler , public AssetBrowserComponentNotificationBus::Handler diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 90b597e273..481cc35635 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -74,8 +74,9 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_ui->setupUi(this); m_ui->m_searchWidget->Setup(true, true); - using namespace AzToolsFramework::AssetBrowser; - AssetBrowserComponentRequestBus::BroadcastResult(m_assetBrowserModel, &AssetBrowserComponentRequests::GetAssetBrowserModel); + namespace AB = AzToolsFramework::AssetBrowser; + + AB::AssetBrowserComponentRequestBus::BroadcastResult(m_assetBrowserModel, &AB::AssetBrowserComponentRequests::GetAssetBrowserModel); AZ_Assert(m_assetBrowserModel, "Failed to get filebrowser model"); m_filterModel->setSourceModel(m_assetBrowserModel); m_filterModel->SetFilter(m_ui->m_searchWidget->GetFilter()); @@ -89,34 +90,34 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_tableModel->setSourceModel(m_filterModel.data()); m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); connect( - m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, m_tableModel.data(), - &AssetBrowserTableModel::UpdateTableModelMaps); + m_filterModel.data(), &AB::AssetBrowserFilterModel::filterChanged, m_tableModel.data(), + &AB::AssetBrowserTableModel::UpdateTableModelMaps); connect( - m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::selectionChangedSignal, this, + m_ui->m_assetBrowserTableViewWidget, &AB::AssetBrowserTableView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); connect( m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItemTableModel); connect( - m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget, - &SearchWidget::ClearStringFilter); + m_ui->m_assetBrowserTableViewWidget, &AB::AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget, + &AB::SearchWidget::ClearStringFilter); connect( - m_ui->m_assetBrowserTableViewWidget, &AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget, - &SearchWidget::ClearTypeFilter); + m_ui->m_assetBrowserTableViewWidget, &AB::AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget, + &AB::SearchWidget::ClearTypeFilter); m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main"); - connect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); + connect(m_filterModel.data(), &AB::AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); connect(m_ui->m_viewSwitcherCheckBox, &QCheckBox::stateChanged, this, &AzAssetBrowserWindow::LockToDefaultView); } m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); connect( - m_ui->m_searchWidget->GetFilter().data(), &AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), - &AssetBrowserFilterModel::filterUpdatedSlot); + m_ui->m_searchWidget->GetFilter().data(), &AB::AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), + &AB::AssetBrowserFilterModel::filterUpdatedSlot); connect( - m_filterModel.data(), &AssetBrowserFilterModel::filterChanged, this, + m_filterModel.data(), &AB::AssetBrowserFilterModel::filterChanged, this, [this]() { const bool hasFilter = !m_ui->m_searchWidget->GetFilterString().isEmpty(); @@ -125,16 +126,17 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) }); connect( - m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::selectionChangedSignal, this, + m_ui->m_assetBrowserTreeViewWidget, &AB::AssetBrowserTreeView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); connect(m_ui->m_assetBrowserTreeViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); connect( - m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, - &SearchWidget::ClearStringFilter); + m_ui->m_assetBrowserTreeViewWidget, &AB::AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, + &AB::SearchWidget::ClearStringFilter); connect( - m_ui->m_assetBrowserTreeViewWidget, &AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, &SearchWidget::ClearTypeFilter); + m_ui->m_assetBrowserTreeViewWidget, &AB::AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, + &AB::SearchWidget::ClearTypeFilter); m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main"); } @@ -192,8 +194,6 @@ static void ExpandTreeToIndex(QTreeView* treeView, const QModelIndex& index) void AzAssetBrowserWindow::SelectAsset(const QString& assetPath) { - using namespace AzToolsFramework::AssetBrowser; - QModelIndex index = m_assetBrowserModel->findIndex(assetPath); if (index.isValid()) { @@ -232,21 +232,21 @@ void AzAssetBrowserWindow::SelectionChangedSlot(const QItemSelection& /*selected // just becuase on some OS clicking once is activation. void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& element) { - using namespace AzToolsFramework; - using namespace AzToolsFramework::AssetBrowser; + namespace AB = AzToolsFramework::AssetBrowser; + // assumption: Double clicking an item selects it before telling us we double clicked it. const auto& selectedAssets = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets(); - for (const AssetBrowserEntry* entry : selectedAssets) + for (const AB::AssetBrowserEntry* entry : selectedAssets) { AZ::Data::AssetId assetIdToOpen; AZStd::string fullFilePath; - if (const ProductAssetBrowserEntry* productEntry = azrtti_cast(entry)) + if (const AB::ProductAssetBrowserEntry* productEntry = azrtti_cast(entry)) { assetIdToOpen = productEntry->GetAssetId(); fullFilePath = entry->GetFullPath(); } - else if (const SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry)) + else if (const AB::SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry)) { // manufacture an empty AssetID with the source's UUID assetIdToOpen = AZ::Data::AssetId(sourceEntry->GetSourceUuid(), 0); @@ -256,8 +256,8 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& bool handledBySomeone = false; if (assetIdToOpen.IsValid()) { - AssetBrowserInteractionNotificationBus::Broadcast( - &AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); + AB::AssetBrowserInteractionNotificationBus::Broadcast( + &AB::AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); } if (!handledBySomeone && !fullFilePath.empty()) @@ -269,21 +269,20 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& void AzAssetBrowserWindow::DoubleClickedItemTableModel([[maybe_unused]] const QModelIndex& element) { - using namespace AzToolsFramework; - using namespace AzToolsFramework::AssetBrowser; + namespace AB = AzToolsFramework::AssetBrowser; // assumption: Double clicking an item selects it before telling us we double clicked it. const auto& selectedAssets = m_ui->m_assetBrowserTableViewWidget->GetSelectedAssets(); - for (const AssetBrowserEntry* entry : selectedAssets) + for (const AB::AssetBrowserEntry* entry : selectedAssets) { AZ::Data::AssetId assetIdToOpen; AZStd::string fullFilePath; - if (const ProductAssetBrowserEntry* productEntry = azrtti_cast(entry)) + if (const AB::ProductAssetBrowserEntry* productEntry = azrtti_cast(entry)) { assetIdToOpen = productEntry->GetAssetId(); fullFilePath = entry->GetFullPath(); } - else if (const SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry)) + else if (const AB::SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry)) { // manufacture an empty AssetID with the source's UUID assetIdToOpen = AZ::Data::AssetId(sourceEntry->GetSourceUuid(), 0); @@ -293,8 +292,8 @@ void AzAssetBrowserWindow::DoubleClickedItemTableModel([[maybe_unused]] const QM bool handledBySomeone = false; if (assetIdToOpen.IsValid()) { - AssetBrowserInteractionNotificationBus::Broadcast( - &AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); + AB::AssetBrowserInteractionNotificationBus::Broadcast( + &AB::AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); } if (!handledBySomeone && !fullFilePath.empty()) @@ -312,12 +311,12 @@ void AzAssetBrowserWindow::SwitchDisplayView(bool state) void AzAssetBrowserWindow::LockToDefaultView(bool state) { - using namespace AzToolsFramework; - using namespace AzToolsFramework::AssetBrowser; + using AzToolsFramework::AssetBrowser::AssetBrowserFilterModel; SwitchDisplayView(!state); if (state == true) { - disconnect(m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); + disconnect( + m_filterModel.data(), &AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); } else { From c55f65b78ff1dbc36de9654af0b8e429a206ca42 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Thu, 3 Jun 2021 15:35:16 -0700 Subject: [PATCH 026/244] Integrate parts of Session Server API --- .../Source/MultiplayerSystemComponent.cpp | 28 +++++++++++++++++++ .../Code/Source/MultiplayerSystemComponent.h | 14 ++++++++++ 2 files changed, 42 insertions(+) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index 0818f605df..50da2136fb 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -29,6 +29,8 @@ #include #include #include +#include +#include #include #include @@ -142,6 +144,7 @@ namespace Multiplayer void MultiplayerSystemComponent::Activate() { AZ::TickBus::Handler::BusConnect(); + AzFramework::SessionNotificationBus::Handler::BusConnect(); m_networkInterface = AZ::Interface::Get()->CreateNetworkInterface(AZ::Name(MPNetworkInterfaceName), sv_protocol, TrustZone::ExternalClientToServer, *this); m_consoleCommandHandler.Connect(AZ::Interface::Get()->GetConsoleCommandInvokedEvent()); AZ::Interface::Register(this); @@ -153,9 +156,34 @@ namespace Multiplayer void MultiplayerSystemComponent::Deactivate() { AZ::Interface::Unregister(this); + AzFramework::SessionNotificationBus::Handler::BusDisconnect(); AZ::TickBus::Handler::BusDisconnect(); } + bool MultiplayerSystemComponent::OnSessionHealthCheck() + { + return true; + } + + bool MultiplayerSystemComponent::OnCreateSessionBegin(const AzFramework::SessionConfig& sessionConfig) + { + Multiplayer::MultiplayerAgentType serverType = sv_isDedicated ? MultiplayerAgentType::DedicatedServer : MultiplayerAgentType::ClientServer; + AZ::Interface::Get()->InitializeMultiplayer(serverType); + return m_networkInterface->Listen(sessionConfig.m_port); + } + + bool MultiplayerSystemComponent::OnDestroySessionBegin() + { + bool disconnectSuccessful = true; + IConnectionSet& connectionSet = m_networkInterface->GetConnectionSet(); + connectionSet.VisitConnections([&disconnectSuccessful](IConnection& connection) + { + bool didDisconnect = connection.Disconnect(DisconnectReason::TerminatedByServer, TerminationEndpoint::Remote); + disconnectSuccessful = disconnectSuccessful && didDisconnect; + }); + return disconnectSuccessful; + } + void MultiplayerSystemComponent::OnTick([[maybe_unused]] float deltaTime, [[maybe_unused]] AZ::ScriptTimePoint time) { AZ::TimeMs deltaTimeMs = aznumeric_cast(static_cast(deltaTime * 1000.0f)); diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h index e8e05a9d4c..bd989cf841 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h @@ -25,8 +25,14 @@ #include #include #include +#include #include +namespace AzFramework +{ + struct SessionConfig; +} + namespace AzNetworking { class INetworkInterface; @@ -38,6 +44,7 @@ namespace Multiplayer class MultiplayerSystemComponent final : public AZ::Component , public AZ::TickBus::Handler + , public AzFramework::SessionNotificationBus::Handler , public AzNetworking::IConnectionListener , public IMultiplayer { @@ -58,6 +65,13 @@ namespace Multiplayer void Deactivate() override; //! @} + //! AzFramework::SessionNotificationBus::Handler overrides. + //! @{ + bool OnSessionHealthCheck() override; + bool OnCreateSessionBegin(const AzFramework::SessionConfig& sessionConfig) override; + bool OnDestroySessionBegin() override; + //! @} + //! AZ::TickBus::Handler overrides. //! @{ void OnTick(float deltaTime, AZ::ScriptTimePoint time) override; From 0e4a632417625d1dceb28a2d62d14a0aa8d277e9 Mon Sep 17 00:00:00 2001 From: moudgils Date: Thu, 3 Jun 2021 22:45:50 -0700 Subject: [PATCH 027/244] Add support for re-binding SRG entries if the drawItem has a new pso which changes how a srg is used in the shader. Also optimized api usage to use single call for UseResource and for setting stream buffers. --- .../Shaders/MorphTargets/MorphTargetSRG.azsli | 2 +- .../Metal/Code/Source/RHI/ArgumentBuffer.cpp | 133 +++++++++--------- .../Metal/Code/Source/RHI/ArgumentBuffer.h | 15 +- .../RHI/Metal/Code/Source/RHI/CommandList.cpp | 56 ++++++-- .../RHI/Metal/Code/Source/RHI/CommandList.h | 1 + .../Metal/Code/Source/RHI/PipelineLayout.cpp | 7 + .../Metal/Code/Source/RHI/PipelineLayout.h | 6 + 7 files changed, 134 insertions(+), 86 deletions(-) diff --git a/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetSRG.azsli b/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetSRG.azsli index 171e803c2c..83193c8559 100644 --- a/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetSRG.azsli +++ b/Gems/Atom/Feature/Common/Assets/Shaders/MorphTargets/MorphTargetSRG.azsli @@ -16,7 +16,7 @@ ShaderResourceGroup MorphTargetPassSrg : SRG_PerPass { - RWStruturedBuffer m_accumulatedDeltas; + RWStructuredBuffer m_accumulatedDeltas; } // This class represents the data that is passed to the morph target compute shader of an individual delta diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp index 6ffd15e0bc..1e2edc6520 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp @@ -386,6 +386,11 @@ namespace AZ void ArgumentBuffer::AddUntrackedResourcesToEncoder(id commandEncoder, const ShaderResourceGroupVisibility& srgResourcesVisInfo) const { + + ComputeResourcesToMakeResidentMap resourcesToMakeResidentCompute; + GraphicsResourcesToMakeResidentMap resourcesToMakeResidentGraphics; + + //Cache the constant buffer associated with a srg if (m_constantBufferSize) { uint8_t numBitsSet = RHI::CountBitsSet(static_cast(srgResourcesVisInfo.m_constantDataStageMask)); @@ -393,28 +398,19 @@ namespace AZ { if(RHI::CheckBitsAny(srgResourcesVisInfo.m_constantDataStageMask, RHI::ShaderStageMask::Compute)) { - [static_cast>(commandEncoder) useResource:m_constantBuffer.GetGpuAddress>() usage:MTLResourceUsageRead]; + resourcesToMakeResidentCompute[MTLResourceUsageRead].m_resourceArray[resourcesToMakeResidentCompute[MTLResourceUsageRead].m_resourceArrayLen++] = m_constantBuffer.GetGpuAddress>(); } else { MTLRenderStages mtlRenderStages = GetRenderStages(srgResourcesVisInfo.m_constantDataStageMask); - [static_cast>(commandEncoder) useResource:m_constantBuffer.GetGpuAddress>() - usage:MTLResourceUsageRead - stages:mtlRenderStages]; + AZStd::pair key = AZStd::make_pair(MTLResourceUsageRead, mtlRenderStages); + resourcesToMakeResidentGraphics[key].m_resourceArray[resourcesToMakeResidentGraphics[key].m_resourceArrayLen++] = m_constantBuffer.GetGpuAddress>(); } - } } - ApplyUseResource(commandEncoder, m_resourceBindings, srgResourcesVisInfo); - } - - void ArgumentBuffer::ApplyUseResource(id encoder, - const ResourceBindingsMap& resourceMap, - const ShaderResourceGroupVisibility& srgResourcesVisInfo) const - { - - CommandEncoderType encodeType = CommandEncoderType::Invalid; - for (const auto& it : resourceMap) + + //Cach all the resources within a srg that are used by the shader based on the visibility information + for (const auto& it : m_resourceBindings) { //Extract the visibility mask for the give resource auto visMaskIt = srgResourcesVisInfo.m_resourcesStageMask.find(it.first); @@ -426,75 +422,50 @@ namespace AZ { if(RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Compute)) { - //Call UseResource on all resources for Compute stage - ApplyUseResourceToCompute(encoder, it.second); - encodeType = CommandEncoderType::Compute; + ApplyUseResourceToCompute(commandEncoder, it.second, resourcesToMakeResidentCompute); } else { - //Call UseResource on all resources for Vertex and Fragment stages AZ_Assert(RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Vertex) || RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Fragment), "The visibility mask %i is not set for Vertex or fragment stage", visMaskIt->second); - ApplyUseResourceToGraphic(encoder, visMaskIt->second, it.second); - encodeType = CommandEncoderType::Render; + ApplyUseResourceToGraphic(commandEncoder, visMaskIt->second, it.second, resourcesToMakeResidentGraphics); } } } - } - - void ArgumentBuffer::ApplyUseResourceToCompute(id encoder, const ResourceBindingsSet& resourceBindingDataSet) const - { - for (const auto& resourceBindingData : resourceBindingDataSet) - { - ResourceType rescType = resourceBindingData.m_resourcPtr->GetResourceType(); - switch(rescType) - { - case ResourceType::MtlTextureType: - { - MTLResourceUsage resourceUsage = GetImageResourceUsage(resourceBindingData.m_imageAccess); - [static_cast>(encoder) useResource:resourceBindingData.m_resourcPtr->GetGpuAddress>() usage:resourceUsage]; - - break; - } - case ResourceType::MtlBufferType: - { - MTLResourceUsage resourceUsage = GetBufferResourceUsage(resourceBindingData.m_bufferAccess); - [static_cast>(encoder) useResource:resourceBindingData.m_resourcPtr->GetGpuAddress>() usage:resourceUsage]; - - break; - } - default: - { - AZ_Assert(false, "Undefined Resource type"); - } - } - } - } - - void ArgumentBuffer::ApplyUseResourceToGraphic(id encoder, RHI::ShaderStageMask visShaderMask, const ResourceBindingsSet& resourceBindingDataSet) const - { - MTLRenderStages mtlRenderStages = GetRenderStages(visShaderMask); + //Call UseResource on all resources for Compute stage + for (const auto& key : resourcesToMakeResidentCompute) + { + [static_cast>(commandEncoder) useResources: key.second.m_resourceArray.data() + count: key.second.m_resourceArrayLen + usage: key.first]; + } + + //Call UseResource on all resources for Vertex and Fragment stages + for (const auto& key : resourcesToMakeResidentGraphics) + { + [static_cast>(commandEncoder) useResources: key.second.m_resourceArray.data() + count: key.second.m_resourceArrayLen + usage: key.first.first + stages: key.first.second]; + } + } + + void ArgumentBuffer::ApplyUseResourceToCompute(id encoder, const ResourceBindingsSet& resourceBindingDataSet, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const + { for (const auto& resourceBindingData : resourceBindingDataSet) { ResourceType rescType = resourceBindingData.m_resourcPtr->GetResourceType(); + MTLResourceUsage resourceUsage = MTLResourceUsageRead; switch(rescType) { case ResourceType::MtlTextureType: { - MTLResourceUsage resourceUsage = GetImageResourceUsage(resourceBindingData.m_imageAccess); - [static_cast>(encoder) useResource:resourceBindingData.m_resourcPtr->GetGpuAddress>() - usage:resourceUsage - stages:mtlRenderStages]; - + resourceUsage |= GetImageResourceUsage(resourceBindingData.m_imageAccess); break; } case ResourceType::MtlBufferType: { - MTLResourceUsage resourceUsage = GetBufferResourceUsage(resourceBindingData.m_bufferAccess); - [static_cast>(encoder) useResource:resourceBindingData.m_resourcPtr->GetGpuAddress>() - usage:resourceUsage - stages:mtlRenderStages]; - + resourceUsage |= GetBufferResourceUsage(resourceBindingData.m_bufferAccess); break; } default: @@ -502,8 +473,38 @@ namespace AZ AZ_Assert(false, "Undefined Resource type"); } } + resourcesToMakeResidentMap[resourceUsage].m_resourceArray[resourcesToMakeResidentMap[resourceUsage].m_resourceArrayLen++] = resourceBindingData.m_resourcPtr->GetGpuAddress>(); + } + } + + void ArgumentBuffer::ApplyUseResourceToGraphic(id encoder, RHI::ShaderStageMask visShaderMask, const ResourceBindingsSet& resourceBindingDataSet, GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const + { + + MTLRenderStages mtlRenderStages = GetRenderStages(visShaderMask); + MTLResourceUsage resourceUsage = MTLResourceUsageRead; + for (const auto& resourceBindingData : resourceBindingDataSet) + { + ResourceType rescType = resourceBindingData.m_resourcPtr->GetResourceType(); + switch(rescType) + { + case ResourceType::MtlTextureType: + { + resourceUsage |= GetImageResourceUsage(resourceBindingData.m_imageAccess); + break; + } + case ResourceType::MtlBufferType: + { + resourceUsage |= GetBufferResourceUsage(resourceBindingData.m_bufferAccess); + break; + } + default: + { + AZ_Assert(false, "Undefined Resource type"); + } + } + AZStd::pair key = AZStd::make_pair(resourceUsage, mtlRenderStages); + resourcesToMakeResidentMap[key].m_resourceArray[resourcesToMakeResidentMap[key].m_resourceArrayLen++] = resourceBindingData.m_resourcPtr->GetGpuAddress>(); } } - } } diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h index a5a8e00e69..2434b8312d 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h @@ -119,8 +119,17 @@ namespace AZ using ResourceBindingsMap = AZStd::unordered_map; ResourceBindingsMap m_resourceBindings; - void ApplyUseResourceToCompute(id encoder, const ResourceBindingsSet& resourceBindingData) const; - void ApplyUseResourceToGraphic(id encoder, RHI::ShaderStageMask visShaderMask, const ResourceBindingsSet& resourceBindingDataSet) const; + static const int MaxEntriesInArgTable = 31; + struct MetalResourceArray + { + AZStd::array, MaxEntriesInArgTable> m_resourceArray; + int m_resourceArrayLen = 0; + }; + using ComputeResourcesToMakeResidentMap = AZStd::unordered_map; + using GraphicsResourcesToMakeResidentMap = AZStd::unordered_map, MetalResourceArray>; + + void ApplyUseResourceToCompute(id encoder, const ResourceBindingsSet& resourceBindingData, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const; + void ApplyUseResourceToGraphic(id encoder, RHI::ShaderStageMask visShaderMask, const ResourceBindingsSet& resourceBindingDataSet, GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const; //! Use visibility information to call UseResource on all resources for this Argument Buffer void ApplyUseResource(id encoder, const ResourceBindingsMap& resourceMap, @@ -144,8 +153,6 @@ namespace AZ #endif ShaderResourceGroupPool* m_srgPool = nullptr; - - static const int MaxEntriesInArgTable = 31; NSCache* m_samplerCache; }; } diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.cpp index 3eca8dabd8..10fbe372b1 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.cpp @@ -258,24 +258,19 @@ namespace AZ continue; } + uint32_t srgVisIndex = pipelineLayout.GetSlotByIndex(shaderResourceGroup->GetBindingSlot()); + const RHI::ShaderStageMask& srgVisInfo = pipelineLayout.GetSrgVisibility(srgVisIndex); + if (bindings.m_srgsByIndex[srgIndex] != shaderResourceGroup) { bindings.m_srgsByIndex[srgIndex] = shaderResourceGroup; auto& compiledArgBuffer = shaderResourceGroup->GetCompiledArgumentBuffer(); - id argBuffer = compiledArgBuffer.GetArgEncoderBuffer(); size_t argBufferOffset = compiledArgBuffer.GetOffset(); - - uint32_t srgVisIndex = pipelineLayout.GetSlotByIndex(shaderResourceGroup->GetBindingSlot()); - const RHI::ShaderStageMask& srgVisInfo = pipelineLayout.GetSrgVisibility(srgVisIndex); - + if(srgVisInfo != RHI::ShaderStageMask::None) { - const ShaderResourceGroupVisibility& srgResourcesVisInfo = pipelineLayout.GetSrgResourcesVisibility(srgVisIndex); - - //For graphics and compute encoder bind the argument buffer and - //make the resource resident for the duration of the work associated with the current scope - //and ensure that it's in a format compatible with the appropriate metal function. + //For graphics and compute encoder bind the argument buffer if(m_commandEncoderType == CommandEncoderType::Render) { id renderEncoder = GetEncoder>(); @@ -293,7 +288,6 @@ namespace AZ offset:argBufferOffset atIndex:slotIndex]; } - shaderResourceGroup->AddUntrackedResourcesToEncoder(m_encoder, srgResourcesVisInfo); } else if(m_commandEncoderType == CommandEncoderType::Compute) { @@ -301,6 +295,28 @@ namespace AZ [computeEncoder setBuffer:argBuffer offset:argBufferOffset atIndex:pipelineLayout.GetSlotByIndex(srgIndex)]; + } + } + } + + //Check againgst the srg resources visibility hash as it is possible for draw items to have different PSO in the same pass. + const AZ::HashValue64 srgResourcesVisHash = pipelineLayout.GetSrgResourcesVisibilityHash(srgVisIndex); + if(bindings.m_srgVisHashByIndex[srgIndex] != srgResourcesVisHash) + { + bindings.m_srgVisHashByIndex[srgIndex] = srgResourcesVisHash; + if(srgVisInfo != RHI::ShaderStageMask::None) + { + const ShaderResourceGroupVisibility& srgResourcesVisInfo = pipelineLayout.GetSrgResourcesVisibility(srgVisIndex); + + //For graphics and compute encoder bind the argument buffer and + //make the resource resident for the duration of the work associated with the current scope + //and ensure that it's in a format compatible with the appropriate metal function. + if(m_commandEncoderType == CommandEncoderType::Render) + { + shaderResourceGroup->AddUntrackedResourcesToEncoder(m_encoder, srgResourcesVisInfo); + } + else if(m_commandEncoderType == CommandEncoderType::Compute) + { shaderResourceGroup->AddUntrackedResourcesToEncoder(m_encoder, srgResourcesVisInfo); } } @@ -447,6 +463,7 @@ namespace AZ for (size_t i = 0; i < bindings.m_srgsByIndex.size(); ++i) { bindings.m_srgsByIndex[i] = nullptr; + bindings.m_srgVisHashByIndex[i] = AZ::HashValue64{0}; } const PipelineLayout& pipelineLayout = pipelineState->GetPipelineLayout(); @@ -469,6 +486,10 @@ namespace AZ void CommandList::SetStreamBuffers(const RHI::StreamBufferView* streams, uint32_t count) { + int bufferArrayLen = 0; + AZStd::array, METAL_MAX_ENTRIES_BUFFER_ARG_TABLE> mtlStreamBuffers; + AZStd::array mtlStreamBufferOffsets; + AZ::HashValue64 streamsHash = AZ::HashValue64{0}; for (uint32_t i = 0; i < count; ++i) { @@ -479,18 +500,23 @@ namespace AZ { m_state.m_streamsHash = streamsHash; AZ_Assert(count <= METAL_MAX_ENTRIES_BUFFER_ARG_TABLE , "Slots needed cannot exceed METAL_MAX_ENTRIES_BUFFER_ARG_TABLE"); - for (uint32_t i = 0; i < count; ++i) + + NSRange range = {METAL_MAX_ENTRIES_BUFFER_ARG_TABLE - count, count}; + //For metal the stream buffers are populated from bottom to top as the top slots are taken by argument buffers + for (int i = count-1; i >= 0; --i) { if (streams[i].GetBuffer()) { const Buffer * buff = static_cast(streams[i].GetBuffer()); id mtlBuff = buff->GetMemoryView().GetGpuAddress>(); - uint32_t VBIndex = (METAL_MAX_ENTRIES_BUFFER_ARG_TABLE - 1) - i; uint32_t offset = streams[i].GetByteOffset() + buff->GetMemoryView().GetOffset(); - id renderEncoder = GetEncoder>(); - [renderEncoder setVertexBuffer: mtlBuff offset: offset atIndex: VBIndex]; + mtlStreamBuffers[bufferArrayLen] = mtlBuff; + mtlStreamBufferOffsets[bufferArrayLen] = offset; + bufferArrayLen++; } } + id renderEncoder = GetEncoder>(); + [renderEncoder setVertexBuffers: mtlStreamBuffers.data() offsets: mtlStreamBufferOffsets.data() withRange: range]; } } diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.h b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.h index 6660beb2c4..dd4e382471 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.h +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/CommandList.h @@ -99,6 +99,7 @@ namespace AZ { AZStd::array m_srgsByIndex; AZStd::array m_srgsBySlot; + AZStd::array m_srgVisHashByIndex; }; ShaderResourceBindings& GetShaderResourceBindingsByPipelineType(RHI::PipelineStateType pipelineType); diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLayout.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLayout.cpp index f237884aab..70d36f8d6d 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLayout.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLayout.cpp @@ -70,6 +70,7 @@ namespace AZ m_srgVisibilities.resize(RHI::Limits::Pipeline::ShaderResourceGroupCountMax); m_srgResourcesVisibility.resize(RHI::Limits::Pipeline::ShaderResourceGroupCountMax); + m_srgResourcesVisibilityHash.resize(RHI::Limits::Pipeline::ShaderResourceGroupCountMax); for (uint32_t srgLayoutIdx = 0; srgLayoutIdx < groupLayoutCount; ++srgLayoutIdx) { const RHI::ShaderResourceGroupLayout& srgLayout = *descriptor.GetShaderResourceGroupLayout(srgLayoutIdx); @@ -111,6 +112,7 @@ namespace AZ m_srgVisibilities[srgIndex] = mask; m_srgResourcesVisibility[srgIndex] = srgVis; + m_srgResourcesVisibilityHash[srgIndex] = srgVis.GetHash(); } // Cache the inline constant size and slot index @@ -141,6 +143,11 @@ namespace AZ return m_srgResourcesVisibility[index]; } + const AZ::HashValue64 PipelineLayout::GetSrgResourcesVisibilityHash(uint32_t index) const + { + return m_srgResourcesVisibilityHash[index]; + } + uint32_t PipelineLayout::GetRootConstantsSize() const { return m_rootConstantsSize; diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLayout.h b/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLayout.h index e8cd249393..6fd06ea29b 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLayout.h +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/PipelineLayout.h @@ -57,6 +57,9 @@ namespace AZ /// Returns srgVisibility data const ShaderResourceGroupVisibility& GetSrgResourcesVisibility(uint32_t index) const; + /// Returns srgVisibility hash + const AZ::HashValue64 GetSrgResourcesVisibilityHash(uint32_t index) const; + /// Returns the root constant specific layout information uint32_t GetRootConstantsSize() const; uint32_t GetRootConstantsSlotIndex() const; @@ -84,6 +87,9 @@ namespace AZ /// Cache Visibility across all the resources within the SRG AZStd::fixed_vector m_srgResourcesVisibility; + /// Cache Visibility hash across all the resources within the SRG + AZStd::fixed_vector m_srgResourcesVisibilityHash; + uint32_t m_rootConstantSlotIndex = (uint32_t)-1; uint32_t m_rootConstantsSize = 0; }; From 3d1abdc4e3934888ad253d0563f614b094496418 Mon Sep 17 00:00:00 2001 From: igarri Date: Fri, 4 Jun 2021 12:16:32 +0100 Subject: [PATCH 028/244] Pull request corrections, namespaces, style, etc --- .../Entries/RootAssetBrowserEntry.cpp | 2 +- .../AssetBrowser/Search/Filter.h | 1 + .../AssetBrowser/Views/EntryDelegate.cpp | 8 +-- .../AzAssetBrowser/AzAssetBrowserWindow.cpp | 61 +++++++++---------- 4 files changed, 36 insertions(+), 36 deletions(-) diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp index 2ccc2cd6bf..e626f31b62 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Entries/RootAssetBrowserEntry.cpp @@ -287,7 +287,7 @@ namespace AzToolsFramework product->m_assetType.ToString(product->m_assetTypeString); AZ::Data::AssetCatalogRequestBus::BroadcastResult(product->m_relativePath, &AZ::Data::AssetCatalogRequests::GetAssetPathById, assetId); QString displayPath = QString::fromUtf8(product->m_relativePath.c_str()); - displayPath.remove(QString("/" + QString::fromUtf8(product->m_name.c_str()))); + displayPath.remove(QString(AZ_CORRECT_DATABASE_SEPARATOR + QString::fromUtf8(product->m_name.c_str()))); product->m_displayPath = displayPath; EntryCache::GetInstance()->m_productAssetIdMap[assetId] = product; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h index 135dd00925..b67b699862 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Search/Filter.h @@ -110,6 +110,7 @@ namespace AzToolsFramework ~StringFilter() override = default; void SetFilterString(const QString& filterString); + protected: QString GetNameInternal() const override; bool MatchInternal(const AssetBrowserEntry* entry) const override; diff --git a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp index c73c00981b..d0ac05020d 100644 --- a/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp +++ b/Code/Framework/AzToolsFramework/AzToolsFramework/AssetBrowser/Views/EntryDelegate.cpp @@ -95,13 +95,13 @@ namespace AzToolsFramework remainingRect.adjust(thumbX, 0, 0, 0); // bump it to the right by the size of the thumbnail remainingRect.adjust(ENTRY_SPACING_LEFT_PIXELS, 0, 0, 0); // bump it to the right by the spacing. } - QString displayString = qvariant_cast(index.data(index.column())); + QString displayString = index.column() == aznumeric_cast(AssetBrowserEntry::Column::Name) + ? qvariant_cast(entry->data(aznumeric_cast(AssetBrowserEntry::Column::Name))) + : qvariant_cast(entry->data(aznumeric_cast(AssetBrowserEntry::Column::Path))); style->drawItemText( painter, remainingRect, option.displayAlignment, actualPalette, isEnabled, - index.column() == aznumeric_cast(AssetBrowserEntry::Column::Name) - ? qvariant_cast(entry->data(aznumeric_cast(AssetBrowserEntry::Column::Name))) - : qvariant_cast(entry->data(aznumeric_cast(AssetBrowserEntry::Column::Path))), + displayString, isSelected ? QPalette::HighlightedText : QPalette::Text); } } diff --git a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp index 481cc35635..60ff6f9549 100644 --- a/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp +++ b/Code/Sandbox/Editor/AzAssetBrowser/AzAssetBrowserWindow.cpp @@ -74,9 +74,9 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_ui->setupUi(this); m_ui->m_searchWidget->Setup(true, true); - namespace AB = AzToolsFramework::AssetBrowser; + namespace AzAssetBrowser = AzToolsFramework::AssetBrowser; - AB::AssetBrowserComponentRequestBus::BroadcastResult(m_assetBrowserModel, &AB::AssetBrowserComponentRequests::GetAssetBrowserModel); + AzAssetBrowser::AssetBrowserComponentRequestBus::BroadcastResult(m_assetBrowserModel, &AzAssetBrowser::AssetBrowserComponentRequests::GetAssetBrowserModel); AZ_Assert(m_assetBrowserModel, "Failed to get filebrowser model"); m_filterModel->setSourceModel(m_assetBrowserModel); m_filterModel->SetFilter(m_ui->m_searchWidget->GetFilter()); @@ -90,34 +90,34 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) m_tableModel->setSourceModel(m_filterModel.data()); m_ui->m_assetBrowserTableViewWidget->setModel(m_tableModel.data()); connect( - m_filterModel.data(), &AB::AssetBrowserFilterModel::filterChanged, m_tableModel.data(), - &AB::AssetBrowserTableModel::UpdateTableModelMaps); + m_filterModel.data(), &AzAssetBrowser::AssetBrowserFilterModel::filterChanged, m_tableModel.data(), + &AzAssetBrowser::AssetBrowserTableModel::UpdateTableModelMaps); connect( - m_ui->m_assetBrowserTableViewWidget, &AB::AssetBrowserTableView::selectionChangedSignal, this, + m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); connect( m_ui->m_assetBrowserTableViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItemTableModel); connect( - m_ui->m_assetBrowserTableViewWidget, &AB::AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget, - &AB::SearchWidget::ClearStringFilter); + m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::ClearStringFilter, m_ui->m_searchWidget, + &AzAssetBrowser::SearchWidget::ClearStringFilter); connect( - m_ui->m_assetBrowserTableViewWidget, &AB::AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget, - &AB::SearchWidget::ClearTypeFilter); + m_ui->m_assetBrowserTableViewWidget, &AzAssetBrowser::AssetBrowserTableView::ClearTypeFilter, m_ui->m_searchWidget, + &AzAssetBrowser::SearchWidget::ClearTypeFilter); m_ui->m_assetBrowserTableViewWidget->SetName("AssetBrowserTableView_main"); - connect(m_filterModel.data(), &AB::AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); + connect(m_filterModel.data(), &AzAssetBrowser::AssetBrowserFilterModel::stringFilterPopulated, this, &AzAssetBrowserWindow::SwitchDisplayView); connect(m_ui->m_viewSwitcherCheckBox, &QCheckBox::stateChanged, this, &AzAssetBrowserWindow::LockToDefaultView); } m_ui->m_assetBrowserTreeViewWidget->setModel(m_filterModel.data()); connect( - m_ui->m_searchWidget->GetFilter().data(), &AB::AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), - &AB::AssetBrowserFilterModel::filterUpdatedSlot); + m_ui->m_searchWidget->GetFilter().data(), &AzAssetBrowser::AssetBrowserEntryFilter::updatedSignal, m_filterModel.data(), + &AzAssetBrowser::AssetBrowserFilterModel::filterUpdatedSlot); connect( - m_filterModel.data(), &AB::AssetBrowserFilterModel::filterChanged, this, + m_filterModel.data(), &AzAssetBrowser::AssetBrowserFilterModel::filterChanged, this, [this]() { const bool hasFilter = !m_ui->m_searchWidget->GetFilterString().isEmpty(); @@ -126,17 +126,17 @@ AzAssetBrowserWindow::AzAssetBrowserWindow(QWidget* parent) }); connect( - m_ui->m_assetBrowserTreeViewWidget, &AB::AssetBrowserTreeView::selectionChangedSignal, this, + m_ui->m_assetBrowserTreeViewWidget, &AzAssetBrowser::AssetBrowserTreeView::selectionChangedSignal, this, &AzAssetBrowserWindow::SelectionChangedSlot); connect(m_ui->m_assetBrowserTreeViewWidget, &QAbstractItemView::doubleClicked, this, &AzAssetBrowserWindow::DoubleClickedItem); connect( - m_ui->m_assetBrowserTreeViewWidget, &AB::AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, - &AB::SearchWidget::ClearStringFilter); + m_ui->m_assetBrowserTreeViewWidget, &AzAssetBrowser::AssetBrowserTreeView::ClearStringFilter, m_ui->m_searchWidget, + &AzAssetBrowser::SearchWidget::ClearStringFilter); connect( - m_ui->m_assetBrowserTreeViewWidget, &AB::AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, - &AB::SearchWidget::ClearTypeFilter); + m_ui->m_assetBrowserTreeViewWidget, &AzAssetBrowser::AssetBrowserTreeView::ClearTypeFilter, m_ui->m_searchWidget, + &AzAssetBrowser::SearchWidget::ClearTypeFilter); m_ui->m_assetBrowserTreeViewWidget->SetName("AssetBrowserTreeView_main"); } @@ -232,21 +232,21 @@ void AzAssetBrowserWindow::SelectionChangedSlot(const QItemSelection& /*selected // just becuase on some OS clicking once is activation. void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& element) { - namespace AB = AzToolsFramework::AssetBrowser; + namespace AzAssetBrowser = AzToolsFramework::AssetBrowser; // assumption: Double clicking an item selects it before telling us we double clicked it. const auto& selectedAssets = m_ui->m_assetBrowserTreeViewWidget->GetSelectedAssets(); - for (const AB::AssetBrowserEntry* entry : selectedAssets) + for (const AzAssetBrowser::AssetBrowserEntry* entry : selectedAssets) { AZ::Data::AssetId assetIdToOpen; AZStd::string fullFilePath; - if (const AB::ProductAssetBrowserEntry* productEntry = azrtti_cast(entry)) + if (const AzAssetBrowser::ProductAssetBrowserEntry* productEntry = azrtti_cast(entry)) { assetIdToOpen = productEntry->GetAssetId(); fullFilePath = entry->GetFullPath(); } - else if (const AB::SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry)) + else if (const AzAssetBrowser::SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry)) { // manufacture an empty AssetID with the source's UUID assetIdToOpen = AZ::Data::AssetId(sourceEntry->GetSourceUuid(), 0); @@ -256,8 +256,8 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& bool handledBySomeone = false; if (assetIdToOpen.IsValid()) { - AB::AssetBrowserInteractionNotificationBus::Broadcast( - &AB::AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); + AzAssetBrowser::AssetBrowserInteractionNotificationBus::Broadcast( + &AzAssetBrowser::AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); } if (!handledBySomeone && !fullFilePath.empty()) @@ -269,20 +269,19 @@ void AzAssetBrowserWindow::DoubleClickedItem([[maybe_unused]] const QModelIndex& void AzAssetBrowserWindow::DoubleClickedItemTableModel([[maybe_unused]] const QModelIndex& element) { - namespace AB = AzToolsFramework::AssetBrowser; - // assumption: Double clicking an item selects it before telling us we double clicked it. + namespace AzAssetBrowser = AzToolsFramework::AssetBrowser; const auto& selectedAssets = m_ui->m_assetBrowserTableViewWidget->GetSelectedAssets(); - for (const AB::AssetBrowserEntry* entry : selectedAssets) + for (const AzAssetBrowser::AssetBrowserEntry* entry : selectedAssets) { AZ::Data::AssetId assetIdToOpen; AZStd::string fullFilePath; - if (const AB::ProductAssetBrowserEntry* productEntry = azrtti_cast(entry)) + if (const AzAssetBrowser::ProductAssetBrowserEntry* productEntry = azrtti_cast(entry)) { assetIdToOpen = productEntry->GetAssetId(); fullFilePath = entry->GetFullPath(); } - else if (const AB::SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry)) + else if (const AzAssetBrowser::SourceAssetBrowserEntry* sourceEntry = azrtti_cast(entry)) { // manufacture an empty AssetID with the source's UUID assetIdToOpen = AZ::Data::AssetId(sourceEntry->GetSourceUuid(), 0); @@ -292,8 +291,8 @@ void AzAssetBrowserWindow::DoubleClickedItemTableModel([[maybe_unused]] const QM bool handledBySomeone = false; if (assetIdToOpen.IsValid()) { - AB::AssetBrowserInteractionNotificationBus::Broadcast( - &AB::AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); + AzAssetBrowser::AssetBrowserInteractionNotificationBus::Broadcast( + &AzAssetBrowser::AssetBrowserInteractionNotifications::OpenAssetInAssociatedEditor, assetIdToOpen, handledBySomeone); } if (!handledBySomeone && !fullFilePath.empty()) From 0f90ccc0b4e78b57a07001a94f8ef219dac3fb7e Mon Sep 17 00:00:00 2001 From: antonmic Date: Fri, 4 Jun 2021 09:38:28 -0700 Subject: [PATCH 029/244] initial changes compiling --- .../DisplayMapperFullScreenPass.h | 2 +- .../Feature/DisplayMapper/DisplayMapperPass.h | 2 +- .../Atom/Feature/LuxCore/LuxCoreTexturePass.h | 2 +- .../Atom/Feature/LuxCore/RenderTexturePass.h | 2 +- .../CheckerboardColorResolvePass.cpp | 6 +- .../CheckerboardColorResolvePass.h | 2 +- .../Source/Checkerboard/CheckerboardPass.cpp | 4 +- .../Source/Checkerboard/CheckerboardPass.h | 2 +- .../CoreLights/CascadedShadowmapsPass.cpp | 8 +- .../CoreLights/CascadedShadowmapsPass.h | 2 +- .../DirectionalLightFeatureProcessor.cpp | 2 +- .../Source/CoreLights/LightCullingPass.cpp | 3 +- .../Code/Source/CoreLights/LightCullingPass.h | 3 +- .../Source/CoreLights/LightCullingRemap.cpp | 2 +- .../Source/CoreLights/LightCullingRemap.h | 2 +- .../LightCullingTilePreparePass.cpp | 25 ++-- .../CoreLights/LightCullingTilePreparePass.h | 3 +- .../CoreLights/ProjectedShadowmapsPass.cpp | 6 +- .../CoreLights/ProjectedShadowmapsPass.h | 2 +- .../Code/Source/CoreLights/ShadowmapPass.cpp | 4 +- .../Code/Source/CoreLights/ShadowmapPass.h | 2 +- .../DisplayMapperFullScreenPass.cpp | 2 +- .../DisplayMapper/DisplayMapperPass.cpp | 6 +- .../Common/Code/Source/ImGui/ImGuiPass.cpp | 4 +- .../Common/Code/Source/ImGui/ImGuiPass.h | 2 +- .../Source/LuxCore/LuxCoreTexturePass.cpp | 6 +- .../Code/Source/LuxCore/RenderTexturePass.cpp | 6 +- .../MorphTargets/MorphTargetComputePass.cpp | 2 +- .../MorphTargets/MorphTargetComputePass.h | 2 +- .../Source/PostProcessing/BloomBlurPass.cpp | 4 +- .../Source/PostProcessing/BloomBlurPass.h | 2 +- .../PostProcessing/BloomCompositePass.cpp | 4 +- .../PostProcessing/BloomCompositePass.h | 2 +- .../PostProcessing/BloomDownsamplePass.cpp | 4 +- .../PostProcessing/BloomDownsamplePass.h | 2 +- .../DepthOfFieldCopyFocusDepthToCpuPass.cpp | 2 +- .../DepthOfFieldCopyFocusDepthToCpuPass.h | 2 +- ...DepthOfFieldWriteFocusDepthFromGpuPass.cpp | 4 +- .../DepthOfFieldWriteFocusDepthFromGpuPass.h | 2 +- .../PostProcessing/EyeAdaptationPass.cpp | 2 +- .../Source/PostProcessing/EyeAdaptationPass.h | 2 +- .../LookModificationTransformPass.cpp | 4 +- .../LookModificationTransformPass.h | 2 +- .../LuminanceHistogramGeneratorPass.cpp | 2 +- .../LuminanceHistogramGeneratorPass.h | 2 +- .../Code/Source/PostProcessing/SsaoPasses.cpp | 4 +- .../Code/Source/PostProcessing/SsaoPasses.h | 2 +- .../RayTracingAccelerationStructurePass.cpp | 2 +- .../RayTracingAccelerationStructurePass.h | 2 +- .../ReflectionCopyFrameBufferPass.cpp | 4 +- .../ReflectionCopyFrameBufferPass.h | 2 +- .../ReflectionScreenSpaceBlurPass.cpp | 6 +- .../ReflectionScreenSpaceBlurPass.h | 2 +- .../ProjectedShadowFeatureProcessor.cpp | 2 +- .../Include/Atom/RPI.Public/Pass/CopyPass.h | 2 +- .../Atom/RPI.Public/Pass/MSAAResolvePass.h | 2 +- .../Include/Atom/RPI.Public/Pass/ParentPass.h | 5 +- .../Code/Include/Atom/RPI.Public/Pass/Pass.h | 50 ++++---- .../Atom/RPI.Public/Pass/PassDefines.h | 25 ++++ .../Include/Atom/RPI.Public/Pass/PassSystem.h | 21 ++-- .../RPI.Public/Pass/PassSystemInterface.h | 24 +++- .../Include/Atom/RPI.Public/Pass/RenderPass.h | 2 +- .../Pass/Specific/DownsampleMipChainPass.h | 2 +- .../Pass/Specific/EnvironmentCubeMapPass.h | 2 +- .../Pass/Specific/RenderToTexturePass.h | 2 +- .../RPI.Public/Pass/Specific/SelectorPass.h | 2 +- .../RPI.Public/Pass/Specific/SwapChainPass.h | 2 +- .../Code/Source/RPI.Public/Pass/CopyPass.cpp | 2 +- .../RPI.Public/Pass/MSAAResolvePass.cpp | 2 +- .../Source/RPI.Public/Pass/ParentPass.cpp | 25 ++-- .../RPI/Code/Source/RPI.Public/Pass/Pass.cpp | 107 +++++++++++------- .../Source/RPI.Public/Pass/PassSystem.cpp | 89 +++++++++++---- .../Source/RPI.Public/Pass/RenderPass.cpp | 2 +- .../Pass/Specific/DownsampleMipChainPass.cpp | 4 +- .../Pass/Specific/EnvironmentCubeMapPass.cpp | 6 +- .../Pass/Specific/RenderToTexturePass.cpp | 6 +- .../RPI.Public/Pass/Specific/SelectorPass.cpp | 6 +- .../Pass/Specific/SwapChainPass.cpp | 8 +- .../Code/Source/RPI.Public/RenderPipeline.cpp | 3 +- Gems/Atom/RPI/Code/Tests/Pass/PassTests.cpp | 14 +-- 80 files changed, 361 insertions(+), 238 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperFullScreenPass.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperFullScreenPass.h index 94e52d41b0..23c4cd1a0a 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperFullScreenPass.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperFullScreenPass.h @@ -42,7 +42,7 @@ namespace AZ void SetInputReferenceAttachmentName(const Name& attachmentName); // Pass behavior overrides - virtual void BuildAttachmentsInternal() override; + virtual void BuildInternal() override; protected: explicit DisplayMapperFullScreenPass(const RPI::PassDescriptor& descriptor); diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperPass.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperPass.h index 67d9eae9ae..15ada4dd94 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperPass.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/DisplayMapper/DisplayMapperPass.h @@ -76,7 +76,7 @@ namespace AZ DisplayMapperPass(const RPI::PassDescriptor& descriptor); // Pass behavior overrides - void BuildAttachmentsInternal() final; + void BuildInternal() final; void FrameBeginInternal(FramePrepareParams params) final; void FrameEndInternal() final; void CreateChildPassesInternal() final; diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h index 23e9c220b2..2ad2af3efd 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/LuxCoreTexturePass.h @@ -42,7 +42,7 @@ namespace AZ protected: // Pass behavior overrides void CreateChildPassesInternal() final; - void BuildAttachmentsInternal() final; + void BuildInternal() final; void FrameBeginInternal(FramePrepareParams params) final; private: diff --git a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/RenderTexturePass.h b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/RenderTexturePass.h index 5ae5008a92..cd148d3452 100644 --- a/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/RenderTexturePass.h +++ b/Gems/Atom/Feature/Common/Code/Include/Atom/Feature/LuxCore/RenderTexturePass.h @@ -46,7 +46,7 @@ namespace AZ private: - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void UpdataAttachment(); diff --git a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.cpp b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.cpp index 3ebb6b370c..a6c440cf39 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.cpp @@ -60,7 +60,7 @@ namespace AZ Base::FrameBeginInternal(params); } - void CheckerboardColorResolvePass::BuildAttachmentsInternal() + void CheckerboardColorResolvePass::BuildInternal() { // For each bound attachments they are the inputs from current frame. // We use them to get their owner CheckerboardPass then find the render targets from last frame @@ -99,7 +99,7 @@ namespace AZ // reset frame offset to 0 since attachments are rebuilt m_frameOffset = 0; - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } void CheckerboardColorResolvePass::CompileResources(const RHI::FrameGraphCompileContext& context) @@ -135,7 +135,7 @@ namespace AZ void CheckerboardColorResolvePass::FrameEndInternal() { // For the input slots for current frame, they always get updated when CheckerboardPass updates the render targets - // But for the input slots for previous frame, we need to manually update them since they were manually attached in BuildAttachmentsInternal() + // But for the input slots for previous frame, we need to manually update them since they were manually attached in BuildInternal() // // When pass attachment was built, CheckerboardPass creates two resources for each render target. // For example, diffuse_0 and diffuse_1 which diffuse_0 is for even frame and diffuse_1 is for odd frame. diff --git a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.h b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.h index 8cb15d5f49..93930e2bbc 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardColorResolvePass.h @@ -52,7 +52,7 @@ namespace AZ protected: // Pass overrides... void FrameBeginInternal(FramePrepareParams params) override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameEndInternal() override; // Scope producer functions... diff --git a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.cpp b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.cpp index 09c69dfe18..a781c460f5 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.cpp @@ -50,7 +50,7 @@ namespace AZ Base::FrameBeginInternal(params); } - void CheckerboardPass::BuildAttachmentsInternal() + void CheckerboardPass::BuildInternal() { Data::Instance pool = RPI::ImageSystemInterface::Get()->GetSystemAttachmentPool(); @@ -101,7 +101,7 @@ namespace AZ // reset frame offset to 0 since attachments are rebuilt m_frameOffset = 0; - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } diff --git a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.h b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.h index 3b905cc3db..02429bb837 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/Checkerboard/CheckerboardPass.h @@ -40,7 +40,7 @@ namespace AZ protected: // Pass overrides... void FrameBeginInternal(FramePrepareParams params); - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameEndInternal() override; private: diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp index d83201533c..4c7e69f2ae 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.cpp @@ -100,7 +100,7 @@ namespace AZ m_arraySize = arraySize; m_updateChildren = true; - QueueForBuildAttachments(); + QueueForBuild(); m_atlas.Initialize(); for (size_t cascadeIndex = 0; cascadeIndex < m_arraySize; ++cascadeIndex) @@ -149,7 +149,7 @@ namespace AZ return m_atlas; } - void CascadedShadowmapsPass::BuildAttachmentsInternal() + void CascadedShadowmapsPass::BuildInternal() { UpdateChildren(); @@ -159,7 +159,7 @@ namespace AZ } UpdateShadowmapImageSize(); - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } void CascadedShadowmapsPass::GetPipelineViewTags(RPI::SortedPipelineViewTags& outTags) const @@ -215,7 +215,7 @@ namespace AZ AZ_RPI_PASS_WARNING(child, "CascadedShadowmapsPass child Pass creation failed for %d", cascadeIndex); if (child) { - child->QueueForBuildAttachments(); + child->QueueForBuild(); AddChild(child); } } diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h index aa95e0af44..772be9466d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/CascadedShadowmapsPass.h @@ -53,7 +53,7 @@ namespace AZ explicit CascadedShadowmapsPass(const RPI::PassDescriptor& descriptor); // RPI::Pass overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void GetPipelineViewTags(RPI::SortedPipelineViewTags& outTags) const override; void GetViewDrawListInfo(RHI::DrawListMask& outDrawListMask, RPI::PassesByDrawList& outPassesByDrawList, const RPI::PipelineViewTag& viewTag) const override; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp index 9b40097716..cdbe431949 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/DirectionalLightFeatureProcessor.cpp @@ -1106,7 +1106,7 @@ namespace AZ { for (EsmShadowmapsPass* pass : it.second) { - pass->QueueForBuildAttachments(); + pass->QueueForBuild(); } } } diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.cpp index 987ed299b3..88a063b499 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.cpp @@ -163,7 +163,6 @@ namespace AZ void LightCullingPass::ResetInternal() { - m_initialized = false; m_tileDataIndex = -1; m_constantDataIndex.Reset(); @@ -260,7 +259,7 @@ namespace AZ return gridPixelSize; } - void LightCullingPass::BuildAttachmentsInternal() + void LightCullingPass::BuildInternal() { m_tileDataIndex = FindInputBinding(AZ::Name("TileLightData")); CreateLightList(); diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.h index d8699ea0c7..8080379716 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingPass.h @@ -50,7 +50,7 @@ namespace AZ // Pass behavior overrides... void ResetInternal()override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; // Scope producer functions... void CompileResources(const RHI::FrameGraphCompileContext& context) override; @@ -96,7 +96,6 @@ namespace AZ AZ::RHI::ShaderInputNameIndex m_constantDataIndex = "m_constantData"; - bool m_initialized = false; Data::Instance m_lightList; uint32_t m_tileDataIndex = -1; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.cpp index 42882cec6e..a12ba48751 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.cpp @@ -108,7 +108,7 @@ namespace AZ return -1; } - void LightCullingRemap::BuildAttachmentsInternal() + void LightCullingRemap::BuildInternal() { m_tileDataIndex = FindInputOutputBinding(AZ::Name("TileLightData")); m_tileDim = GetTileDataBufferResolution(); diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.h index 0738acd459..6d60f93a64 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingRemap.h @@ -55,7 +55,7 @@ namespace AZ // Pass behavior overrides... void ResetInternal()override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; // RHI::ScopeProducer overrides... void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp index 816ef25bc6..c144525cec 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp @@ -167,37 +167,36 @@ namespace AZ AZ_Assert(setOk, "LightCullingTilePreparePass::SetConstantData() - could not set constant data"); } - void LightCullingTilePreparePass::BuildAttachmentsInternal() + void LightCullingTilePreparePass::BuildInternal() { ChooseShaderVariant(); } - void LightCullingTilePreparePass::OnShaderReinitialized(const AZ::RPI::Shader&) + void LightCullingTilePreparePass::OnShaderReloaded() { LoadShader(); - if (!m_flags.m_queuedForBuildAttachment && !m_flags.m_isBuildingAttachments) + AZ_Assert(GetPassState() != RPI::PassState::Rendering, "LightCullingTilePreparePass: Trying to reload shader during rendering"); + if (GetPassState() == RPI::PassState::Initialized) { ChooseShaderVariant(); } } + + void LightCullingTilePreparePass::OnShaderReinitialized(const AZ::RPI::Shader&) + { + OnShaderReloaded(); + } + void LightCullingTilePreparePass::OnShaderAssetReinitialized(const Data::Asset&) { - LoadShader(); - if (!m_flags.m_queuedForBuildAttachment && !m_flags.m_isBuildingAttachments) - { - ChooseShaderVariant(); - } + OnShaderReloaded(); } void LightCullingTilePreparePass::OnShaderVariantReinitialized( const AZ::RPI::Shader&, const AZ::RPI::ShaderVariantId&, AZ::RPI::ShaderVariantStableId) { - LoadShader(); - if (!m_flags.m_queuedForBuildAttachment && !m_flags.m_isBuildingAttachments) - { - ChooseShaderVariant(); - } + OnShaderReloaded(); } } // namespace Render diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.h index efba105912..0febb66e3d 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.h @@ -50,7 +50,7 @@ namespace AZ LightCullingTilePreparePass(const RPI::PassDescriptor& descriptor); // Pass behavior overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; /////////////////////////////////////////////////////////////////// // ShaderReloadNotificationBus overrides... @@ -73,6 +73,7 @@ namespace AZ const AZ::RPI::ShaderVariant& CreateShaderVariant(); void CreatePipelineStateFromShaderVariant(const RPI::ShaderVariant& shaderVariant); void SetConstantData(); + void OnShaderReloaded(); AZ::RHI::ShaderInputNameIndex m_constantDataIndex = "m_constantData"; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.cpp index d77419fe8f..87cacbb345 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.cpp @@ -73,7 +73,7 @@ namespace AZ { m_sizes = sizes; m_updateChildren = true; - QueueForBuildAttachments(); + QueueForBuild(); m_atlas.Initialize(); for (const auto& it : m_sizes) @@ -156,7 +156,7 @@ namespace AZ return m_atlas; } - void ProjectedShadowmapsPass::BuildAttachmentsInternal() + void ProjectedShadowmapsPass::BuildInternal() { UpdateChildren(); @@ -177,7 +177,7 @@ namespace AZ imageDescriptor.m_size = RHI::Size(shadowmapWidth, shadowmapWidth, 1); imageDescriptor.m_arraySize = m_atlas.GetArraySliceCount(); - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } void ProjectedShadowmapsPass::GetPipelineViewTags(RPI::SortedPipelineViewTags& outTags) const diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h index 63640d22c6..f1963cc885 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ProjectedShadowmapsPass.h @@ -71,7 +71,7 @@ namespace AZ explicit ProjectedShadowmapsPass(const RPI::PassDescriptor& descriptor); // RPI::Pass overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void GetPipelineViewTags(RPI::SortedPipelineViewTags& outTags) const override; void GetViewDrawListInfo(RHI::DrawListMask& outDrawListMask, RPI::PassesByDrawList& outPassesByDrawList, const RPI::PipelineViewTag& viewTag) const override; diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.cpp index 087a73a94d..d31947da5a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.cpp @@ -107,7 +107,7 @@ namespace AZ m_scissorState = scissor; } - void ShadowmapPass::BuildAttachmentsInternal() + void ShadowmapPass::BuildInternal() { RPI::Ptr parentPass = GetParent(); if (!parentPass) @@ -135,7 +135,7 @@ namespace AZ action.m_loadAction = m_clearEnabled ? RHI::AttachmentLoadAction::Clear : RHI::AttachmentLoadAction::DontCare; binding.m_unifiedScopeDesc = RHI::UnifiedScopeAttachmentDescriptor(attachmentId, imageViewDescriptor, action); - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } } // namespace Render diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.h b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.h index 9c308dc4df..2814761a69 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/ShadowmapPass.h @@ -58,7 +58,7 @@ namespace AZ explicit ShadowmapPass(const RPI::PassDescriptor& descriptor); // RHI::Pass overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; uint16_t m_arraySlice = 0; bool m_clearEnabled = true; diff --git a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperFullScreenPass.cpp b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperFullScreenPass.cpp index ba83fabed3..096179d5b6 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperFullScreenPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperFullScreenPass.cpp @@ -34,7 +34,7 @@ namespace AZ { } - void DisplayMapperFullScreenPass::BuildAttachmentsInternal() + void DisplayMapperFullScreenPass::BuildInternal() { RPI::PassConnection inConnection; inConnection.m_localSlot = InputAttachmentName; diff --git a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp index 8ae790e12c..be3e05163a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp @@ -46,8 +46,6 @@ namespace AZ DisplayMapperPass::DisplayMapperPass(const RPI::PassDescriptor& descriptor) : RPI::ParentPass(descriptor) { - m_flags.m_alreadyCreated = false; - AzFramework::NativeWindowHandle windowHandle = nullptr; AzFramework::WindowSystemRequestBus::BroadcastResult( windowHandle, @@ -137,7 +135,7 @@ namespace AZ } } - void DisplayMapperPass::BuildAttachmentsInternal() + void DisplayMapperPass::BuildInternal() { const Name outputName = Name{ "Output" }; Name inputPass = Name{ "Parent" }; @@ -187,7 +185,7 @@ namespace AZ m_swapChainAttachmentBinding = FindAttachmentBinding(Name("SwapChainOutput")); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void DisplayMapperPass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp index a29354f723..fe5d9a16fe 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp @@ -519,13 +519,13 @@ namespace AZ io.Fonts->TexID = reinterpret_cast(m_fontAtlas.get()); } - void ImGuiPass::OnBuildAttachmentsFinishedInternal() + void ImGuiPass::OnBuildFinishedInternal() { // Set output format and finalize pipeline state m_pipelineState->SetOutputFromPass(this); m_pipelineState->Finalize(); - Base::OnBuildAttachmentsFinishedInternal(); + Base::OnBuildFinishedInternal(); } void ImGuiPass::SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) diff --git a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h index c8be0d7ee6..30449820bb 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h @@ -94,7 +94,7 @@ namespace AZ explicit ImGuiPass(const RPI::PassDescriptor& descriptor); // Pass Behaviour Overrides... - void OnBuildAttachmentsFinishedInternal() override; + void OnBuildFinishedInternal() override; void FrameBeginInternal(FramePrepareParams params) override; // Scope producer functions diff --git a/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp b/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp index 9a921205ab..3c7233e747 100644 --- a/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp @@ -28,8 +28,6 @@ namespace AZ LuxCoreTexturePass::LuxCoreTexturePass(const RPI::PassDescriptor& descriptor) : ParentPass(descriptor) { - m_flags.m_alreadyCreated = false; - RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get(); // Create render target pass @@ -61,9 +59,9 @@ namespace AZ AddChild(m_renderTargetPass); } - void LuxCoreTexturePass::BuildAttachmentsInternal() + void LuxCoreTexturePass::BuildInternal() { - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void LuxCoreTexturePass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/LuxCore/RenderTexturePass.cpp b/Gems/Atom/Feature/Common/Code/Source/LuxCore/RenderTexturePass.cpp index 0782e12278..aa991e270a 100644 --- a/Gems/Atom/Feature/Common/Code/Source/LuxCore/RenderTexturePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/LuxCore/RenderTexturePass.cpp @@ -38,13 +38,13 @@ namespace AZ m_attachmentSize = image->GetRHIImage()->GetDescriptor().m_size; m_attachmentFormat = format; m_shaderResourceGroup->SetImage(m_textureIndex, image); - QueueForBuildAttachments(); + QueueForBuild(); } - void RenderTexturePass::BuildAttachmentsInternal() + void RenderTexturePass::BuildInternal() { UpdataAttachment(); - FullscreenTrianglePass::BuildAttachmentsInternal(); + FullscreenTrianglePass::BuildInternal(); } void RenderTexturePass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.cpp b/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.cpp index 1bb537ecef..42acd5c447 100644 --- a/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.cpp @@ -44,7 +44,7 @@ namespace AZ m_skinnedMeshFeatureProcessor = skinnedMeshFeatureProcessor; } - void MorphTargetComputePass::BuildAttachmentsInternal() + void MorphTargetComputePass::BuildInternal() { // The same buffer that skinning writes to is used to manage the computed vertex deltas that are passed from the // morph target pass to the skinning pass. This simplifies things by only requiring one class to manage the memory diff --git a/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.h b/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.h index 61fa485fbc..d346edd908 100644 --- a/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/MorphTargets/MorphTargetComputePass.h @@ -37,7 +37,7 @@ namespace AZ void SetFeatureProcessor(SkinnedMeshFeatureProcessor* m_skinnedMeshFeatureProcessor); private: - void BuildAttachmentsInternal() override; + void BuildInternal() override; void BuildCommandListInternal(const RHI::FrameGraphExecuteContext& context) override; SkinnedMeshFeatureProcessor* m_skinnedMeshFeatureProcessor = nullptr; diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp index 1427adeb08..af95a76718 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.cpp @@ -252,10 +252,10 @@ namespace AZ } } - void BloomBlurPass::BuildAttachmentsInternal() + void BloomBlurPass::BuildInternal() { BuildChildPasses(); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void BloomBlurPass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.h index e87d831382..4c65368506 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomBlurPass.h @@ -47,7 +47,7 @@ namespace AZ BloomBlurPass(const RPI::PassDescriptor& descriptor); // Pass behaviour overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void GetInputInfo(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.cpp index fbb020cbf3..810353aab1 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.cpp @@ -56,10 +56,10 @@ namespace AZ m_passData = *passData; } - void BloomCompositePass::BuildAttachmentsInternal() + void BloomCompositePass::BuildInternal() { BuildChildPasses(); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void BloomCompositePass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.h index 86d897ae7d..a19947e1d0 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomCompositePass.h @@ -44,7 +44,7 @@ namespace AZ BloomCompositePass(const RPI::PassDescriptor& descriptor); // Pass behaviour overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void GetAttachmentInfo(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.cpp index 647177a1ce..63779beb16 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.cpp @@ -74,10 +74,10 @@ namespace AZ AddAttachmentBinding(outBinding); } - ComputePass::BuildAttachmentsInternal(); + ComputePass::BuildInternal(); } - void BloomDownsamplePass::BuildAttachmentsInternal() + void BloomDownsamplePass::BuildInternal() { BuildOutAttachmentBinding(); } diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.h index 824f703417..3eb0ac8740 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/BloomDownsamplePass.h @@ -37,7 +37,7 @@ namespace AZ BloomDownsamplePass(const RPI::PassDescriptor& descriptor); // Pass Behaviour Overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void BuildOutAttachmentBinding(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.cpp index d64bba1957..00d5ad93c3 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.cpp @@ -52,7 +52,7 @@ namespace AZ return depth; } - void DepthOfFieldCopyFocusDepthToCpuPass::BuildAttachmentsInternal() + void DepthOfFieldCopyFocusDepthToCpuPass::BuildInternal() { SetScopeId(RHI::ScopeId(GetPathName())); } diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.h index 64301b6e0c..7e8d041e96 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldCopyFocusDepthToCpuPass.h @@ -48,7 +48,7 @@ namespace AZ void BuildCommandList(const RHI::FrameGraphExecuteContext& context) override; // Pass overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; RPI::Ptr m_bufferRef; diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.cpp index e7ac891198..4aaf936426 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.cpp @@ -62,9 +62,9 @@ namespace AZ m_bufferRef = bufferRef; } - void DepthOfFieldWriteFocusDepthFromGpuPass::BuildAttachmentsInternal() + void DepthOfFieldWriteFocusDepthFromGpuPass::BuildInternal() { - AZ_Assert(m_bufferRef != nullptr, "%s has a null buffer when calling BuildAttachmentsInternal.", GetPathName().GetCStr()); + AZ_Assert(m_bufferRef != nullptr, "%s has a null buffer when calling BuildInternal.", GetPathName().GetCStr()); AttachBufferToSlot(Name("DofDepthInputOutput"), m_bufferRef); } diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.h index 592ab64c01..881ef9df94 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldWriteFocusDepthFromGpuPass.h @@ -51,7 +51,7 @@ namespace AZ void CompileResources(const RHI::FrameGraphCompileContext& context) override; // Pass overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; }; } // namespace Render } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp index e7d4c47f02..879abf6418 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.cpp @@ -62,7 +62,7 @@ namespace AZ m_buffer = RPI::BufferSystemInterface::Get()->CreateBufferFromCommonPool(desc); } - void EyeAdaptationPass::BuildAttachmentsInternal() + void EyeAdaptationPass::BuildInternal() { if (!m_buffer) { diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h index cef168a122..d53569a9f9 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/EyeAdaptationPass.h @@ -58,7 +58,7 @@ namespace AZ float m_exposureValue = 1.0f; }; - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.cpp index 98c842042b..9f792370fc 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.cpp @@ -36,10 +36,10 @@ namespace AZ &AzFramework::WindowSystemRequestBus::Events::GetDefaultWindowHandle); } - void LookModificationPass::BuildAttachmentsInternal() + void LookModificationPass::BuildInternal() { m_swapChainAttachmentBinding = FindAttachmentBinding(Name("SwapChainOutput")); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void LookModificationPass::FrameBeginInternal([[maybe_unused]] FramePrepareParams params) diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.h index 5102015e82..8203530918 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LookModificationTransformPass.h @@ -52,7 +52,7 @@ namespace AZ //! Pass overrides ... void FrameBeginInternal(FramePrepareParams params) override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; private: const RPI::PassAttachmentBinding* m_swapChainAttachmentBinding = nullptr; diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp index 758c21bc4e..2fe8b01089 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.cpp @@ -86,7 +86,7 @@ namespace AZ return colorBuffer->m_descriptor.m_image.m_size; } - void LuminanceHistogramGeneratorPass::BuildAttachmentsInternal() + void LuminanceHistogramGeneratorPass::BuildInternal() { CreateHistogramBuffer(); AttachHistogramBuffer(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.h index ee8a10fe16..9691daab6f 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/LuminanceHistogramGeneratorPass.h @@ -42,7 +42,7 @@ namespace AZ protected: LuminanceHistogramGeneratorPass(const RPI::PassDescriptor& descriptor); - virtual void BuildAttachmentsInternal() override; + virtual void BuildInternal() override; void CreateHistogramBuffer(); void AttachHistogramBuffer(); AZ::RHI::Size GetColorBufferResolution(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp index 68472115ce..1aa16a4417 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp @@ -41,9 +41,9 @@ namespace AZ return ParentPass::IsEnabled(); } - void SsaoParentPass::OnBuildAttachmentsFinishedInternal() + void SsaoParentPass::OnBuildFinishedInternal() { - ParentPass::OnBuildAttachmentsFinishedInternal(); + ParentPass::OnBuildFinishedInternal(); m_blurParentPass = FindChildPass(Name("SsaoBlur"))->AsParent(); AZ_Assert(m_blurParentPass, "[SsaoParentPass] Could not retrieve parent blur pass."); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h index 9abd04e306..20aa554414 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h @@ -36,7 +36,7 @@ namespace AZ protected: // Behavior functions override... - void OnBuildAttachmentsFinishedInternal() override; + void OnBuildFinishedInternal() override; void FrameBeginInternal(FramePrepareParams params) override; private: diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp index 92cd41b4e8..f1fcd2de35 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.cpp @@ -42,7 +42,7 @@ namespace AZ } } - void RayTracingAccelerationStructurePass::BuildAttachmentsInternal() + void RayTracingAccelerationStructurePass::BuildInternal() { SetScopeId(RHI::ScopeId(GetPathName())); } diff --git a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.h b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.h index 6d90d752e3..127669301e 100644 --- a/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.h +++ b/Gems/Atom/Feature/Common/Code/Source/RayTracing/RayTracingAccelerationStructurePass.h @@ -44,7 +44,7 @@ namespace AZ void BuildCommandList(const RHI::FrameGraphExecuteContext& context) override; // Pass overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; // buffer view descriptor for the TLAS diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.cpp index 5137b66bf9..9a9064bdf7 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.cpp @@ -30,7 +30,7 @@ namespace AZ { } - void ReflectionCopyFrameBufferPass::BuildAttachmentsInternal() + void ReflectionCopyFrameBufferPass::BuildInternal() { RPI::PassHierarchyFilter passFilter(AZ::Name("ReflectionScreenSpaceBlurPass")); const AZStd::vector& passes = RPI::PassSystemInterface::Get()->FindPasses(passFilter); @@ -43,7 +43,7 @@ namespace AZ AttachImageToSlot(outputBinding.m_name, frameBufferAttachment); } - FullscreenTrianglePass::BuildAttachmentsInternal(); + FullscreenTrianglePass::BuildInternal(); } } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.h b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.h index 2a2fecea40..f0b8c80d72 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionCopyFrameBufferPass.h @@ -37,7 +37,7 @@ namespace AZ explicit ReflectionCopyFrameBufferPass(const RPI::PassDescriptor& descriptor); // Pass Overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; }; } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp index 883686ac5b..680d117b98 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp @@ -113,7 +113,7 @@ namespace AZ } } - void ReflectionScreenSpaceBlurPass::BuildAttachmentsInternal() + void ReflectionScreenSpaceBlurPass::BuildInternal() { RemoveChildren(); @@ -166,9 +166,9 @@ namespace AZ // create child passes, one vertical and one horizontal blur per mip level CreateChildPasses(mipLevels - 1); - // call ParentPass::BuildAttachmentsInternal() first to configure the slots and auto-add the empty bindings, + // call ParentPass::BuildInternal() first to configure the slots and auto-add the empty bindings, // then we will assign attachments to the bindings - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); // setup attachment bindings on vertical blur child passes uint32_t attachmentIndex = 0; diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h index 53f4026aef..f344fc8e9b 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h @@ -44,7 +44,7 @@ namespace AZ // Pass Overrides... void ResetInternal() override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; AZStd::vector> m_verticalBlurChildPasses; AZStd::vector> m_horizontalBlurChildPasses; diff --git a/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp b/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp index 216a126953..8484fdddc2 100644 --- a/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/Shadows/ProjectedShadowFeatureProcessor.cpp @@ -526,7 +526,7 @@ namespace AZ::Render for (EsmShadowmapsPass* esmPass : m_esmShadowmapsPasses) { - esmPass->QueueForBuildAttachments(); + esmPass->QueueForBuild(); } for (ProjectedShadowmapsPass* shadowPass : m_projectedShadowmapsPasses) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/CopyPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/CopyPass.h index ede14564cd..fd5cdabc83 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/CopyPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/CopyPass.h @@ -49,7 +49,7 @@ namespace AZ void CopyImageToBuffer(const RHI::FrameGraphCompileContext& context); // Pass behavior overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; // Scope producer functions... void SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) override; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h index 91ae1536c3..71776982b3 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/MSAAResolvePass.h @@ -40,7 +40,7 @@ namespace AZ MSAAResolvePass(const PassDescriptor& descriptor); // Pass behavior overrides... - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; private: diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h index b4f63a7099..0e1e12e620 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h @@ -109,8 +109,9 @@ namespace AZ // --- Pass Behaviour Overrides --- void ResetInternal() override; - void BuildAttachmentsInternal() override; - void OnBuildAttachmentsFinishedInternal() override; + void BuildInternal() override; + void OnBuildFinishedInternal() override; + void InitializeInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void FrameEndInternal() override; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h index 1cba71ae7e..ee7f850d27 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h @@ -80,7 +80,7 @@ namespace AZ //! ending with 'Internal' to define the behavior of your passes. These virtual are recursively //! called in Preorder order throughout the pass tree. Only FramePrepare and FrameEnd are //! guaranteed to be called per frame. The other override-able functions are called as needed - //! when scheduled with the PassSystem. See QueueForBuildAttachments and QueueForRemoval. + //! when scheduled with the PassSystem. See QueueForBuild and QueueForRemoval. //! //! Passes are created by the PassFactory. They can be created using either Pass Name, //! a PassTemplate, or a PassRequest. To register your pass class with the PassFactory, @@ -153,11 +153,14 @@ namespace AZ // --- Utility functions --- - //! Queues the pass to have BuildAttachments() called by the PassSystem on frame update - void QueueForBuildAttachments(); + //! Queues the pass to have Build() called by the PassSystem on frame update + void QueueForBuild(); //! Queues the pass to have RemoveFromParent() called by the PassSystem on frame update - void QueueForRemoval(bool needsDeletion = false); + void QueueForRemoval(); + + //! Queues the pass to have Initialize() called by the PassSystem on frame update + void QueueForInitialization(); //! Adds an attachment binding to the list of this Pass' attachment bindings void AddAttachmentBinding(PassAttachmentBinding attachmentBinding); @@ -173,8 +176,8 @@ namespace AZ //! Attach an external buffer resource as attachment to specified slot //! The buffer will be added as a pass attachment then attach to the pass slot - //! Note: the pass attachment and binding will be removed after the general BuildAttachments call. - //! you can add this call in pass' BuildAttachmentsInternal so it will be added whenever attachments get rebuilt + //! Note: the pass attachment and binding will be removed after the general Build call. + //! you can add this call in pass' BuildInternal so it will be added whenever attachments get rebuilt void AttachBufferToSlot(AZStd::string_view slot, Data::Instance buffer); void AttachBufferToSlot(const Name& slot, Data::Instance buffer); void AttachImageToSlot(const Name& slot, Data::Instance image); @@ -256,6 +259,8 @@ namespace AZ //! Returns pointer to the parent pass ParentPass* GetParent() const; + PassState GetPassState() const; + protected: explicit Pass(const PassDescriptor& descriptor); @@ -309,18 +314,23 @@ namespace AZ // customize it's behavior, hence why these functions are called the pass behavior functions. // Resets everything in the pass (like Attachments). - // Called from PassSystem when pass is QueueForBuildAttachments. + // Called from PassSystem when pass is QueueForBuild. void Reset(); virtual void ResetInternal() { } // Builds and sets up any attachments and input/output connections the pass needs. - // Called from PassSystem when pass is QueueForBuildAttachments. - void BuildAttachments(); - virtual void BuildAttachmentsInternal() { } + // Called from PassSystem when pass is QueueForBuild. + void Build(); + virtual void BuildInternal() { } // Called after the pass build phase has finished. Allows passes to reset build flags. - void OnBuildAttachmentsFinished(); - virtual void OnBuildAttachmentsFinishedInternal() { }; + void OnBuildFinished(); + virtual void OnBuildFinishedInternal() { }; + + // Allows for additional pass initialization between building and rendering + // Can be queued independently of Build so as to only invoke Initialize without Build + void Initialize(); + virtual void InitializeInternal() { }; // The Pass's 'Render' function. Called every frame, here the pass sets up it's rendering logic with // the FrameGraphBuilder. This is where your derived pass needs to call ImportScopeProducer on @@ -379,20 +389,16 @@ namespace AZ struct { uint64_t m_createdByPassRequest : 1; - uint64_t m_initialized : 1; uint64_t m_enabled : 1; uint64_t m_parentEnabled : 1; - uint64_t m_alreadyCreated : 1; - uint64_t m_alreadyReset : 1; - uint64_t m_alreadyPrepared : 1; + + uint64_t m_initialized : 1; + uint64_t m_partOfHierarchy : 1; uint64_t m_hasDrawListTag : 1; uint64_t m_hasPipelineViewTag : 1; - uint64_t m_queuedForBuildAttachment : 1; uint64_t m_timestampQueryEnabled : 1; uint64_t m_pipelineStatisticsQueryEnabled : 1; - uint64_t m_isBuildingAttachments : 1; - uint64_t m_isRendering : 1; }; uint64_t m_allFlags = 0; }; @@ -510,6 +516,12 @@ namespace AZ // Depth of the tree hierarchy this pass is at. // Example: Root would be depth 0, Root.Ssao.Downsample depth 2 uint32_t m_treeDepth = 0; + + // Used to track what phase of build/execution the pass is in + PassState m_state = PassState::Uninitialized; + + // Used to track what phases of build/initialization the pass is queued for + PassQueueState m_queueState = PassQueueState::NoQueue; }; //! Struct used to return results from Pass hierarchy validation diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h index d536104768..7c55944603 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h @@ -21,3 +21,28 @@ // Set this to 1 locally on your machine to facilitate pass debugging and get extra information // about passes in the output window. DO NOT SUBMIT with value set to 1 #define AZ_RPI_ENABLE_PASS_DEBUGGING 0 + +namespace AZ +{ + namespace RPI + { + enum class PassState : u8 + { + Uninitialized, + Queued, + Resetting, + Building, + Initializing, + Initialized, + Rendering + }; + + enum class PassQueueState : u8 + { + NoQueue, + QueuedForRemoval, + QueuedForBuild, + QueuedForInitialization, + }; + } +} diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystem.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystem.h index fd30f4f406..534bf211dd 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystem.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystem.h @@ -73,12 +73,12 @@ namespace AZ bool LoadPassTemplateMappings(const AZStd::string& templateMappingPath) override; void WriteTemplateToFile(const PassTemplate& passTemplate, AZStd::string_view assetFilePath) override; void DebugPrintPassHierarchy() override; - bool IsBuilding() const override; bool IsHotReloading() const override; void SetHotReloading(bool hotReloading) override; void SetTargetedPassDebuggingName(const AZ::Name& targetPassName) override; const AZ::Name& GetTargetedPassDebuggingName() const override; void ConnectEvent(OnReadyLoadTemplatesEvent::Handler& handler) override; + PassSystemState GetState() const override; // PassSystemInterface factory related functions... void AddPassCreator(Name className, PassCreator createFunction) override; @@ -103,8 +103,11 @@ namespace AZ // Returns the root of the pass tree hierarchy const Ptr& GetRootPass() override; - // Calls BuildAttachments() on passes queued in m_buildAttachmentsList - void BuildPassAttachments(); + // Calls Build() on passes queued in m_buildPassList + void BuildPasses(); + + // Calls Initialize() on passes queued in m_initializePassList + void InitializePasses(); // Validates Pass Hierarchy after building void Validate(); @@ -113,13 +116,15 @@ namespace AZ void RemovePasses(); // Functions for queuing passes in the lists below - void QueueForBuildAttachments(Pass* pass) override; + void QueueForBuild(Pass* pass) override; void QueueForRemoval(Pass* pass) override; + void QueueForInitialization(Pass* pass) override; // Lists for queuing passes for various function calls // Name of the list reflects the pass function it will call - AZStd::vector< Ptr > m_buildAttachmentsList; + AZStd::vector< Ptr > m_buildPassList; AZStd::vector< Ptr > m_removePassList; + AZStd::vector< Ptr > m_initializePassList; // Library of pass descriptors that can be instantiated through data driven pass requests PassLibrary m_passLibrary; @@ -133,9 +138,6 @@ namespace AZ // Whether the Pass Hierarchy changed bool m_passHierarchyChanged = true; - // Whether the Pass System is currently in it's building phase - bool m_isBuilding = false; - // Whether the Pass System is currently hot reloading passes bool m_isHotReloading = false; @@ -147,6 +149,9 @@ namespace AZ // Events OnReadyLoadTemplatesEvent m_loadTemplatesEvent; + + // Used to track what phase of execution the pass system is in + PassSystemState m_state = PassSystemState::Unitialized; }; } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystemInterface.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystemInterface.h index 1224bf9545..788d00c8eb 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystemInterface.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassSystemInterface.h @@ -40,6 +40,18 @@ namespace AZ using PassCreator = AZStd::function(const PassDescriptor& descriptor)>; + enum class PassSystemState : u32 + { + Unitialized, + Idle, + RemovingPasses, + Building, + Initializing, + Validating, + Rendering, + FrameEnd, + }; + class PassSystemInterface { friend class Pass; @@ -77,9 +89,6 @@ namespace AZ //! Prints the entire pass hierarchy from the root virtual void DebugPrintPassHierarchy() = 0; - //! Returns whether the Pass System is currently in it's build phase - virtual bool IsBuilding() const = 0; - //! Returns whether the Pass System is currently hot reloading virtual bool IsHotReloading() const = 0; @@ -157,15 +166,20 @@ namespace AZ //! The handler can add new pass templates or load pass template mappings from assets virtual void ConnectEvent(OnReadyLoadTemplatesEvent::Handler& handler) = 0; + virtual PassSystemState GetState() const = 0; + private: // These functions are only meant to be used by the Pass class - // Schedules a pass to have it's BuildAttachments() function called during frame update - virtual void QueueForBuildAttachments(Pass* pass) = 0; + // Schedules a pass to have it's Build() function called during frame update + virtual void QueueForBuild(Pass* pass) = 0; // Schedules a pass to be deleted during frame update virtual void QueueForRemoval(Pass* pass) = 0; + // Schedules a pass to be initialized during frame update + virtual void QueueForInitialization(Pass* pass) = 0; + //! Registers the pass with the pass library. Called in the Pass constructor. virtual void RegisterPass(Pass* pass) = 0; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h index 5cd917e841..5f222d8bba 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h @@ -96,7 +96,7 @@ namespace AZ void BindPassSrg(const RHI::FrameGraphCompileContext& context, Data::Instance& shaderResourceGroup); // Pass behavior overrides... - void OnBuildAttachmentsFinishedInternal() override; + void OnBuildFinishedInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void FrameEndInternal() override; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h index 71c1fe4c49..eb4c4ed0aa 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/DownsampleMipChainPass.h @@ -46,7 +46,7 @@ namespace AZ // Pass Behaviour Overrides... void ResetInternal() override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; private: diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h index 293a750f38..235871df83 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.h @@ -61,7 +61,7 @@ namespace AZ // Pass overrides void CreateChildPassesInternal() override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void FrameEndInternal() override; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/RenderToTexturePass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/RenderToTexturePass.h index c8daab8ef8..c86203b79b 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/RenderToTexturePass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/RenderToTexturePass.h @@ -47,7 +47,7 @@ namespace AZ protected: // Pass behavior overrides - void BuildAttachmentsInternal() override; + void BuildInternal() override; void FrameBeginInternal(FramePrepareParams params) override; // Function to be called when output size changed diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SelectorPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SelectorPass.h index fe0ce231eb..2d876c6040 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SelectorPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SelectorPass.h @@ -49,7 +49,7 @@ namespace AZ SelectorPass(const PassDescriptor& descriptor); // Pass behavior overrides - void BuildAttachmentsInternal() final; + void BuildInternal() final; // the input slot index each output slot connect to AZStd::vector m_connections; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SwapChainPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SwapChainPass.h index 9aa00c99c2..7eac0d366d 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SwapChainPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Specific/SwapChainPass.h @@ -64,7 +64,7 @@ namespace AZ protected: // Pass behavior overrides void CreateChildPassesInternal() override final; - void BuildAttachmentsInternal() override final; + void BuildInternal() override final; void FrameBeginInternal(FramePrepareParams params) override final; // WindowNotificationBus::Handler overrides ... diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/CopyPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/CopyPass.cpp index 4a6c883584..9648a47fd6 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/CopyPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/CopyPass.cpp @@ -74,7 +74,7 @@ namespace AZ // --- Pass behavior overrides --- - void CopyPass::BuildAttachmentsInternal() + void CopyPass::BuildInternal() { AZ_Assert(GetInputCount() == 1 && GetOutputCount() == 1, "CopyPass has %d inputs and %d outputs. It should have exactly one of each.", diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp index c889f367b7..e457cb4992 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/MSAAResolvePass.cpp @@ -38,7 +38,7 @@ namespace AZ { } - void MSAAResolvePass::BuildAttachmentsInternal() + void MSAAResolvePass::BuildInternal() { AZ_Assert(GetOutputCount() != 0, "MSAAResolvePass %s has no outputs to render to.", GetPathName().GetCStr()); } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index 106ef82bf1..7244510fbd 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -59,7 +59,7 @@ namespace AZ child->m_parent = this; child->OnHierarchyChange(); - QueueForBuildAttachments(); + QueueForBuild(); // Notify pipeline if (m_pipeline) @@ -248,13 +248,6 @@ namespace AZ void ParentPass::CreateChildPasses() { - // Flag prevents the function from executing multiple times a frame. Can happen - // as pass system has a list of passes for which it needs to call this function. - if (m_flags.m_alreadyCreated) - { - return; - } - m_flags.m_alreadyCreated = true; RemoveChildren(); CreatePassesFromTemplate(); CreateChildPassesInternal(); @@ -277,19 +270,27 @@ namespace AZ } } - void ParentPass::BuildAttachmentsInternal() + void ParentPass::BuildInternal() { for (const Ptr& child : m_children) { - child->BuildAttachments(); + child->Build(); } } - void ParentPass::OnBuildAttachmentsFinishedInternal() + void ParentPass::OnBuildFinishedInternal() { for (const Ptr& child : m_children) { - child->OnBuildAttachmentsFinished(); + child->OnBuildFinished(); + } + } + + void ParentPass::InitializeInternal() + { + for (const Ptr& child : m_children) + { + child->Initialize(); } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp index 8d613eb2bb..da9022b655 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp @@ -71,7 +71,7 @@ namespace AZ } PassSystemInterface::Get()->RegisterPass(this); - QueueForBuildAttachments(); + QueueForBuild(); } Pass::~Pass() @@ -162,6 +162,11 @@ namespace AZ // --- Getters & Setters --- + PassState Pass::GetPassState() const + { + return m_state; + } + ParentPass* Pass::GetParent() const { return m_parent; @@ -350,28 +355,49 @@ namespace AZ // --- Queuing functions with PassSystem --- - void Pass::QueueForBuildAttachments() + void Pass::QueueForBuild() { // Don't queue if we're in building phase - if (!PassSystemInterface::Get()->IsBuilding()) + if (PassSystemInterface::Get()->GetState() != PassSystemState::Building && + (m_queueState == PassQueueState::NoQueue || m_queueState == PassQueueState::QueuedForInitialization)) { - // m_queuedForBuildAttachment makes sure the pass only be queue for once - if (!m_flags.m_queuedForBuildAttachment) - { - PassSystemInterface::Get()->QueueForBuildAttachments(this); - m_flags.m_queuedForBuildAttachment = true; + PassSystemInterface::Get()->QueueForBuild(this); + m_queueState = PassQueueState::QueuedForBuild; - // Set these two flags to false since when queue build attachments request, they should all be already be false except one use - // case that the pass system processed all queued requests when active a scene. - m_flags.m_alreadyPrepared = false; - m_flags.m_alreadyReset = false; + if (m_state != PassState::Rendering) + { + m_state = PassState::Queued; } } } - void Pass::QueueForRemoval([[maybe_unused]] bool needsDeletion) + void Pass::QueueForInitialization() { - PassSystemInterface::Get()->QueueForRemoval(this); + // Don't queue if we're in initialization phase + if (PassSystemInterface::Get()->GetState() != PassSystemState::Initializing && m_queueState == PassQueueState::NoQueue) + { + PassSystemInterface::Get()->QueueForInitialization(this); + m_queueState = PassQueueState::QueuedForInitialization; + + if(m_state != PassState::Rendering) + { + m_state = PassState::Queued; + } + } + } + + void Pass::QueueForRemoval() + { + if (m_queueState != PassQueueState::QueuedForRemoval) + { + PassSystemInterface::Get()->QueueForRemoval(this); + m_queueState = PassQueueState::QueuedForRemoval; + + if (m_state != PassState::Rendering) + { + m_state = PassState::Queued; + } + } } // --- PassTemplate related functions --- @@ -990,7 +1016,7 @@ namespace AZ { Ptr targetAttachment = nullptr; - if (!m_flags.m_isBuildingAttachments && !IsEnabled() && binding.m_slotType == PassSlotType::Output && binding.m_fallbackBinding) + if (m_state != PassState::Building && !IsEnabled() && binding.m_slotType == PassSlotType::Output && binding.m_fallbackBinding) { targetAttachment = binding.m_fallbackBinding->m_attachment; } @@ -1037,13 +1063,11 @@ namespace AZ void Pass::Reset() { - // Flag prevents the function from executing multiple times a frame. Can happen - // as pass system has a list of passes for which it needs to call this function. - if (m_flags.m_alreadyReset) + if (m_queueState != PassQueueState::QueuedForBuild || m_state != PassState::Queued) { return; } - m_flags.m_alreadyReset = true; + m_state = PassState::Resetting; // Store references to imported attachments to underlying images and buffers aren't deleted during attachment building StoreImportedAttachmentReferences(); @@ -1060,18 +1084,13 @@ namespace AZ ResetInternal(); } - void Pass::BuildAttachments() + void Pass::Build() { - m_flags.m_queuedForBuildAttachment = false; - - // Flag prevents the function from executing multiple times a frame. Can happen - // as pass system has a list of passes for which it needs to call this function. - if (m_flags.m_alreadyPrepared) + if (m_queueState != PassQueueState::QueuedForBuild || m_state != PassState::Resetting) { return; } - m_flags.m_alreadyPrepared = true; - m_flags.m_isBuildingAttachments = true; + m_state = PassState::Building; AZ_RPI_BREAK_ON_TARGET_PASS; @@ -1084,7 +1103,7 @@ namespace AZ SetupInputsFromTemplate(); // Custom pass behavior - BuildAttachmentsInternal(); + BuildInternal(); // Outputs SetupOutputsFromTemplate(); @@ -1095,21 +1114,29 @@ namespace AZ UpdateOwnedAttachments(); UpdateAttachmentUsageIndices(); - m_flags.m_isBuildingAttachments = false; + // Queue for Initialization + m_queueState = PassQueueState::NoQueue; + QueueForInitialization(); } - void Pass::OnBuildAttachmentsFinished() + void Pass::OnBuildFinished() { AZ_RPI_BREAK_ON_TARGET_PASS; - // These flags are to prevent a pass from being built multiple times. - // We reset them after each build phase. - m_flags.m_alreadyCreated = false; - m_flags.m_alreadyPrepared = false; - m_flags.m_alreadyReset = false; - m_flags.m_queuedForBuildAttachment = false; m_importedAttachmentStore.clear(); - OnBuildAttachmentsFinishedInternal(); + OnBuildFinishedInternal(); + } + + void Pass::Initialize() + { + if (m_queueState != PassQueueState::QueuedForInitialization || m_state != PassState::Queued) + { + return; + } + + m_state = PassState::Initializing; + InitializeInternal(); + m_state = PassState::Initialized; } void Pass::Validate(PassValidationResults& validationResults) @@ -1165,7 +1192,7 @@ namespace AZ UpdateConnectedBindings(); return; } - m_flags.m_isRendering = true; + m_state = PassState::Rendering; UpdateConnectedBindings(); UpdateOwnedAttachments(); @@ -1180,10 +1207,10 @@ namespace AZ void Pass::FrameEnd() { - if (m_flags.m_isRendering) + if (m_state == PassState::Rendering) { FrameEndInternal(); - m_flags.m_isRendering = false; + m_state = (m_queueState == PassQueueState::NoQueue) ? PassState::Initialized : PassState::Queued; } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index 448c28f202..3dabd88fff 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -93,11 +93,15 @@ namespace AZ void PassSystem::Init() { + m_state = PassSystemState::Initializing; + Interface::Register(this); m_passLibrary.Init(); m_passFactory.Init(&m_passLibrary); m_rootPass = CreatePass(Name{"Root"}); m_rootPass->m_flags.m_partOfHierarchy = true; + + m_state = PassSystemState::Idle; } void PassSystem::InitPassTemplates() @@ -118,10 +122,10 @@ namespace AZ JsonSerializationUtils::SaveObjectToFile(&passAsset, assetFilePath); } - void PassSystem::QueueForBuildAttachments(Pass* pass) + void PassSystem::QueueForBuild(Pass* pass) { - AZ_Assert(pass != nullptr, "Queuing nullptr pass in PassSystem::QueueForBuildAttachments"); - m_buildAttachmentsList.push_back(pass); + AZ_Assert(pass != nullptr, "Queuing nullptr pass in PassSystem::QueueForBuild"); + m_buildPassList.push_back(pass); } void PassSystem::QueueForRemoval(Pass* pass) @@ -130,6 +134,12 @@ namespace AZ m_removePassList.push_back(pass); } + void PassSystem::QueueForInitialization(Pass* pass) + { + AZ_Assert(pass != nullptr, "Queuing nullptr pass in PassSystem::QueueForInitialization"); + m_initializePassList.push_back(pass); + } + // Sort so passes with less depth (closer to the root) are first. Used when changes // in the parent passes can affect the child passes, like with attachment building. void SortPassListAscending(AZStd::vector< Ptr >& passList) @@ -155,6 +165,7 @@ namespace AZ void PassSystem::RemovePasses() { + m_state = PassSystemState::RemovingPasses; AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: RemovePasses"); if (!m_removePassList.empty()) @@ -168,24 +179,25 @@ namespace AZ m_removePassList.clear(); } + + m_state = PassSystemState::Idle; } - void PassSystem::BuildPassAttachments() + void PassSystem::BuildPasses() { + m_state = PassSystemState::Building; AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender); AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: BuildPassAttachments"); - m_isBuilding = true; + m_passHierarchyChanged = !m_buildPassList.empty(); - m_passHierarchyChanged = !m_buildAttachmentsList.empty(); - - // While loop is for the event in which passes being built add more pass to m_buildAttachmentsList - while(!m_buildAttachmentsList.empty()) + // While loop is for the event in which passes being built add more pass to m_buildPassList + while(!m_buildPassList.empty()) { AZ_Assert(m_removePassList.empty(), "Passes shouldn't be queued removal during build attachment process"); - AZStd::vector< Ptr > buildListCopy = m_buildAttachmentsList; - m_buildAttachmentsList.clear(); + AZStd::vector< Ptr > buildListCopy = m_buildPassList; + m_buildPassList.clear(); // Erase passes which were removed from pass tree already (which parent is empty) auto unused = AZStd::remove_if(buildListCopy.begin(), buildListCopy.end(), @@ -203,15 +215,15 @@ namespace AZ } for (const Ptr& pass : buildListCopy) { - pass->BuildAttachments(); + pass->Build(); } - - // Signal all passes that we have finished building - m_rootPass->OnBuildAttachmentsFinished(); } if (m_passHierarchyChanged) { + // Signal all passes that we have finished building + m_rootPass->OnBuildFinished(); + #if AZ_RPI_ENABLE_PASS_DEBUGGING if (!m_isHotReloading) { @@ -221,11 +233,39 @@ namespace AZ #endif } - m_isBuilding = false; + m_state = PassSystemState::Idle; + } + + void PassSystem::InitializePasses() + { + m_state = PassSystemState::Initializing; + AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender); + AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: BuildPassAttachments"); + + if(!m_initializePassList.empty()) + { + // Erase passes which were removed from pass tree already (which parent is empty) + auto unused = AZStd::remove_if(m_initializePassList.begin(), m_initializePassList.end(), + [](const RHI::Ptr& currentPass) + { + return !currentPass->m_flags.m_partOfHierarchy; + }); + m_initializePassList.erase(unused, m_initializePassList.end()); + + SortPassListAscending(m_initializePassList); + + for (const Ptr& pass : m_initializePassList) + { + pass->Initialize(); + } + } + + m_state = PassSystemState::Idle; } void PassSystem::Validate() { + m_state = PassSystemState::Validating; AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: Validate"); if (PassValidation::IsEnabled()) @@ -241,12 +281,15 @@ namespace AZ m_rootPass->Validate(validationResults); validationResults.PrintValidationIfError(); } + + m_state = PassSystemState::Idle; } void PassSystem::ProcessQueuedChanges() { RemovePasses(); - BuildPassAttachments(); + BuildPasses(); + InitializePasses(); Validate(); } @@ -256,6 +299,8 @@ namespace AZ AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: FrameUpdate"); ProcessQueuedChanges(); + + m_state = PassSystemState::Rendering; Pass::FramePrepareParams params{ &frameGraphBuilder }; m_rootPass->FrameBegin(params); } @@ -264,6 +309,8 @@ namespace AZ { AZ_ATOM_PROFILE_FUNCTION("RHI", "PassSystem: FrameEnd"); + m_state = PassSystemState::FrameEnd; + m_rootPass->FrameEnd(); // remove any pipelines that are marked as ExecuteOnce @@ -278,12 +325,14 @@ namespace AZ } m_passHierarchyChanged = false; + + m_state = PassSystemState::Idle; } void PassSystem::Shutdown() { RemovePasses(); - m_buildAttachmentsList.clear(); + m_buildPassList.clear(); m_rootPass = nullptr; m_passFactory.Shutdown(); m_passLibrary.Shutdown(); @@ -296,9 +345,9 @@ namespace AZ return m_rootPass; } - bool PassSystem::IsBuilding() const + PassSystemState PassSystem::GetState() const { - return m_isBuilding; + return m_state; } bool PassSystem::IsHotReloading() const diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp index 3a2a556429..12989fb873 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp @@ -128,7 +128,7 @@ namespace AZ } - void RenderPass::OnBuildAttachmentsFinishedInternal() + void RenderPass::OnBuildFinishedInternal() { if (m_shaderResourceGroup != nullptr) { diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp index 0e0ebf445e..329247d4eb 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/DownsampleMipChainPass.cpp @@ -181,12 +181,12 @@ namespace AZ // Pass behavior functions... - void DownsampleMipChainPass::BuildAttachmentsInternal() + void DownsampleMipChainPass::BuildInternal() { GetInputInfo(); BuildChildPasses(); UpdateChildren(); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void DownsampleMipChainPass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp index c72712bce5..672e5509ee 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp @@ -37,8 +37,6 @@ namespace AZ EnvironmentCubeMapPass::EnvironmentCubeMapPass(const PassDescriptor& passDescriptor) : ParentPass(passDescriptor) { - m_flags.m_alreadyCreated = false; - // load pass data const EnvironmentCubeMapPassData* passData = PassUtils::GetPassData(passDescriptor); if (passData == nullptr) @@ -113,7 +111,7 @@ namespace AZ AddChild(m_childPass); } - void EnvironmentCubeMapPass::BuildAttachmentsInternal() + void EnvironmentCubeMapPass::BuildInternal() { // create output image descriptor m_outputImageDesc = RHI::ImageDescriptor::Create2D(RHI::ImageBindFlags::Color | RHI::ImageBindFlags::CopyRead, CubeMapFaceSize, CubeMapFaceSize, RHI::Format::R16G16B16A16_FLOAT); @@ -135,7 +133,7 @@ namespace AZ m_attachmentBindings.push_back(outputAttachment); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void EnvironmentCubeMapPass::FrameBeginInternal(FramePrepareParams params) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/RenderToTexturePass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/RenderToTexturePass.cpp index 4356a56622..c0a4785365 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/RenderToTexturePass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/RenderToTexturePass.cpp @@ -50,7 +50,7 @@ namespace AZ { } - void RenderToTexturePass::BuildAttachmentsInternal() + void RenderToTexturePass::BuildInternal() { m_outputAttachment = aznew PassAttachment(); m_outputAttachment->m_name = "RenderTarget"; @@ -73,7 +73,7 @@ namespace AZ m_attachmentBindings.push_back(outputBinding); - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } void RenderToTexturePass::FrameBeginInternal(FramePrepareParams params) @@ -100,7 +100,7 @@ namespace AZ m_passData.m_width = width; m_passData.m_height = height; OnUpdateOutputSize(); - QueueForBuildAttachments(); + QueueForBuild(); } void RenderToTexturePass::OnUpdateOutputSize() diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SelectorPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SelectorPass.cpp index 8e8c67393d..90390b78d7 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SelectorPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SelectorPass.cpp @@ -44,7 +44,7 @@ namespace AZ } } - void SelectorPass::BuildAttachmentsInternal() + void SelectorPass::BuildInternal() { // Update output connections based on m_connections // This need to be done after BuildAttachment is finished @@ -72,7 +72,7 @@ namespace AZ m_connections[outputSlotIndex] = inputSlotIndex; // Queue to rebuild attachment connections - QueueForBuildAttachments(); + QueueForBuild(); } void SelectorPass::Connect(const AZ::Name& inputSlot, const AZ::Name& outputSlot) @@ -113,7 +113,7 @@ namespace AZ m_connections[outputIdx] = inputIdx; // Queue to rebuild attachment connections - QueueForBuildAttachments(); + QueueForBuild(); } } // namespace RPI diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp index 5bcec87df0..e6f65e997c 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp @@ -26,8 +26,6 @@ namespace AZ , m_windowContext(windowContext) , m_childTemplateName(childTemplateName) { - m_flags.m_alreadyCreated = false; - PassSystemInterface* passSystem = PassSystemInterface::Get(); // Create child pass @@ -112,7 +110,7 @@ namespace AZ AddChild(m_childPass); } - void SwapChainPass::BuildAttachmentsInternal() + void SwapChainPass::BuildInternal() { if (m_windowContext->GetSwapChain() == nullptr) { @@ -124,7 +122,7 @@ namespace AZ SetupSwapChainAttachment(); - ParentPass::BuildAttachmentsInternal(); + ParentPass::BuildInternal(); } void SwapChainPass::FrameBeginInternal(FramePrepareParams params) @@ -154,7 +152,7 @@ namespace AZ void SwapChainPass::OnWindowResized([[maybe_unused]] uint32_t width, [[maybe_unused]] uint32_t height) { - QueueForBuildAttachments(); + QueueForBuild(); } void SwapChainPass::ReadbackSwapChain(AZStd::shared_ptr readback) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp index cc0cefd082..86d76287bb 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp @@ -329,9 +329,8 @@ namespace AZ if (validation.IsValid()) { // Remove old pass - bool deletePass = true; m_rootPass->SetRenderPipeline(nullptr); - m_rootPass->QueueForRemoval(deletePass); + m_rootPass->QueueForRemoval(); // Set new root m_rootPass = newRoot; diff --git a/Gems/Atom/RPI/Code/Tests/Pass/PassTests.cpp b/Gems/Atom/RPI/Code/Tests/Pass/PassTests.cpp index 96a21f8c9b..f9a2bc4493 100644 --- a/Gems/Atom/RPI/Code/Tests/Pass/PassTests.cpp +++ b/Gems/Atom/RPI/Code/Tests/Pass/PassTests.cpp @@ -329,7 +329,7 @@ namespace UnitTest Ptr parentPass = m_passSystem->CreatePassFromTemplate(Name("ParentPass"), Name("ParentPass")); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -351,7 +351,7 @@ namespace UnitTest Ptr parentPass = m_passSystem->CreatePassFromTemplate(Name("ParentPass"), Name("ParentPass")); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -373,7 +373,7 @@ namespace UnitTest Ptr parentPass = m_passSystem->CreatePassFromTemplate(Name("ParentPass"), Name("ParentPass")); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -397,7 +397,7 @@ namespace UnitTest parentPass->m_flags.m_partOfHierarchy = true; parentPass->OnHierarchyChange(); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -421,7 +421,7 @@ namespace UnitTest parentPass->m_flags.m_partOfHierarchy = true; parentPass->OnHierarchyChange(); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -445,7 +445,7 @@ namespace UnitTest parentPass->m_flags.m_partOfHierarchy = true; parentPass->OnHierarchyChange(); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); @@ -469,7 +469,7 @@ namespace UnitTest parentPass->m_flags.m_partOfHierarchy = true; parentPass->OnHierarchyChange(); parentPass->Reset(); - parentPass->BuildAttachments(); + parentPass->Build(); PassValidationResults validationResults; parentPass->Validate(validationResults); From 52b306eb3ef53ea01080c9670985d893d8ef73d1 Mon Sep 17 00:00:00 2001 From: antonmic Date: Fri, 4 Jun 2021 14:59:27 -0700 Subject: [PATCH 030/244] Pass changes now building and working --- .../Code/Source/DisplayMapper/DisplayMapperPass.cpp | 2 ++ .../Code/Source/LuxCore/LuxCoreTexturePass.cpp | 2 ++ .../RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h | 1 + .../RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp | 6 ++++++ Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp | 11 +++++++---- .../RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp | 13 ++++++++----- .../Pass/Specific/EnvironmentCubeMapPass.cpp | 2 ++ .../RPI.Public/Pass/Specific/SwapChainPass.cpp | 2 ++ 8 files changed, 30 insertions(+), 9 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp index be3e05163a..b6fa0b5c41 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp @@ -46,6 +46,8 @@ namespace AZ DisplayMapperPass::DisplayMapperPass(const RPI::PassDescriptor& descriptor) : RPI::ParentPass(descriptor) { + m_flags.m_alreadyCreated = false; + AzFramework::NativeWindowHandle windowHandle = nullptr; AzFramework::WindowSystemRequestBus::BroadcastResult( windowHandle, diff --git a/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp b/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp index 3c7233e747..7708605e29 100644 --- a/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp @@ -28,6 +28,8 @@ namespace AZ LuxCoreTexturePass::LuxCoreTexturePass(const RPI::PassDescriptor& descriptor) : ParentPass(descriptor) { + m_flags.m_alreadyCreated = false; + RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get(); // Create render target pass diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h index ee7f850d27..b71016f30a 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h @@ -393,6 +393,7 @@ namespace AZ uint64_t m_parentEnabled : 1; uint64_t m_initialized : 1; + uint64_t m_alreadyCreated : 1; uint64_t m_partOfHierarchy : 1; uint64_t m_hasDrawListTag : 1; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index 7244510fbd..ebdfa7cf55 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -248,6 +248,12 @@ namespace AZ void ParentPass::CreateChildPasses() { + if (m_flags.m_alreadyCreated) + { + return; + } + m_flags.m_alreadyCreated = true; + RemoveChildren(); CreatePassesFromTemplate(); CreateChildPassesInternal(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp index da9022b655..726d702a72 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp @@ -151,6 +151,7 @@ namespace AZ { AZ_RPI_PASS_ASSERT(m_parent != nullptr, "Trying to remove pass from parent but pointer to the parent pass is null."); m_parent->RemoveChild(Ptr(this)); + m_queueState = PassQueueState::NoQueue; } void Pass::OnOrphan() @@ -358,7 +359,7 @@ namespace AZ void Pass::QueueForBuild() { // Don't queue if we're in building phase - if (PassSystemInterface::Get()->GetState() != PassSystemState::Building && + if (m_state != PassState::Building && (m_queueState == PassQueueState::NoQueue || m_queueState == PassQueueState::QueuedForInitialization)) { PassSystemInterface::Get()->QueueForBuild(this); @@ -374,7 +375,7 @@ namespace AZ void Pass::QueueForInitialization() { // Don't queue if we're in initialization phase - if (PassSystemInterface::Get()->GetState() != PassSystemState::Initializing && m_queueState == PassQueueState::NoQueue) + if (m_queueState == PassQueueState::NoQueue) { PassSystemInterface::Get()->QueueForInitialization(this); m_queueState = PassQueueState::QueuedForInitialization; @@ -1086,11 +1087,12 @@ namespace AZ void Pass::Build() { - if (m_queueState != PassQueueState::QueuedForBuild || m_state != PassState::Resetting) + if (m_queueState != PassQueueState::QueuedForBuild || (m_state != PassState::Queued && m_state != PassState::Resetting)) { return; } m_state = PassState::Building; + m_queueState = PassQueueState::NoQueue; AZ_RPI_BREAK_ON_TARGET_PASS; @@ -1115,7 +1117,6 @@ namespace AZ UpdateAttachmentUsageIndices(); // Queue for Initialization - m_queueState = PassQueueState::NoQueue; QueueForInitialization(); } @@ -1123,6 +1124,7 @@ namespace AZ { AZ_RPI_BREAK_ON_TARGET_PASS; + m_flags.m_alreadyCreated = false; m_importedAttachmentStore.clear(); OnBuildFinishedInternal(); } @@ -1133,6 +1135,7 @@ namespace AZ { return; } + m_queueState = PassQueueState::NoQueue; m_state = PassState::Initializing; InitializeInternal(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index 3dabd88fff..0c38b228f5 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -242,19 +242,22 @@ namespace AZ AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender); AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: BuildPassAttachments"); - if(!m_initializePassList.empty()) + while (!m_initializePassList.empty()) { + AZStd::vector< Ptr > initListCopy = m_initializePassList; + m_initializePassList.clear(); + // Erase passes which were removed from pass tree already (which parent is empty) - auto unused = AZStd::remove_if(m_initializePassList.begin(), m_initializePassList.end(), + auto unused = AZStd::remove_if(initListCopy.begin(), initListCopy.end(), [](const RHI::Ptr& currentPass) { return !currentPass->m_flags.m_partOfHierarchy; }); - m_initializePassList.erase(unused, m_initializePassList.end()); + initListCopy.erase(unused, initListCopy.end()); - SortPassListAscending(m_initializePassList); + SortPassListAscending(initListCopy); - for (const Ptr& pass : m_initializePassList) + for (const Ptr& pass : initListCopy) { pass->Initialize(); } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp index 672e5509ee..be06343ab9 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp @@ -37,6 +37,8 @@ namespace AZ EnvironmentCubeMapPass::EnvironmentCubeMapPass(const PassDescriptor& passDescriptor) : ParentPass(passDescriptor) { + m_flags.m_alreadyCreated = false; + // load pass data const EnvironmentCubeMapPassData* passData = PassUtils::GetPassData(passDescriptor); if (passData == nullptr) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp index e6f65e997c..45fb890e91 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp @@ -26,6 +26,8 @@ namespace AZ , m_windowContext(windowContext) , m_childTemplateName(childTemplateName) { + m_flags.m_alreadyCreated = false; + PassSystemInterface* passSystem = PassSystemInterface::Get(); // Create child pass From ed759612dd198ae463c6af0b8b6b92ba2c51c563 Mon Sep 17 00:00:00 2001 From: antonmic Date: Sat, 5 Jun 2021 19:12:45 -0700 Subject: [PATCH 031/244] Atom Pass changes WIP: ASV screenshot tests passing now --- .../Common/Code/Source/ImGui/ImGuiPass.cpp | 4 +- .../Common/Code/Source/ImGui/ImGuiPass.h | 2 +- .../Code/Source/PostProcessing/SsaoPasses.cpp | 4 +- .../Code/Source/PostProcessing/SsaoPasses.h | 2 +- .../Atom/RPI.Public/Pass/AttachmentReadback.h | 2 +- .../Include/Atom/RPI.Public/Pass/ParentPass.h | 2 +- .../Code/Include/Atom/RPI.Public/Pass/Pass.h | 12 +- .../Atom/RPI.Public/Pass/PassDefines.h | 5 +- .../Include/Atom/RPI.Public/Pass/RenderPass.h | 2 +- .../RPI.Public/Pass/AttachmentReadback.cpp | 15 +- .../Source/RPI.Public/Pass/ParentPass.cpp | 12 +- .../RPI/Code/Source/RPI.Public/Pass/Pass.cpp | 228 ++++++++++++------ .../Source/RPI.Public/Pass/PassSystem.cpp | 28 ++- .../Source/RPI.Public/Pass/RenderPass.cpp | 2 +- 14 files changed, 208 insertions(+), 112 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp index fe5d9a16fe..750402ada8 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.cpp @@ -519,13 +519,13 @@ namespace AZ io.Fonts->TexID = reinterpret_cast(m_fontAtlas.get()); } - void ImGuiPass::OnBuildFinishedInternal() + void ImGuiPass::InitializeInternal() { // Set output format and finalize pipeline state m_pipelineState->SetOutputFromPass(this); m_pipelineState->Finalize(); - Base::OnBuildFinishedInternal(); + Base::InitializeInternal(); } void ImGuiPass::SetupFrameGraphDependencies(RHI::FrameGraphInterface frameGraph) diff --git a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h index 30449820bb..f63b515536 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/ImGui/ImGuiPass.h @@ -94,7 +94,7 @@ namespace AZ explicit ImGuiPass(const RPI::PassDescriptor& descriptor); // Pass Behaviour Overrides... - void OnBuildFinishedInternal() override; + void InitializeInternal() override; void FrameBeginInternal(FramePrepareParams params) override; // Scope producer functions diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp index 1aa16a4417..8954584886 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.cpp @@ -41,9 +41,9 @@ namespace AZ return ParentPass::IsEnabled(); } - void SsaoParentPass::OnBuildFinishedInternal() + void SsaoParentPass::InitializeInternal() { - ParentPass::OnBuildFinishedInternal(); + ParentPass::InitializeInternal(); m_blurParentPass = FindChildPass(Name("SsaoBlur"))->AsParent(); AZ_Assert(m_blurParentPass, "[SsaoParentPass] Could not retrieve parent blur pass."); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h index 20aa554414..9fc5448f65 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/SsaoPasses.h @@ -36,7 +36,7 @@ namespace AZ protected: // Behavior functions override... - void OnBuildFinishedInternal() override; + void InitializeInternal() override; void FrameBeginInternal(FramePrepareParams params) override; private: diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/AttachmentReadback.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/AttachmentReadback.h index 539e1a5398..3c00ce4e4c 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/AttachmentReadback.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/AttachmentReadback.h @@ -99,7 +99,7 @@ namespace AZ void DecomposeExecute(const RHI::FrameGraphExecuteContext& context); // copy data from the read back buffer (m_readbackBuffer) to the data buffer (m_dataBuffer) - void CopyBufferData(uint32_t readbackBufferIndex); + bool CopyBufferData(uint32_t readbackBufferIndex); // Get read back data in a structure ReadbackResult GetReadbackResult() const; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h index 0e1e12e620..ca7baf1a0f 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h @@ -110,7 +110,7 @@ namespace AZ void ResetInternal() override; void BuildInternal() override; - void OnBuildFinishedInternal() override; + void OnInitializationFinishedInternal() override; void InitializeInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void FrameEndInternal() override; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h index b71016f30a..3cab5b36e4 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h @@ -320,12 +320,12 @@ namespace AZ // Builds and sets up any attachments and input/output connections the pass needs. // Called from PassSystem when pass is QueueForBuild. - void Build(); + void Build(bool calledFromPassSystem = false); virtual void BuildInternal() { } // Called after the pass build phase has finished. Allows passes to reset build flags. - void OnBuildFinished(); - virtual void OnBuildFinishedInternal() { }; + void OnInitializationFinished(); + virtual void OnInitializationFinishedInternal() { }; // Allows for additional pass initialization between building and rendering // Can be queued independently of Build so as to only invoke Initialize without Build @@ -395,6 +395,12 @@ namespace AZ uint64_t m_initialized : 1; uint64_t m_alreadyCreated : 1; + // OLD SCHOOL + uint64_t m_alreadyReset : 1; + uint64_t m_alreadyPrepared : 1; + uint64_t m_queuedForBuildAttachment : 1; + + uint64_t m_partOfHierarchy : 1; uint64_t m_hasDrawListTag : 1; uint64_t m_hasPipelineViewTag : 1; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h index 7c55944603..7ba7f1be4e 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/PassDefines.h @@ -20,7 +20,7 @@ // Enables debugging of the pass system // Set this to 1 locally on your machine to facilitate pass debugging and get extra information // about passes in the output window. DO NOT SUBMIT with value set to 1 -#define AZ_RPI_ENABLE_PASS_DEBUGGING 0 +#define AZ_RPI_ENABLE_PASS_DEBUGGING 1 namespace AZ { @@ -31,9 +31,12 @@ namespace AZ Uninitialized, Queued, Resetting, + Reset, Building, + Built, Initializing, Initialized, + Idle, Rendering }; diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h index 5f222d8bba..8f8267393e 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/RenderPass.h @@ -96,7 +96,7 @@ namespace AZ void BindPassSrg(const RHI::FrameGraphCompileContext& context, Data::Instance& shaderResourceGroup); // Pass behavior overrides... - void OnBuildFinishedInternal() override; + void InitializeInternal() override; void FrameBeginInternal(FramePrepareParams params) override; void FrameEndInternal() override; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/AttachmentReadback.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/AttachmentReadback.cpp index 6435ae9570..88d3eb27fd 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/AttachmentReadback.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/AttachmentReadback.cpp @@ -320,8 +320,14 @@ namespace AZ { if (m_state == ReadbackState::Reading) { - CopyBufferData(readbackBufferCurrentIndex); - m_state = ReadbackState::Success; + if (CopyBufferData(readbackBufferCurrentIndex)) + { + m_state = ReadbackState::Success; + } + else + { + m_state = ReadbackState::Failed; + } } if (m_callback) { @@ -498,13 +504,13 @@ namespace AZ return result; } - void AttachmentReadback::CopyBufferData(uint32_t readbackBufferIndex) + bool AttachmentReadback::CopyBufferData(uint32_t readbackBufferIndex) { Data::Instance readbackBufferCurrent = m_readbackBufferArray[readbackBufferIndex]; if (!readbackBufferCurrent) { - return; + return false; } auto bufferSize = readbackBufferCurrent->GetBufferSize(); @@ -537,6 +543,7 @@ namespace AZ } m_isReadbackComplete[readbackBufferIndex] = true; + return true; } } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index ebdfa7cf55..ad361bdf42 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -270,10 +270,10 @@ namespace AZ void ParentPass::ResetInternal() { - for (const Ptr& child : m_children) - { - child->Reset(); - } + //for (const Ptr& child : m_children) + //{ + // child->Reset(); + //} } void ParentPass::BuildInternal() @@ -284,11 +284,11 @@ namespace AZ } } - void ParentPass::OnBuildFinishedInternal() + void ParentPass::OnInitializationFinishedInternal() { for (const Ptr& child : m_children) { - child->OnBuildFinished(); + child->OnInitializationFinished(); } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp index 726d702a72..790a1e767f 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp @@ -37,10 +37,13 @@ #include #include + namespace AZ { namespace RPI { +#pragma optimize("", off) + // --- Constructors --- Pass::Pass(const PassDescriptor& descriptor) @@ -152,6 +155,7 @@ namespace AZ AZ_RPI_PASS_ASSERT(m_parent != nullptr, "Trying to remove pass from parent but pointer to the parent pass is null."); m_parent->RemoveChild(Ptr(this)); m_queueState = PassQueueState::NoQueue; + m_state = PassState::Idle; } void Pass::OnOrphan() @@ -354,53 +358,6 @@ namespace AZ return nullptr; } - // --- Queuing functions with PassSystem --- - - void Pass::QueueForBuild() - { - // Don't queue if we're in building phase - if (m_state != PassState::Building && - (m_queueState == PassQueueState::NoQueue || m_queueState == PassQueueState::QueuedForInitialization)) - { - PassSystemInterface::Get()->QueueForBuild(this); - m_queueState = PassQueueState::QueuedForBuild; - - if (m_state != PassState::Rendering) - { - m_state = PassState::Queued; - } - } - } - - void Pass::QueueForInitialization() - { - // Don't queue if we're in initialization phase - if (m_queueState == PassQueueState::NoQueue) - { - PassSystemInterface::Get()->QueueForInitialization(this); - m_queueState = PassQueueState::QueuedForInitialization; - - if(m_state != PassState::Rendering) - { - m_state = PassState::Queued; - } - } - } - - void Pass::QueueForRemoval() - { - if (m_queueState != PassQueueState::QueuedForRemoval) - { - PassSystemInterface::Get()->QueueForRemoval(this); - m_queueState = PassQueueState::QueuedForRemoval; - - if (m_state != PassState::Rendering) - { - m_state = PassState::Queued; - } - } - } - // --- PassTemplate related functions --- void Pass::CreateBindingsFromTemplate() @@ -430,7 +387,7 @@ namespace AZ PassAttachmentBinding* localBinding = FindAttachmentBinding(slot); if (!localBinding) { - AZ_RPI_PASS_ERROR(false, "Pass::AttachBufferToSlot - Pass %s failed to find slot %s.", + AZ_RPI_PASS_ERROR(false, "Pass::AttachBufferToSlot - Pass [%s] failed to find slot [%s].", m_path.GetCStr(), slot.GetCStr()); return; } @@ -440,7 +397,7 @@ namespace AZ // handle the connected bindings if (localBinding->m_attachment) { - AZ_RPI_PASS_ERROR(false, "Pass::AttachBufferToSlot - Slot %s already has attachment %s.", + AZ_RPI_PASS_ERROR(false, "Pass::AttachBufferToSlot - Slot [%s] already has attachment [%s].", slot.GetCStr(), localBinding->m_attachment->m_name.GetCStr()); return; } @@ -462,7 +419,7 @@ namespace AZ PassAttachmentBinding* localBinding = FindAttachmentBinding(slot); if (!localBinding) { - AZ_RPI_PASS_ERROR(false, "Pass::AttachImageToSlot - Pass %s failed to find slot %s.", + AZ_RPI_PASS_ERROR(false, "Pass::AttachImageToSlot - Pass [%s] failed to find slot [%s].", m_path.GetCStr(), slot.GetCStr()); return; } @@ -472,7 +429,7 @@ namespace AZ // handle the connected bindings if (localBinding->m_attachment) { - AZ_RPI_PASS_ERROR(false, "Pass::AttachImageToSlot - Slot %s already has attachment %s.", + AZ_RPI_PASS_ERROR(false, "Pass::AttachImageToSlot - Slot [%s] already has attachment [%s].", slot.GetCStr(), localBinding->m_attachment->m_name.GetCStr()); return; } @@ -495,7 +452,7 @@ namespace AZ PassAttachmentBinding* localBinding = FindAttachmentBinding(connection.m_localSlot); if (!localBinding) { - AZ_RPI_PASS_ERROR(false, "Pass::ProcessConnection - Pass %s failed to find slot %s.", + AZ_RPI_PASS_ERROR(false, "Pass::ProcessConnection - Pass [%s] failed to find slot [%s].", m_path.GetCStr(), connection.m_localSlot.GetCStr()); return; @@ -517,7 +474,7 @@ namespace AZ { foundPass = true; const Ptr attachment = FindOwnedAttachment(connectedSlotName); - AZ_RPI_PASS_ERROR(attachment, "Pass::ProcessConnection - Pass %s doesn't own an attachment named %s.", + AZ_RPI_PASS_ERROR(attachment, "Pass::ProcessConnection - Pass [%s] doesn't own an attachment named [%s].", m_path.GetCStr(), connectedSlotName.GetCStr()); localBinding->SetAttachment(attachment); @@ -628,10 +585,10 @@ namespace AZ if (!outputBinding || !inputBinding) { - AZ_RPI_PASS_ERROR(inputBinding, "Pass::ProcessFallbackConnection - Pass %s failed to find input slot %s.", + AZ_RPI_PASS_ERROR(inputBinding, "Pass::ProcessFallbackConnection - Pass [%s] failed to find input slot [%s].", m_path.GetCStr(), connection.m_inputSlotName.GetCStr()); - AZ_RPI_PASS_ERROR(outputBinding, "Pass::ProcessFallbackConnection - Pass %s failed to find output slot %s.", + AZ_RPI_PASS_ERROR(outputBinding, "Pass::ProcessFallbackConnection - Pass [%s] failed to find output slot [%s].", m_path.GetCStr(), connection.m_outputSlotName.GetCStr()); return; @@ -641,10 +598,10 @@ namespace AZ if (!typesAreValid) { - AZ_RPI_PASS_ERROR(inputBinding->m_slotType == PassSlotType::Input, "Pass::ProcessFallbackConnection - Pass %s specifies fallback connection input %s, which is not an input.", + AZ_RPI_PASS_ERROR(inputBinding->m_slotType == PassSlotType::Input, "Pass::ProcessFallbackConnection - Pass [%s] specifies fallback connection input [%s], which is not an input.", m_path.GetCStr(), connection.m_inputSlotName.GetCStr()); - AZ_RPI_PASS_ERROR(outputBinding->m_slotType == PassSlotType::Output, "Pass::ProcessFallbackConnection - Pass %s specifies fallback connection output %s, which is not an output.", + AZ_RPI_PASS_ERROR(outputBinding->m_slotType == PassSlotType::Output, "Pass::ProcessFallbackConnection - Pass [%s] specifies fallback connection output [%s], which is not an output.", m_path.GetCStr(), connection.m_inputSlotName.GetCStr()); return; @@ -1038,7 +995,7 @@ namespace AZ // Check whether the template's slot allows this attachment if (m_template && !m_template->AttachmentFitsSlot(targetAttachment->m_descriptor, binding.m_name)) { - AZ_RPI_PASS_ERROR(false, "Pass::UpdateConnectedBinding - Attachment %s did not match the filters of input slot %s on pass %s.", + AZ_RPI_PASS_ERROR(false, "Pass::UpdateConnectedBinding - Attachment [%s] did not match the filters of input slot [%s] on pass [%s].", targetAttachment->m_name.GetCStr(), binding.m_name.GetCStr(), m_path.GetCStr()); @@ -1060,14 +1017,86 @@ namespace AZ } } + // --- Queuing functions with PassSystem --- + +#define OLD_SCHOOL 1 + + void Pass::QueueForBuild() + { +#if OLD_SCHOOL + // Don't queue if we're in building phase + //if (PassSystemInterface::Get()->GetState() != RPI::PassSystemState::Building) + { + if (!m_flags.m_queuedForBuildAttachment) + { + PassSystemInterface::Get()->QueueForBuild(this); + m_flags.m_queuedForBuildAttachment = true; + + // Set these two flags to false since when queue build attachments request, they should all be already be false except one use + // case that the pass system processed all queued requests when active a scene. + // m_flags.m_alreadyPrepared = false; + + m_queueState = PassQueueState::QueuedForBuild; + + if (m_state != PassState::Rendering) + { + m_state = PassState::Queued; + } + + } + } +#else + // Don't queue if we're in building phase + if (m_state != PassState::Building && + (m_queueState == PassQueueState::NoQueue || m_queueState == PassQueueState::QueuedForInitialization)) + { + //if (PassSystemInterface::Get()->GetState() != RPI::PassSystemState::Building) + { + PassSystemInterface::Get()->QueueForBuild(this); + } + m_queueState = PassQueueState::QueuedForBuild; + + if (m_state != PassState::Rendering) + { + m_state = PassState::Queued; + } + } +#endif + } + + void Pass::QueueForInitialization() + { + // Only queue if the pass is not in any other queue + if (m_queueState == PassQueueState::NoQueue) + { + PassSystemInterface::Get()->QueueForInitialization(this); + m_queueState = PassQueueState::QueuedForInitialization; + + if (m_state != PassState::Rendering && m_state != PassState::Built) + { + m_state = PassState::Queued; + } + } + } + + void Pass::QueueForRemoval() + { + if (m_queueState != PassQueueState::QueuedForRemoval) + { + PassSystemInterface::Get()->QueueForRemoval(this); + m_queueState = PassQueueState::QueuedForRemoval; + + if (m_state != PassState::Rendering) + { + m_state = PassState::Queued; + } + } + } + // --- Pass behavior functions --- void Pass::Reset() { - if (m_queueState != PassQueueState::QueuedForBuild || m_state != PassState::Queued) - { - return; - } m_state = PassState::Resetting; // Store references to imported attachments to underlying images and buffers aren't deleted during attachment building @@ -1083,19 +1112,37 @@ namespace AZ m_executeBeforePasses.clear(); ResetInternal(); + + m_state = PassState::Reset; } - void Pass::Build() + void Pass::Build(bool calledFromPassSystem) { - if (m_queueState != PassQueueState::QueuedForBuild || (m_state != PassState::Queued && m_state != PassState::Resetting)) + AZ_RPI_BREAK_ON_TARGET_PASS; + + bool execute = (m_state == PassState::Idle); + execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForBuild); + execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization); + +#if OLD_SCHOOL + AZ_Assert(!execute == m_flags.m_alreadyPrepared, "ANTON - EARLY OUT FLAGS do not match for pass BUILD!!"); + if (m_flags.m_alreadyPrepared) { return; } + m_flags.m_alreadyPrepared = true; +#else + if (!execute) + { + return; + } +#endif + + Reset(); + m_state = PassState::Building; m_queueState = PassQueueState::NoQueue; - AZ_RPI_BREAK_ON_TARGET_PASS; - // Bindings, inputs and attachments CreateBindingsFromTemplate(); SetupInputsFromRequest(); @@ -1116,32 +1163,51 @@ namespace AZ UpdateOwnedAttachments(); UpdateAttachmentUsageIndices(); - // Queue for Initialization - QueueForInitialization(); - } + m_state = PassState::Built; - void Pass::OnBuildFinished() - { - AZ_RPI_BREAK_ON_TARGET_PASS; - - m_flags.m_alreadyCreated = false; - m_importedAttachmentStore.clear(); - OnBuildFinishedInternal(); + // If this pass's Build() wasn't called from the Pass System, then it was called by it's parent pass + // In which case we don't need to queue for initialization because the parent will already be queued + if (calledFromPassSystem) + { + // Queue for Initialization + QueueForInitialization(); + } } void Pass::Initialize() { - if (m_queueState != PassQueueState::QueuedForInitialization || m_state != PassState::Queued) + AZ_RPI_BREAK_ON_TARGET_PASS; + + bool execute = (m_state == PassState::Idle || m_state == PassState::Built); + execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization); + + if (!execute) { return; } - m_queueState = PassQueueState::NoQueue; m_state = PassState::Initializing; + m_queueState = PassQueueState::NoQueue; + InitializeInternal(); + m_state = PassState::Initialized; } + void Pass::OnInitializationFinished() + { + AZ_RPI_BREAK_ON_TARGET_PASS; + + m_flags.m_alreadyPrepared = false; + m_flags.m_queuedForBuildAttachment = false; + + m_flags.m_alreadyCreated = false; + m_importedAttachmentStore.clear(); + OnInitializationFinishedInternal(); + + m_state = PassState::Idle; + } + void Pass::Validate(PassValidationResults& validationResults) { if (PassValidation::IsEnabled()) @@ -1195,6 +1261,8 @@ namespace AZ UpdateConnectedBindings(); return; } + + AZ_Assert(m_state == PassState::Idle, "Pass::FrameBegin - Pass [%s] is attempting to render, but is not in the Idle state.", m_path.GetCStr()); m_state = PassState::Rendering; UpdateConnectedBindings(); @@ -1213,7 +1281,7 @@ namespace AZ if (m_state == PassState::Rendering) { FrameEndInternal(); - m_state = (m_queueState == PassQueueState::NoQueue) ? PassState::Initialized : PassState::Queued; + m_state = (m_queueState == PassQueueState::NoQueue) ? PassState::Idle : PassState::Queued; } } @@ -1578,6 +1646,8 @@ namespace AZ } } +#pragma optimize("", on) + } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index 0c38b228f5..abcaa181d8 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -50,6 +50,8 @@ namespace AZ { namespace RPI { +#pragma optimize("", off) + PassSystemInterface* PassSystemInterface::Get() { return Interface::Get(); @@ -101,6 +103,8 @@ namespace AZ m_rootPass = CreatePass(Name{"Root"}); m_rootPass->m_flags.m_partOfHierarchy = true; + //m_targetedPassDebugName = "RPISamplePipeline"; + m_state = PassSystemState::Idle; } @@ -189,7 +193,8 @@ namespace AZ AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender); AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: BuildPassAttachments"); - m_passHierarchyChanged = !m_buildPassList.empty(); + m_passHierarchyChanged = m_passHierarchyChanged || !m_buildPassList.empty(); + u32 loopCounter = 0; // While loop is for the event in which passes being built add more pass to m_buildPassList while(!m_buildPassList.empty()) @@ -211,19 +216,13 @@ namespace AZ for (const Ptr& pass : buildListCopy) { - pass->Reset(); - } - for (const Ptr& pass : buildListCopy) - { - pass->Build(); + pass->Build(true); } + loopCounter++; } if (m_passHierarchyChanged) { - // Signal all passes that we have finished building - m_rootPass->OnBuildFinished(); - #if AZ_RPI_ENABLE_PASS_DEBUGGING if (!m_isHotReloading) { @@ -242,6 +241,9 @@ namespace AZ AZ_PROFILE_FUNCTION(AZ::Debug::ProfileCategory::AzRender); AZ_ATOM_PROFILE_FUNCTION("RPI", "PassSystem: BuildPassAttachments"); + m_passHierarchyChanged = m_passHierarchyChanged || !m_initializePassList.empty(); + u32 loopCounter = 0; + while (!m_initializePassList.empty()) { AZStd::vector< Ptr > initListCopy = m_initializePassList; @@ -261,6 +263,13 @@ namespace AZ { pass->Initialize(); } + loopCounter++; + } + + if (m_passHierarchyChanged) + { + // Signal all passes that we have finished initialization + m_rootPass->OnInitializationFinished(); } m_state = PassSystemState::Idle; @@ -474,5 +483,6 @@ namespace AZ return nullptr; } +#pragma optimize("", on) } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp index 12989fb873..3e52130f6f 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/RenderPass.cpp @@ -128,7 +128,7 @@ namespace AZ } - void RenderPass::OnBuildFinishedInternal() + void RenderPass::InitializeInternal() { if (m_shaderResourceGroup != nullptr) { From c6d0887210c367f58b086d90f5f20759887d5e72 Mon Sep 17 00:00:00 2001 From: moudgils Date: Sun, 6 Jun 2021 10:24:42 -0700 Subject: [PATCH 032/244] Minor method name changes --- Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp | 8 ++++---- Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp index 1e2edc6520..5d6c275184 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.cpp @@ -422,12 +422,12 @@ namespace AZ { if(RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Compute)) { - ApplyUseResourceToCompute(commandEncoder, it.second, resourcesToMakeResidentCompute); + CollectResourcesForCompute(commandEncoder, it.second, resourcesToMakeResidentCompute); } else { AZ_Assert(RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Vertex) || RHI::CheckBitsAny(visMaskIt->second, RHI::ShaderStageMask::Fragment), "The visibility mask %i is not set for Vertex or fragment stage", visMaskIt->second); - ApplyUseResourceToGraphic(commandEncoder, visMaskIt->second, it.second, resourcesToMakeResidentGraphics); + CollectResourcesForGraphics(commandEncoder, visMaskIt->second, it.second, resourcesToMakeResidentGraphics); } } } @@ -450,7 +450,7 @@ namespace AZ } } - void ArgumentBuffer::ApplyUseResourceToCompute(id encoder, const ResourceBindingsSet& resourceBindingDataSet, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const + void ArgumentBuffer::CollectResourcesForCompute(id encoder, const ResourceBindingsSet& resourceBindingDataSet, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const { for (const auto& resourceBindingData : resourceBindingDataSet) { @@ -477,7 +477,7 @@ namespace AZ } } - void ArgumentBuffer::ApplyUseResourceToGraphic(id encoder, RHI::ShaderStageMask visShaderMask, const ResourceBindingsSet& resourceBindingDataSet, GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const + void ArgumentBuffer::CollectResourcesForGraphics(id encoder, RHI::ShaderStageMask visShaderMask, const ResourceBindingsSet& resourceBindingDataSet, GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const { MTLRenderStages mtlRenderStages = GetRenderStages(visShaderMask); diff --git a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h index 2434b8312d..06380162b6 100644 --- a/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h +++ b/Gems/Atom/RHI/Metal/Code/Source/RHI/ArgumentBuffer.h @@ -128,8 +128,8 @@ namespace AZ using ComputeResourcesToMakeResidentMap = AZStd::unordered_map; using GraphicsResourcesToMakeResidentMap = AZStd::unordered_map, MetalResourceArray>; - void ApplyUseResourceToCompute(id encoder, const ResourceBindingsSet& resourceBindingData, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const; - void ApplyUseResourceToGraphic(id encoder, RHI::ShaderStageMask visShaderMask, const ResourceBindingsSet& resourceBindingDataSet, GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const; + void CollectResourcesForCompute(id encoder, const ResourceBindingsSet& resourceBindingData, ComputeResourcesToMakeResidentMap& resourcesToMakeResidentMap) const; + void CollectResourcesForGraphics(id encoder, RHI::ShaderStageMask visShaderMask, const ResourceBindingsSet& resourceBindingDataSet, GraphicsResourcesToMakeResidentMap& resourcesToMakeResidentMap) const; //! Use visibility information to call UseResource on all resources for this Argument Buffer void ApplyUseResource(id encoder, const ResourceBindingsMap& resourceMap, From 9d7119a7f84a8f19db2d60da6ba3ea174e8c6461 Mon Sep 17 00:00:00 2001 From: antonmic Date: Sun, 6 Jun 2021 21:51:49 -0700 Subject: [PATCH 033/244] Pass Changes WIP: fixed bloom pass --- .../Code/Include/Atom/RPI.Public/Pass/Pass.h | 2 +- .../Source/RPI.Public/Pass/ParentPass.cpp | 8 ++--- .../RPI/Code/Source/RPI.Public/Pass/Pass.cpp | 33 +++++++++++++++++-- .../Source/RPI.Public/Pass/PassSystem.cpp | 4 +++ 4 files changed, 40 insertions(+), 7 deletions(-) diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h index 3cab5b36e4..64daf1006d 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h @@ -396,8 +396,8 @@ namespace AZ uint64_t m_alreadyCreated : 1; // OLD SCHOOL - uint64_t m_alreadyReset : 1; uint64_t m_alreadyPrepared : 1; + uint64_t m_alreadyReset : 1; uint64_t m_queuedForBuildAttachment : 1; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index ad361bdf42..6b95a6e17a 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -270,10 +270,10 @@ namespace AZ void ParentPass::ResetInternal() { - //for (const Ptr& child : m_children) - //{ - // child->Reset(); - //} + for (const Ptr& child : m_children) + { + child->Reset(); + } } void ParentPass::BuildInternal() diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp index 790a1e767f..391db8361d 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp @@ -75,6 +75,10 @@ namespace AZ PassSystemInterface::Get()->RegisterPass(this); QueueForBuild(); + + // Skip reset since the pass just got created + m_state = PassState::Reset; + m_flags.m_alreadyReset = true; } Pass::~Pass() @@ -1034,6 +1038,7 @@ namespace AZ // Set these two flags to false since when queue build attachments request, they should all be already be false except one use // case that the pass system processed all queued requests when active a scene. + // m_flags.m_alreadyReset = false; // m_flags.m_alreadyPrepared = false; m_queueState = PassQueueState::QueuedForBuild; @@ -1097,6 +1102,24 @@ namespace AZ void Pass::Reset() { + bool execute = (m_state == PassState::Idle); + execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForBuild); + execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization); + +#if OLD_SCHOOL + AZ_Assert(!execute == m_flags.m_alreadyReset, "ANTON - EARLY OUT FLAGS do not match for pass BUILD!!"); + if (m_flags.m_alreadyReset) + { + return; + } + m_flags.m_alreadyReset = true; +#else + if (!execute) + { + return; + } +#endif + m_state = PassState::Resetting; // Store references to imported attachments to underlying images and buffers aren't deleted during attachment building @@ -1120,7 +1143,7 @@ namespace AZ { AZ_RPI_BREAK_ON_TARGET_PASS; - bool execute = (m_state == PassState::Idle); + bool execute = (m_state == PassState::Idle || m_state == PassState::Reset); execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForBuild); execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization); @@ -1138,7 +1161,7 @@ namespace AZ } #endif - Reset(); + //Reset(); m_state = PassState::Building; m_queueState = PassQueueState::NoQueue; @@ -1189,6 +1212,11 @@ namespace AZ m_state = PassState::Initializing; m_queueState = PassQueueState::NoQueue; + // Update +// UpdateConnectedBindings(); +// UpdateOwnedAttachments(); +// UpdateAttachmentUsageIndices(); + InitializeInternal(); m_state = PassState::Initialized; @@ -1198,6 +1226,7 @@ namespace AZ { AZ_RPI_BREAK_ON_TARGET_PASS; + m_flags.m_alreadyReset = false; m_flags.m_alreadyPrepared = false; m_flags.m_queuedForBuildAttachment = false; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index abcaa181d8..bbd9ac7df8 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -214,6 +214,10 @@ namespace AZ SortPassListAscending(buildListCopy); + for (const Ptr& pass : buildListCopy) + { + pass->Reset(); + } for (const Ptr& pass : buildListCopy) { pass->Build(true); From bd7c5f4ee2aa2a8f98d32c9a8df767ded2e7ca9f Mon Sep 17 00:00:00 2001 From: antonmic Date: Mon, 7 Jun 2021 08:39:08 -0700 Subject: [PATCH 034/244] Pass changes WIP: small improvements --- .../RPI/Code/Source/RPI.Public/Pass/Pass.cpp | 10 ++++----- .../Source/RPI.Public/Pass/PassSystem.cpp | 21 ++++++++++++++++--- 2 files changed, 23 insertions(+), 8 deletions(-) diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp index 391db8361d..e53ffbf122 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp @@ -1027,7 +1027,7 @@ namespace AZ void Pass::QueueForBuild() { -#if OLD_SCHOOL +#if 0//OLD_SCHOOL // Don't queue if we're in building phase //if (PassSystemInterface::Get()->GetState() != RPI::PassSystemState::Building) { @@ -1107,7 +1107,7 @@ namespace AZ execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization); #if OLD_SCHOOL - AZ_Assert(!execute == m_flags.m_alreadyReset, "ANTON - EARLY OUT FLAGS do not match for pass BUILD!!"); + AZ_Assert(!execute == m_flags.m_alreadyReset, "ANTON - EARLY OUT FLAGS do not match for pass RESET!!"); if (m_flags.m_alreadyReset) { return; @@ -1143,6 +1143,8 @@ namespace AZ { AZ_RPI_BREAK_ON_TARGET_PASS; + AZ_Assert(m_state == PassState::Reset, "ANTON - BUILDING PASS BUT STATE IS NOT RESET!!"); + bool execute = (m_state == PassState::Idle || m_state == PassState::Reset); execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForBuild); execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization); @@ -1161,10 +1163,7 @@ namespace AZ } #endif - //Reset(); - m_state = PassState::Building; - m_queueState = PassQueueState::NoQueue; // Bindings, inputs and attachments CreateBindingsFromTemplate(); @@ -1187,6 +1186,7 @@ namespace AZ UpdateAttachmentUsageIndices(); m_state = PassState::Built; + m_queueState = PassQueueState::NoQueue; // If this pass's Build() wasn't called from the Pass System, then it was called by it's parent pass // In which case we don't need to queue for initialization because the parent will already be queued diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index bbd9ac7df8..a7021ee6fd 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -214,13 +214,23 @@ namespace AZ SortPassListAscending(buildListCopy); + Pass* previousPassInList = nullptr; for (const Ptr& pass : buildListCopy) { - pass->Reset(); + if (pass.get() != previousPassInList); + { + pass->Reset(); + previousPassInList = pass.get(); + } } + previousPassInList = nullptr; for (const Ptr& pass : buildListCopy) { - pass->Build(true); + if (pass.get() != previousPassInList); + { + pass->Build(true); + previousPassInList = pass.get(); + } } loopCounter++; } @@ -263,9 +273,14 @@ namespace AZ SortPassListAscending(initListCopy); + Pass* previousPassInList = nullptr; for (const Ptr& pass : initListCopy) { - pass->Initialize(); + if (pass.get() != previousPassInList); + { + pass->Initialize(); + previousPassInList = pass.get(); + } } loopCounter++; } From 40c7a6bd2d530d53a2f19d365b2639f40490f4c8 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Mon, 7 Jun 2021 17:02:42 -0700 Subject: [PATCH 035/244] Integrate remaining requests and rename Handling Requests interfaces for clarity --- .../Session/ISessionHandlingRequests.h | 33 +++++---- .../Source/MultiplayerSystemComponent.cpp | 67 +++++++++++++++++++ .../Code/Source/MultiplayerSystemComponent.h | 9 +++ 3 files changed, 95 insertions(+), 14 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h b/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h index a0731626ef..2537842d8a 100644 --- a/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h +++ b/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h @@ -45,14 +45,14 @@ namespace AzFramework AZStd::string m_playerSessionId; }; - //! ISessionHandlingClientRequests - //! The session handling events to invoke multiplayer component handle the work on client side - class ISessionHandlingClientRequests + //! ISessionLocalUserRequests + //! Requests made to the local user to manage their connection to a session + class ISessionLocalUserRequests { public: - AZ_RTTI(ISessionHandlingClientRequests, "{41DE6BD3-72BC-4443-BFF9-5B1B9396657A}"); - ISessionHandlingClientRequests() = default; - virtual ~ISessionHandlingClientRequests() = default; + AZ_RTTI(ISessionLocalUserRequests, "{41DE6BD3-72BC-4443-BFF9-5B1B9396657A}"); + ISessionLocalUserRequests() = default; + virtual ~ISessionLocalUserRequests() = default; // Request the player join session // @param sessionConnectionConfig The required properties to handle the player join session process @@ -63,14 +63,14 @@ namespace AzFramework virtual void RequestPlayerLeaveSession() = 0; }; - //! ISessionHandlingServerRequests - //! The session handling events to invoke server provider handle the work on server side - class ISessionHandlingServerRequests + //! ISessionProviderRequests + //! Requests made to the service providing server/fleet management by the server + class ISessionProviderRequests { public: - AZ_RTTI(ISessionHandlingServerRequests, "{4F0C17BA-F470-4242-A8CB-EC7EA805257C}"); - ISessionHandlingServerRequests() = default; - virtual ~ISessionHandlingServerRequests() = default; + AZ_RTTI(ISessionProviderRequests, "{4F0C17BA-F470-4242-A8CB-EC7EA805257C}"); + ISessionProviderRequests() = default; + virtual ~ISessionProviderRequests() = default; // Handle the destroy session process virtual void HandleDestroySession() = 0; @@ -84,9 +84,14 @@ namespace AzFramework // @param playerConnectionConfig The required properties to handle the player leave session process virtual void HandlePlayerLeaveSession(const PlayerConnectionConfig& playerConnectionConfig) = 0; - // Retrieves the file location of a pem-encoded TLS certificate + // Retrieves the file location of a pem-encoded TLS certificate for Client to Server communication // @return If successful, returns the file location of TLS certificate file; if not successful, returns // empty string. - virtual AZStd::string GetSessionCertificate() = 0; + virtual AZStd::string GetExternalSessionCertificate() = 0; + + // Retrieves the file location of a pem-encoded TLS certificate for Server to Server communication + // @return If successful, returns the file location of TLS certificate file; if not successful, returns + // empty string. + virtual AZStd::string GetInternalSessionCertificate() = 0; }; } // namespace AzFramework diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index ce4b7d8601..18d8bd6e2e 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -32,6 +32,7 @@ #include #include #include +#include #include #include #include @@ -169,6 +170,24 @@ namespace Multiplayer AZ::TickBus::Handler::BusDisconnect(); } + bool MultiplayerSystemComponent::RequestPlayerJoinSession(const AzFramework::SessionConnectionConfig& config) + { + AZ::Interface::Get()->InitializeMultiplayer(MultiplayerAgentType::Client); + INetworkInterface* networkInterface = AZ::Interface::Get()->RetrieveNetworkInterface(AZ::Name(MPNetworkInterfaceName)); + + const IpAddress ipAddress(config.m_ipAddress.c_str(), config.m_port, networkInterface->GetType()); + networkInterface->Connect(ipAddress); + return true; + } + + void MultiplayerSystemComponent::RequestPlayerLeaveSession() + { + AZ::Interface::Get()->InitializeMultiplayer(MultiplayerAgentType::Uninitialized); + INetworkInterface* networkInterface = AZ::Interface::Get()->RetrieveNetworkInterface(AZ::Name(MPNetworkInterfaceName)); + auto visitor = [](IConnection& connection) { connection.Disconnect(DisconnectReason::TerminatedByUser, TerminationEndpoint::Local); }; + networkInterface->GetConnectionSet().VisitConnections(visitor); + } + bool MultiplayerSystemComponent::OnSessionHealthCheck() { return true; @@ -176,6 +195,21 @@ namespace Multiplayer bool MultiplayerSystemComponent::OnCreateSessionBegin(const AzFramework::SessionConfig& sessionConfig) { + // Check if session manager has a certificate for us and pass it along if so + AZ::CVarFixedString externalCertPath = AZ::CVarFixedString(AZ::Interface::Get()->GetExternalSessionCertificate()); + if (!externalCertPath.empty()) + { + AZ::CVarFixedString commandString = "net_SslExternalCertificateFile " + externalCertPath; + AZ::Interface::Get()->PerformCommand(commandString.c_str()); + } + + AZ::CVarFixedString internalCertPath = AZ::CVarFixedString(AZ::Interface::Get()->GetInternalSessionCertificate()); + if (!internalCertPath.empty()) + { + AZ::CVarFixedString commandString = "net_SslInternalCertificateFile " + internalCertPath; + AZ::Interface::Get()->PerformCommand(commandString.c_str()); + } + Multiplayer::MultiplayerAgentType serverType = sv_isDedicated ? MultiplayerAgentType::DedicatedServer : MultiplayerAgentType::ClientServer; AZ::Interface::Get()->InitializeMultiplayer(serverType); return m_networkInterface->Listen(sessionConfig.m_port); @@ -497,6 +531,10 @@ namespace Multiplayer { AZLOG_INFO("New incoming connection from remote address: %s", connection->GetRemoteAddress().GetString().c_str()); m_connAcquiredEvent.Signal(datum); + AzFramework::PlayerConnectionConfig config; + config.m_playerConnectionId = aznumeric_cast(connection->GetConnectionId()); + config.m_playerSessionId = AZStd::to_string(config.m_playerConnectionId); + AZ::Interface::Get()->ValidatePlayerJoinSession(config); } // Hosts will spawn a new default player prefab for the user that just connected @@ -558,6 +596,34 @@ namespace Multiplayer delete connectionData; connection->SetUserData(nullptr); } + + // Signal to session management that a user triggered a disconnect + if (m_agentType == MultiplayerAgentType::Client && connection->GetConnectionRole() == ConnectionRole::Connector) + { + AZ::Interface::Get()->LeaveSession(); + } + + // Signal to session management that a user has left the server + if (m_agentType == MultiplayerAgentType::DedicatedServer || m_agentType == MultiplayerAgentType::ClientServer) + { + if (connection->GetConnectionRole() == ConnectionRole::Connector) + { + AzFramework::PlayerConnectionConfig config; + config.m_playerConnectionId = aznumeric_cast(connection->GetConnectionId()); + config.m_playerSessionId = AZStd::to_string(config.m_playerConnectionId); + AZ::Interface::Get()->HandlePlayerLeaveSession(config); + } + } + + // Signal to session management when there are no remaining players in a dedicated server for potential cleanup + // We avoid this for client server as the host itself is a user + if (m_agentType == MultiplayerAgentType::DedicatedServer) + { + if (m_networkInterface->GetConnectionSet().GetConnectionCount() == 0) + { + AZ::Interface::Get()->HandleDestroySession(); + } + } } MultiplayerAgentType MultiplayerSystemComponent::GetAgentType() const @@ -788,6 +854,7 @@ namespace Multiplayer } AZ_CONSOLEFREEFUNC(host, AZ::ConsoleFunctorFlags::DontReplicate, "Opens a multiplayer connection as a host for other clients to connect to"); + void connect([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments) { AZ::Interface::Get()->InitializeMultiplayer(MultiplayerAgentType::Client); diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h index ab3e54ad6d..505df52a6a 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h @@ -25,6 +25,8 @@ #include #include #include +#include +#include #include #include @@ -45,6 +47,7 @@ namespace Multiplayer : public AZ::Component , public AZ::TickBus::Handler , public AzFramework::SessionNotificationBus::Handler + , public AzFramework::ISessionLocalUserRequests , public AzNetworking::IConnectionListener , public IMultiplayer { @@ -96,6 +99,12 @@ namespace Multiplayer void OnDisconnect(AzNetworking::IConnection* connection, AzNetworking::DisconnectReason reason, AzNetworking::TerminationEndpoint endpoint) override; //! @} + //! ISessionLocalUserRequests interface + //! @{ + bool RequestPlayerJoinSession(const AzFramework::SessionConnectionConfig& sessionConnectionConfig) override; + void RequestPlayerLeaveSession() override; + //! @} + //! IMultiplayer interface //! @{ MultiplayerAgentType GetAgentType() const override; From 03989f77bb120188bad5c0cb9fdd973becd988f7 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Mon, 7 Jun 2021 17:06:00 -0700 Subject: [PATCH 036/244] Cleanup includes --- Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp | 1 - Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h | 1 - 2 files changed, 2 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index 18d8bd6e2e..44e17c0ef4 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -32,7 +32,6 @@ #include #include #include -#include #include #include #include diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h index 505df52a6a..f6ca670d87 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h @@ -25,7 +25,6 @@ #include #include #include -#include #include #include #include From 6f4c0c2ce898dcdf84cb02c0e34e3e740a72c1ae Mon Sep 17 00:00:00 2001 From: puvvadar Date: Mon, 7 Jun 2021 17:12:29 -0700 Subject: [PATCH 037/244] Rename interfaces for clarity --- .../Session/ISessionHandlingRequests.h | 20 +++++++++---------- .../Source/MultiplayerSystemComponent.cpp | 12 ++++++----- .../Code/Source/MultiplayerSystemComponent.h | 4 ++-- 3 files changed, 19 insertions(+), 17 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h b/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h index 2537842d8a..10c1d1cdd5 100644 --- a/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h +++ b/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h @@ -45,14 +45,14 @@ namespace AzFramework AZStd::string m_playerSessionId; }; - //! ISessionLocalUserRequests - //! Requests made to the local user to manage their connection to a session - class ISessionLocalUserRequests + //! ISessionHandlingClientRequests + //! Requests made to the client to manage their connection to a session + class ISessionHandlingClientRequests { public: - AZ_RTTI(ISessionLocalUserRequests, "{41DE6BD3-72BC-4443-BFF9-5B1B9396657A}"); - ISessionLocalUserRequests() = default; - virtual ~ISessionLocalUserRequests() = default; + AZ_RTTI(ISessionHandlingClientRequests, "{41DE6BD3-72BC-4443-BFF9-5B1B9396657A}"); + ISessionHandlingClientRequests() = default; + virtual ~ISessionHandlingClientRequests() = default; // Request the player join session // @param sessionConnectionConfig The required properties to handle the player join session process @@ -65,12 +65,12 @@ namespace AzFramework //! ISessionProviderRequests //! Requests made to the service providing server/fleet management by the server - class ISessionProviderRequests + class ISessionHandlingProviderRequests { public: - AZ_RTTI(ISessionProviderRequests, "{4F0C17BA-F470-4242-A8CB-EC7EA805257C}"); - ISessionProviderRequests() = default; - virtual ~ISessionProviderRequests() = default; + AZ_RTTI(ISessionHandlingProviderRequests, "{4F0C17BA-F470-4242-A8CB-EC7EA805257C}"); + ISessionHandlingProviderRequests() = default; + virtual ~ISessionHandlingProviderRequests() = default; // Handle the destroy session process virtual void HandleDestroySession() = 0; diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index 44e17c0ef4..336f27e7e4 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -157,6 +157,7 @@ namespace Multiplayer m_networkInterface = AZ::Interface::Get()->CreateNetworkInterface(AZ::Name(MPNetworkInterfaceName), sv_protocol, TrustZone::ExternalClientToServer, *this); m_consoleCommandHandler.Connect(AZ::Interface::Get()->GetConsoleCommandInvokedEvent()); AZ::Interface::Register(this); + AZ::Interface::Register(this); //! Register our gems multiplayer components to assign NetComponentIds RegisterMultiplayerComponents(); @@ -164,6 +165,7 @@ namespace Multiplayer void MultiplayerSystemComponent::Deactivate() { + AZ::Interface::Unregister(this); AZ::Interface::Unregister(this); AzFramework::SessionNotificationBus::Handler::BusDisconnect(); AZ::TickBus::Handler::BusDisconnect(); @@ -195,14 +197,14 @@ namespace Multiplayer bool MultiplayerSystemComponent::OnCreateSessionBegin(const AzFramework::SessionConfig& sessionConfig) { // Check if session manager has a certificate for us and pass it along if so - AZ::CVarFixedString externalCertPath = AZ::CVarFixedString(AZ::Interface::Get()->GetExternalSessionCertificate()); + AZ::CVarFixedString externalCertPath = AZ::CVarFixedString(AZ::Interface::Get()->GetExternalSessionCertificate()); if (!externalCertPath.empty()) { AZ::CVarFixedString commandString = "net_SslExternalCertificateFile " + externalCertPath; AZ::Interface::Get()->PerformCommand(commandString.c_str()); } - AZ::CVarFixedString internalCertPath = AZ::CVarFixedString(AZ::Interface::Get()->GetInternalSessionCertificate()); + AZ::CVarFixedString internalCertPath = AZ::CVarFixedString(AZ::Interface::Get()->GetInternalSessionCertificate()); if (!internalCertPath.empty()) { AZ::CVarFixedString commandString = "net_SslInternalCertificateFile " + internalCertPath; @@ -533,7 +535,7 @@ namespace Multiplayer AzFramework::PlayerConnectionConfig config; config.m_playerConnectionId = aznumeric_cast(connection->GetConnectionId()); config.m_playerSessionId = AZStd::to_string(config.m_playerConnectionId); - AZ::Interface::Get()->ValidatePlayerJoinSession(config); + AZ::Interface::Get()->ValidatePlayerJoinSession(config); } // Hosts will spawn a new default player prefab for the user that just connected @@ -610,7 +612,7 @@ namespace Multiplayer AzFramework::PlayerConnectionConfig config; config.m_playerConnectionId = aznumeric_cast(connection->GetConnectionId()); config.m_playerSessionId = AZStd::to_string(config.m_playerConnectionId); - AZ::Interface::Get()->HandlePlayerLeaveSession(config); + AZ::Interface::Get()->HandlePlayerLeaveSession(config); } } @@ -620,7 +622,7 @@ namespace Multiplayer { if (m_networkInterface->GetConnectionSet().GetConnectionCount() == 0) { - AZ::Interface::Get()->HandleDestroySession(); + AZ::Interface::Get()->HandleDestroySession(); } } } diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h index f6ca670d87..c089b243bd 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.h @@ -46,7 +46,7 @@ namespace Multiplayer : public AZ::Component , public AZ::TickBus::Handler , public AzFramework::SessionNotificationBus::Handler - , public AzFramework::ISessionLocalUserRequests + , public AzFramework::ISessionHandlingClientRequests , public AzNetworking::IConnectionListener , public IMultiplayer { @@ -98,7 +98,7 @@ namespace Multiplayer void OnDisconnect(AzNetworking::IConnection* connection, AzNetworking::DisconnectReason reason, AzNetworking::TerminationEndpoint endpoint) override; //! @} - //! ISessionLocalUserRequests interface + //! ISessionHandlingClientRequests interface //! @{ bool RequestPlayerJoinSession(const AzFramework::SessionConnectionConfig& sessionConnectionConfig) override; void RequestPlayerLeaveSession() override; From 45b1bbc85cd273a5f0392488b862b2395620e005 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Mon, 7 Jun 2021 17:13:52 -0700 Subject: [PATCH 038/244] Fix duplicate include --- Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index 336f27e7e4..bd5f4e63de 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -36,7 +36,6 @@ #include #include #include -#include #include From 2b227a17d1ce1ddad9517c3ffa9b83ca269f8885 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Mon, 7 Jun 2021 17:20:12 -0700 Subject: [PATCH 039/244] Remove extraneous code --- .../Multiplayer/Code/Source/MultiplayerSystemComponent.cpp | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index bd5f4e63de..6f8569251f 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -597,12 +597,6 @@ namespace Multiplayer connection->SetUserData(nullptr); } - // Signal to session management that a user triggered a disconnect - if (m_agentType == MultiplayerAgentType::Client && connection->GetConnectionRole() == ConnectionRole::Connector) - { - AZ::Interface::Get()->LeaveSession(); - } - // Signal to session management that a user has left the server if (m_agentType == MultiplayerAgentType::DedicatedServer || m_agentType == MultiplayerAgentType::ClientServer) { @@ -854,7 +848,6 @@ namespace Multiplayer } AZ_CONSOLEFREEFUNC(host, AZ::ConsoleFunctorFlags::DontReplicate, "Opens a multiplayer connection as a host for other clients to connect to"); - void connect([[maybe_unused]] const AZ::ConsoleCommandContainer& arguments) { AZ::Interface::Get()->InitializeMultiplayer(MultiplayerAgentType::Client); From a30d9621d5e930d66fc6ed7fda4fdb2b288866ae Mon Sep 17 00:00:00 2001 From: antonmic Date: Mon, 7 Jun 2021 23:05:36 -0700 Subject: [PATCH 040/244] Pass changes WIP: various fixes, exposure sample now works --- .../Code/Source/CoreLights/LightCullingTilePreparePass.cpp | 2 +- .../Feature/Common/Code/Source/PostProcessing/TaaPass.cpp | 4 ++-- .../Feature/Common/Code/Source/PostProcessing/TaaPass.h | 2 +- Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp | 3 +-- Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp | 6 +++--- 5 files changed, 8 insertions(+), 9 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp index c144525cec..4f2a4f0346 100644 --- a/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/CoreLights/LightCullingTilePreparePass.cpp @@ -176,7 +176,7 @@ namespace AZ { LoadShader(); AZ_Assert(GetPassState() != RPI::PassState::Rendering, "LightCullingTilePreparePass: Trying to reload shader during rendering"); - if (GetPassState() == RPI::PassState::Initialized) + if (GetPassState() == RPI::PassState::Idle) { ChooseShaderVariant(); } diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/TaaPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/TaaPass.cpp index 9f885ede70..38e03ab156 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/TaaPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/TaaPass.cpp @@ -108,7 +108,7 @@ namespace AZ::Render Base::ResetInternal(); } - void TaaPass::BuildAttachmentsInternal() + void TaaPass::BuildInternal() { m_accumulationAttachments[0] = FindAttachment(Name("Accumulation1")); m_accumulationAttachments[1] = FindAttachment(Name("Accumulation2")); @@ -143,7 +143,7 @@ namespace AZ::Render m_outputColorBinding->SetAttachment(m_accumulationAttachments[1]); } - Base::BuildAttachmentsInternal(); + Base::BuildInternal(); } void TaaPass::UpdateAttachmentImage(RPI::Ptr& attachment) diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/TaaPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/TaaPass.h index 6133720691..e8f4796e7b 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/TaaPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/TaaPass.h @@ -63,7 +63,7 @@ namespace AZ::Render // Pass behavior overrides... void FrameBeginInternal(FramePrepareParams params) override; void ResetInternal() override; - void BuildAttachmentsInternal() override; + void BuildInternal() override; void UpdateAttachmentImage(RPI::Ptr& attachment); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp index 4002216361..78e30e7176 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Pass.cpp @@ -1160,8 +1160,6 @@ namespace AZ { AZ_RPI_BREAK_ON_TARGET_PASS; - AZ_Assert(m_state == PassState::Reset, "ANTON - BUILDING PASS BUT STATE IS NOT RESET!!"); - bool execute = (m_state == PassState::Idle || m_state == PassState::Reset); execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForBuild); execute = execute || (m_state == PassState::Queued && m_queueState == PassQueueState::QueuedForInitialization); @@ -1180,6 +1178,7 @@ namespace AZ } #endif + AZ_Assert(m_state == PassState::Reset, "ANTON - BUILDING PASS BUT STATE IS NOT RESET!!"); m_state = PassState::Building; // Bindings, inputs and attachments diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp index a7021ee6fd..76ea52b4a3 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/PassSystem.cpp @@ -217,7 +217,7 @@ namespace AZ Pass* previousPassInList = nullptr; for (const Ptr& pass : buildListCopy) { - if (pass.get() != previousPassInList); + if (pass.get() != previousPassInList) { pass->Reset(); previousPassInList = pass.get(); @@ -226,7 +226,7 @@ namespace AZ previousPassInList = nullptr; for (const Ptr& pass : buildListCopy) { - if (pass.get() != previousPassInList); + if (pass.get() != previousPassInList) { pass->Build(true); previousPassInList = pass.get(); @@ -276,7 +276,7 @@ namespace AZ Pass* previousPassInList = nullptr; for (const Ptr& pass : initListCopy) { - if (pass.get() != previousPassInList); + if (pass.get() != previousPassInList) { pass->Initialize(); previousPassInList = pass.get(); From 6973d9c7a3c4593b66aadea908d8c097248f3c20 Mon Sep 17 00:00:00 2001 From: antonmic Date: Tue, 8 Jun 2021 12:03:58 -0700 Subject: [PATCH 041/244] Pass changes WIP: moved child pass creation to Build phase --- .../DisplayMapper/DisplayMapperPass.cpp | 68 ++++--------------- .../Source/LuxCore/LuxCoreTexturePass.cpp | 4 -- .../DepthOfFieldReadBackFocusDepthPass.cpp | 33 +++++---- .../DepthOfFieldReadBackFocusDepthPass.h | 1 + .../ReflectionScreenSpaceBlurPass.cpp | 8 +-- .../ReflectionScreenSpaceBlurPass.h | 3 +- .../Include/Atom/RPI.Public/Pass/ParentPass.h | 2 +- .../Code/Include/Atom/RPI.Public/Pass/Pass.h | 2 + .../Source/RPI.Public/Pass/ParentPass.cpp | 15 ++-- .../Pass/Specific/EnvironmentCubeMapPass.cpp | 4 -- .../Pass/Specific/SwapChainPass.cpp | 4 -- .../Code/Source/RPI.Public/RenderPipeline.cpp | 2 + 12 files changed, 49 insertions(+), 97 deletions(-) diff --git a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp index b6fa0b5c41..f5b301ca5c 100644 --- a/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/DisplayMapper/DisplayMapperPass.cpp @@ -46,8 +46,6 @@ namespace AZ DisplayMapperPass::DisplayMapperPass(const RPI::PassDescriptor& descriptor) : RPI::ParentPass(descriptor) { - m_flags.m_alreadyCreated = false; - AzFramework::NativeWindowHandle windowHandle = nullptr; AzFramework::WindowSystemRequestBus::BroadcastResult( windowHandle, @@ -61,8 +59,6 @@ namespace AZ { m_displayMapperConfigurationDescriptor = passData->m_config; } - - m_needToRebuildChildren = true; } DisplayMapperPass::~DisplayMapperPass() @@ -199,24 +195,14 @@ namespace AZ void DisplayMapperPass::FrameEndInternal() { GetDisplayMapperConfiguration(); - if (m_needToRebuildChildren) - { - ClearChildren(); - BuildGradingLutTemplate(); - CreateGradingAndAcesPasses(); - } ParentPass::FrameEndInternal(); } void DisplayMapperPass::CreateChildPassesInternal() { - if (m_needToRebuildChildren) - { - ClearChildren(); - BuildGradingLutTemplate(); - CreateGradingAndAcesPasses(); - } - ParentPass::CreateChildPassesInternal(); + ClearChildren(); + BuildGradingLutTemplate(); + CreateGradingAndAcesPasses(); } AZStd::shared_ptr CreatePassTemplateHelper( @@ -485,7 +471,6 @@ namespace AZ { AddChild(m_ldrGradingLookupTablePass); } - m_needToRebuildChildren = false; } void DisplayMapperPass::GetDisplayMapperConfiguration() @@ -513,7 +498,8 @@ namespace AZ desc.m_ldrColorGradingLut != m_displayMapperConfigurationDescriptor.m_ldrColorGradingLut || desc.m_acesParameterOverrides.m_overrideDefaults != m_displayMapperConfigurationDescriptor.m_acesParameterOverrides.m_overrideDefaults) { - m_needToRebuildChildren = true; + m_flags.m_createChildren = true; + QueueForBuild(); } m_displayMapperConfigurationDescriptor = desc; } @@ -527,41 +513,15 @@ namespace AZ void DisplayMapperPass::ClearChildren() { - if (m_acesOutputTransformPass) - { - RemoveChild(m_acesOutputTransformPass); - m_acesOutputTransformPass = nullptr; - } - if (m_bakeAcesOutputTransformLutPass) - { - RemoveChild(m_bakeAcesOutputTransformLutPass); - m_bakeAcesOutputTransformLutPass = nullptr; - } - if (m_acesOutputTransformLutPass) - { - RemoveChild(m_acesOutputTransformLutPass); - m_acesOutputTransformLutPass = nullptr; - } - if (m_displayMapperPassthroughPass) - { - RemoveChild(m_displayMapperPassthroughPass); - m_displayMapperPassthroughPass = nullptr; - } - if (m_displayMapperOnlyGammaCorrectionPass) - { - RemoveChild(m_displayMapperOnlyGammaCorrectionPass); - m_displayMapperOnlyGammaCorrectionPass = nullptr; - } - if (m_ldrGradingLookupTablePass) - { - RemoveChild(m_ldrGradingLookupTablePass); - m_ldrGradingLookupTablePass = nullptr; - } - if (m_outputTransformPass) - { - RemoveChild(m_outputTransformPass); - m_outputTransformPass = nullptr; - } + RemoveChildren(); + + m_acesOutputTransformPass = nullptr; + m_bakeAcesOutputTransformLutPass = nullptr; + m_acesOutputTransformLutPass = nullptr; + m_displayMapperPassthroughPass = nullptr; + m_displayMapperOnlyGammaCorrectionPass = nullptr; + m_ldrGradingLookupTablePass = nullptr; + m_outputTransformPass = nullptr; } } // namespace Render } // namespace AZ diff --git a/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp b/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp index 7708605e29..724511b355 100644 --- a/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/LuxCore/LuxCoreTexturePass.cpp @@ -28,8 +28,6 @@ namespace AZ LuxCoreTexturePass::LuxCoreTexturePass(const RPI::PassDescriptor& descriptor) : ParentPass(descriptor) { - m_flags.m_alreadyCreated = false; - RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get(); // Create render target pass @@ -41,8 +39,6 @@ namespace AZ // Create readback m_readback = AZStd::make_shared(AZ::RHI::ScopeId{ Uuid::CreateRandom().ToString() }); - - CreateChildPasses(); } LuxCoreTexturePass::~LuxCoreTexturePass() diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldReadBackFocusDepthPass.cpp b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldReadBackFocusDepthPass.cpp index c355b7c8a7..6050ac2b2e 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldReadBackFocusDepthPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldReadBackFocusDepthPass.cpp @@ -34,18 +34,6 @@ namespace AZ DepthOfFieldReadBackFocusDepthPass::DepthOfFieldReadBackFocusDepthPass(const RPI::PassDescriptor& descriptor) : ParentPass(descriptor) { - RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get(); - - // Create read back pass - m_readbackPass = passSystem->CreatePass(AZ::Name("DepthOfFieldReadBackPass")); - AZ_Assert(m_readbackPass, "DepthOfFieldReadBackFocusDepthPass : read back pass is invalid"); - - AddChild(m_readbackPass); - - // Find GetDepth pass on template - auto pass = FindChildPass(Name("DepthOfFieldWriteFocusDepthFromGpu")); - m_getDepthPass = static_cast(pass.get()); - // Create buffer for read back focus depth. We append static counter to avoid name conflicts. RPI::CommonBufferDescriptor desc; desc.m_bufferName = "DepthOfFieldReadBackAutoFocusDepthBuffer"; @@ -55,9 +43,6 @@ namespace AZ desc.m_bufferData = nullptr; desc.m_elementFormat = RHI::Format::R32_FLOAT; m_buffer = RPI::BufferSystemInterface::Get()->CreateBufferFromCommonPool(desc); - - m_getDepthPass->SetBufferRef(m_buffer); - m_readbackPass->SetBufferRef(m_buffer); } DepthOfFieldReadBackFocusDepthPass::~DepthOfFieldReadBackFocusDepthPass() @@ -85,6 +70,24 @@ namespace AZ } } + void DepthOfFieldReadBackFocusDepthPass::CreateChildPassesInternal() + { + RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get(); + + // Create read back pass + m_readbackPass = passSystem->CreatePass(AZ::Name("DepthOfFieldReadBackPass")); + AZ_Assert(m_readbackPass, "DepthOfFieldReadBackFocusDepthPass : read back pass is invalid"); + + AddChild(m_readbackPass); + + // Find GetDepth pass on template + auto pass = FindChildPass(Name("DepthOfFieldWriteFocusDepthFromGpu")); + m_getDepthPass = static_cast(pass.get()); + + m_getDepthPass->SetBufferRef(m_buffer); + m_readbackPass->SetBufferRef(m_buffer); + } + void DepthOfFieldReadBackFocusDepthPass::FrameBeginInternal(FramePrepareParams params) { RPI::Scene* scene = GetScene(); diff --git a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldReadBackFocusDepthPass.h b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldReadBackFocusDepthPass.h index 75842fb67a..db29576d22 100644 --- a/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldReadBackFocusDepthPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/PostProcessing/DepthOfFieldReadBackFocusDepthPass.h @@ -43,6 +43,7 @@ namespace AZ protected: // Pass behavior overrides... + void CreateChildPassesInternal() override; void FrameBeginInternal(FramePrepareParams params) override; private: diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp index 680d117b98..631ff803dd 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.cpp @@ -47,7 +47,7 @@ namespace AZ RemoveChildren(); } - void ReflectionScreenSpaceBlurPass::CreateChildPasses(uint32_t numBlurMips) + void ReflectionScreenSpaceBlurPass::CreateChildPassesInternal() { RPI::PassSystemInterface* passSystem = RPI::PassSystemInterface::Get(); @@ -83,7 +83,7 @@ namespace AZ horizontalBlurChildDesc.m_passTemplate = blurHorizontalPassTemplate; // add child passes to perform the vertical and horizontal Gaussian blur for each roughness mip level - for (uint32_t mip = 0; mip < numBlurMips; ++mip) + for (uint32_t mip = 0; mip < m_numBlurMips; ++mip) { // create Vertical blur child passes { @@ -116,6 +116,7 @@ namespace AZ void ReflectionScreenSpaceBlurPass::BuildInternal() { RemoveChildren(); + m_flags.m_createChildren = true; Data::Instance pool = RPI::ImageSystemInterface::Get()->GetSystemAttachmentPool(); @@ -163,8 +164,7 @@ namespace AZ m_ownedAttachments.push_back(transientPassAttachment); } - // create child passes, one vertical and one horizontal blur per mip level - CreateChildPasses(mipLevels - 1); + m_numBlurMips = mipLevels - 1; // call ParentPass::BuildInternal() first to configure the slots and auto-add the empty bindings, // then we will assign attachments to the bindings diff --git a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h index f344fc8e9b..4a2ccce1d4 100644 --- a/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h +++ b/Gems/Atom/Feature/Common/Code/Source/ReflectionScreenSpace/ReflectionScreenSpaceBlurPass.h @@ -40,7 +40,7 @@ namespace AZ private: explicit ReflectionScreenSpaceBlurPass(const RPI::PassDescriptor& descriptor); - void CreateChildPasses(uint32_t numBlurMips); + void CreateChildPassesInternal() override; // Pass Overrides... void ResetInternal() override; @@ -50,6 +50,7 @@ namespace AZ AZStd::vector> m_horizontalBlurChildPasses; Data::Instance m_frameBufferImageAttachment; + uint32_t m_numBlurMips = 0; }; } // namespace RPI } // namespace AZ diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h index ca7baf1a0f..727398040d 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/ParentPass.h @@ -118,7 +118,7 @@ namespace AZ // Finds the pass in m_children and removes it void RemoveChild(Ptr pass); - // Orphans all children from clearing m_children. + // Orphans all children by clearing m_children. void RemoveChildren(); private: diff --git a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h index a184e8ed32..1cfd2e759e 100644 --- a/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h +++ b/Gems/Atom/RPI/Code/Include/Atom/RPI.Public/Pass/Pass.h @@ -40,6 +40,7 @@ friend class PassSystem; \ friend class PassFactory; \ friend class ParentPass; \ + friend class RenderPipeline; \ friend class UnitTest::PassTests; \ namespace UnitTest @@ -394,6 +395,7 @@ namespace AZ uint64_t m_initialized : 1; uint64_t m_alreadyCreated : 1; + uint64_t m_createChildren : 1; // OLD SCHOOL uint64_t m_alreadyPrepared : 1; diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp index 6b95a6e17a..e06ffca556 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/ParentPass.cpp @@ -40,7 +40,7 @@ namespace AZ ParentPass::ParentPass(const PassDescriptor& descriptor) : Pass(descriptor) { - CreateChildPasses(); + m_flags.m_createChildren = true; } ParentPass::~ParentPass() @@ -248,7 +248,7 @@ namespace AZ void ParentPass::CreateChildPasses() { - if (m_flags.m_alreadyCreated) + if (!m_flags.m_createChildren || m_flags.m_alreadyCreated) { return; } @@ -258,14 +258,7 @@ namespace AZ CreatePassesFromTemplate(); CreateChildPassesInternal(); - for (Ptr& child : m_children) - { - ParentPass* asParent = child->AsParent(); - if (asParent != nullptr) - { - asParent->CreateChildPasses(); - } - } + m_flags.m_createChildren = false; } void ParentPass::ResetInternal() @@ -278,6 +271,8 @@ namespace AZ void ParentPass::BuildInternal() { + CreateChildPasses(); + for (const Ptr& child : m_children) { child->Build(); diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp index be06343ab9..28a03de297 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/EnvironmentCubeMapPass.cpp @@ -37,8 +37,6 @@ namespace AZ EnvironmentCubeMapPass::EnvironmentCubeMapPass(const PassDescriptor& passDescriptor) : ParentPass(passDescriptor) { - m_flags.m_alreadyCreated = false; - // load pass data const EnvironmentCubeMapPassData* passData = PassUtils::GetPassData(passDescriptor); if (passData == nullptr) @@ -88,8 +86,6 @@ namespace AZ AZ::Matrix4x4 viewToClipMatrix; MakePerspectiveFovMatrixRH(viewToClipMatrix, AZ::Constants::HalfPi, 1.0f, 0.1f, 100.0f, true); m_view->SetViewToClipMatrix(viewToClipMatrix); - - CreateChildPasses(); } EnvironmentCubeMapPass::~EnvironmentCubeMapPass() diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp index 45fb890e91..a7add17042 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/Pass/Specific/SwapChainPass.cpp @@ -26,8 +26,6 @@ namespace AZ , m_windowContext(windowContext) , m_childTemplateName(childTemplateName) { - m_flags.m_alreadyCreated = false; - PassSystemInterface* passSystem = PassSystemInterface::Get(); // Create child pass @@ -44,8 +42,6 @@ namespace AZ m_childPass = passSystem->CreatePassFromRequest(&childRequest); AZ_Assert(m_childPass, "SwapChain child pass is invalid: check your passs pipeline, run configuration and your AssetProcessor set project (project_path)"); - - CreateChildPasses(); AzFramework::WindowNotificationBus::Handler::BusConnect(m_windowContext->GetWindowHandle()); } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp index 86d76287bb..2c4c61f5aa 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/RenderPipeline.cpp @@ -107,6 +107,8 @@ namespace AZ pipeline->m_originalRenderSettings = desc.m_renderSettings; pipeline->m_activeRenderSettings = desc.m_renderSettings; pipeline->m_rootPass->SetRenderPipeline(pipeline); + pipeline->m_rootPass->Build(); + pipeline->m_rootPass->Initialize(); pipeline->BuildPipelineViews(); } From fa55b495c4401b3ac626ec352e59e8a7107871c1 Mon Sep 17 00:00:00 2001 From: puvvadar Date: Tue, 8 Jun 2021 13:36:27 -0700 Subject: [PATCH 042/244] Add handling for session provider ticket --- .../Session/ISessionHandlingRequests.h | 6 +- .../AutoGen/Multiplayer.AutoPackets.xml | 1 + .../ClientToServerConnectionData.cpp | 4 +- .../ClientToServerConnectionData.h | 6 +- .../ClientToServerConnectionData.inl | 5 ++ .../ServerToClientConnectionData.h | 3 + .../ServerToClientConnectionData.inl | 10 +++ .../Source/MultiplayerSystemComponent.cpp | 65 +++++++++++++------ 8 files changed, 75 insertions(+), 25 deletions(-) diff --git a/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h b/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h index 10c1d1cdd5..d55f38f65c 100644 --- a/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h +++ b/Code/Framework/AzFramework/AzFramework/Session/ISessionHandlingRequests.h @@ -46,7 +46,7 @@ namespace AzFramework }; //! ISessionHandlingClientRequests - //! Requests made to the client to manage their connection to a session + //! Requests made to the client to manage their membership in a session class ISessionHandlingClientRequests { public: @@ -87,11 +87,11 @@ namespace AzFramework // Retrieves the file location of a pem-encoded TLS certificate for Client to Server communication // @return If successful, returns the file location of TLS certificate file; if not successful, returns // empty string. - virtual AZStd::string GetExternalSessionCertificate() = 0; + virtual AZ::IO::Path GetExternalSessionCertificate() = 0; // Retrieves the file location of a pem-encoded TLS certificate for Server to Server communication // @return If successful, returns the file location of TLS certificate file; if not successful, returns // empty string. - virtual AZStd::string GetInternalSessionCertificate() = 0; + virtual AZ::IO::Path GetInternalSessionCertificate() = 0; }; } // namespace AzFramework diff --git a/Gems/Multiplayer/Code/Source/AutoGen/Multiplayer.AutoPackets.xml b/Gems/Multiplayer/Code/Source/AutoGen/Multiplayer.AutoPackets.xml index 642832805d..ce8931107f 100644 --- a/Gems/Multiplayer/Code/Source/AutoGen/Multiplayer.AutoPackets.xml +++ b/Gems/Multiplayer/Code/Source/AutoGen/Multiplayer.AutoPackets.xml @@ -9,6 +9,7 @@ + diff --git a/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.cpp b/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.cpp index ee308f6ed8..11207df27d 100644 --- a/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.cpp +++ b/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.cpp @@ -21,10 +21,12 @@ namespace Multiplayer ClientToServerConnectionData::ClientToServerConnectionData ( AzNetworking::IConnection* connection, - AzNetworking::IConnectionListener& connectionListener + AzNetworking::IConnectionListener& connectionListener, + AZStd::string providerTicket ) : m_connection(connection) , m_entityReplicationManager(*connection, connectionListener, EntityReplicationManager::Mode::LocalClientToRemoteServer) + , m_providerTicket(providerTicket) { m_entityReplicationManager.SetMaxRemoteEntitiesPendingCreationCount(cl_ClientMaxRemoteEntitiesPendingCreationCount); m_entityReplicationManager.SetEntityPendingRemovalMs(cl_ClientEntityReplicatorPendingRemovalTimeMs); diff --git a/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.h b/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.h index 2e7be47842..52c5dea00d 100644 --- a/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.h +++ b/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.h @@ -24,7 +24,8 @@ namespace Multiplayer ClientToServerConnectionData ( AzNetworking::IConnection* connection, - AzNetworking::IConnectionListener& connectionListener + AzNetworking::IConnectionListener& connectionListener, + AZStd::string providerTicket = "" ); ~ClientToServerConnectionData() override; @@ -38,8 +39,11 @@ namespace Multiplayer void SetCanSendUpdates(bool canSendUpdates) override; //! @} + AZStd::string GetProviderTicket() const; + private: EntityReplicationManager m_entityReplicationManager; + AZStd::string m_providerTicket; AzNetworking::IConnection* m_connection = nullptr; bool m_canSendUpdates = true; }; diff --git a/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.inl b/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.inl index 6d4a332b6e..f23c8dd1d9 100644 --- a/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.inl +++ b/Gems/Multiplayer/Code/Source/ConnectionData/ClientToServerConnectionData.inl @@ -21,4 +21,9 @@ namespace Multiplayer { m_canSendUpdates = canSendUpdates; } + + inline AZStd::string ClientToServerConnectionData::GetProviderTicket() const + { + return m_providerTicket; + } } diff --git a/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.h b/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.h index faa11bc225..c171cdbe5d 100644 --- a/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.h +++ b/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.h @@ -41,6 +41,8 @@ namespace Multiplayer NetworkEntityHandle GetPrimaryPlayerEntity(); const NetworkEntityHandle& GetPrimaryPlayerEntity() const; + AZStd::string GetProviderTicket() const; + void SetProviderTicket(AZStd::string); private: void OnControlledEntityRemove(); @@ -51,6 +53,7 @@ namespace Multiplayer NetworkEntityHandle m_controlledEntity; EntityStopEvent::Handler m_controlledEntityRemovedHandler; EntityServerMigrationEvent::Handler m_controlledEntityMigrationHandler; + AZStd::string m_ticket; AzNetworking::IConnection* m_connection = nullptr; bool m_canSendUpdates = false; }; diff --git a/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.inl b/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.inl index 0a4215a363..0427936f00 100644 --- a/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.inl +++ b/Gems/Multiplayer/Code/Source/ConnectionData/ServerToClientConnectionData.inl @@ -32,4 +32,14 @@ namespace Multiplayer { return m_controlledEntity; } + + inline AZStd::string ServerToClientConnectionData::GetProviderTicket() const + { + return m_ticket; + } + + inline void ServerToClientConnectionData::SetProviderTicket(AZStd::string ticket) + { + m_ticket = ticket; + } } diff --git a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp index 6f8569251f..d0d2c609b3 100644 --- a/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp +++ b/Gems/Multiplayer/Code/Source/MultiplayerSystemComponent.cpp @@ -176,7 +176,13 @@ namespace Multiplayer INetworkInterface* networkInterface = AZ::Interface::Get()->RetrieveNetworkInterface(AZ::Name(MPNetworkInterfaceName)); const IpAddress ipAddress(config.m_ipAddress.c_str(), config.m_port, networkInterface->GetType()); - networkInterface->Connect(ipAddress); + ConnectionId connectionId = networkInterface->Connect(ipAddress); + + AzNetworking::IConnection* connection = networkInterface->GetConnectionSet().GetConnection(connectionId); + if (connection->GetUserData() == nullptr) // Only add user data if the connect event handler has not already done so + { + connection->SetUserData(new ClientToServerConnectionData(connection, *this, config.m_playerSessionId)); + } return true; } @@ -196,18 +202,23 @@ namespace Multiplayer bool MultiplayerSystemComponent::OnCreateSessionBegin(const AzFramework::SessionConfig& sessionConfig) { // Check if session manager has a certificate for us and pass it along if so - AZ::CVarFixedString externalCertPath = AZ::CVarFixedString(AZ::Interface::Get()->GetExternalSessionCertificate()); - if (!externalCertPath.empty()) + if (AZ::Interface::Get() != nullptr) { - AZ::CVarFixedString commandString = "net_SslExternalCertificateFile " + externalCertPath; - AZ::Interface::Get()->PerformCommand(commandString.c_str()); - } + AZ::CVarFixedString externalCertPath = AZ::CVarFixedString( + AZ::Interface::Get()->GetExternalSessionCertificate().c_str()); + if (!externalCertPath.empty()) + { + AZ::CVarFixedString commandString = "net_SslExternalCertificateFile " + externalCertPath; + AZ::Interface::Get()->PerformCommand(commandString.c_str()); + } - AZ::CVarFixedString internalCertPath = AZ::CVarFixedString(AZ::Interface::Get()->GetInternalSessionCertificate()); - if (!internalCertPath.empty()) - { - AZ::CVarFixedString commandString = "net_SslInternalCertificateFile " + internalCertPath; - AZ::Interface::Get()->PerformCommand(commandString.c_str()); + AZ::CVarFixedString internalCertPath = AZ::CVarFixedString( + AZ::Interface::Get()->GetInternalSessionCertificate().c_str()); + if (!internalCertPath.empty()) + { + AZ::CVarFixedString commandString = "net_SslInternalCertificateFile " + internalCertPath; + AZ::Interface::Get()->PerformCommand(commandString.c_str()); + } } Multiplayer::MultiplayerAgentType serverType = sv_isDedicated ? MultiplayerAgentType::DedicatedServer : MultiplayerAgentType::ClientServer; @@ -370,6 +381,17 @@ namespace Multiplayer { if (connection->SendReliablePacket(MultiplayerPackets::Accept(InvalidHostId, sv_map))) { + // Validate our session with the provider if any + if (AZ::Interface::Get() != nullptr) + { + AzFramework::PlayerConnectionConfig config; + config.m_playerConnectionId = aznumeric_cast(connection->GetConnectionId()); + config.m_playerSessionId = packet.GetTicket(); + AZ::Interface::Get()->ValidatePlayerJoinSession(config); + + reinterpret_cast(connection->GetUserData())->SetProviderTicket(packet.GetTicket().c_str()); + } + // Sync our console ConsoleReplicator consoleReplicator(connection); AZ::Interface::Get()->VisitRegisteredFunctors([&consoleReplicator](AZ::ConsoleFunctorBase* functor) { consoleReplicator.Visit(functor); }); @@ -525,16 +547,17 @@ namespace Multiplayer if (connection->GetConnectionRole() == ConnectionRole::Connector) { AZLOG_INFO("New outgoing connection to remote address: %s", connection->GetRemoteAddress().GetString().c_str()); - connection->SendReliablePacket(MultiplayerPackets::Connect(0)); + AZ::CVarFixedString providerTicket; + if (connection->GetUserData() != nullptr) + { + providerTicket = reinterpret_cast(connection->GetUserData())->GetProviderTicket(); + } + connection->SendReliablePacket(MultiplayerPackets::Connect(0, providerTicket)); } else { AZLOG_INFO("New incoming connection from remote address: %s", connection->GetRemoteAddress().GetString().c_str()); m_connAcquiredEvent.Signal(datum); - AzFramework::PlayerConnectionConfig config; - config.m_playerConnectionId = aznumeric_cast(connection->GetConnectionId()); - config.m_playerSessionId = AZStd::to_string(config.m_playerConnectionId); - AZ::Interface::Get()->ValidatePlayerJoinSession(config); } // Hosts will spawn a new default player prefab for the user that just connected @@ -600,20 +623,22 @@ namespace Multiplayer // Signal to session management that a user has left the server if (m_agentType == MultiplayerAgentType::DedicatedServer || m_agentType == MultiplayerAgentType::ClientServer) { - if (connection->GetConnectionRole() == ConnectionRole::Connector) + if (AZ::Interface::Get() != nullptr && + connection->GetConnectionRole() == ConnectionRole::Connector) { AzFramework::PlayerConnectionConfig config; config.m_playerConnectionId = aznumeric_cast(connection->GetConnectionId()); - config.m_playerSessionId = AZStd::to_string(config.m_playerConnectionId); + config.m_playerSessionId = reinterpret_cast(connection->GetUserData())->GetProviderTicket(); AZ::Interface::Get()->HandlePlayerLeaveSession(config); } } // Signal to session management when there are no remaining players in a dedicated server for potential cleanup // We avoid this for client server as the host itself is a user - if (m_agentType == MultiplayerAgentType::DedicatedServer) + if (m_agentType == MultiplayerAgentType::DedicatedServer && connection->GetConnectionRole() == ConnectionRole::Connector) { - if (m_networkInterface->GetConnectionSet().GetConnectionCount() == 0) + if (AZ::Interface::Get() != nullptr + && m_networkInterface->GetConnectionSet().GetConnectionCount() == 0) { AZ::Interface::Get()->HandleDestroySession(); } From a766e3af5c08a63e2f6edcddae26376ef8b57dd4 Mon Sep 17 00:00:00 2001 From: chcurran Date: Tue, 8 Jun 2021 13:54:25 -0700 Subject: [PATCH 043/244] Fixes for internal if-branch node parser bug (LYN-4347) and exposing properties for AZStd::tuple (LYN-3910) --- .../AzCore/RTTI/AzStdOnDemandPrettyName.inl | 51 +- .../AzCore/RTTI/AzStdOnDemandReflection.inl | 24 +- .../Grammar/AbstractCodeModel.cpp | 36 +- ...ionIfBranchWithConnectedInput.scriptcanvas | 2499 +++++++++++++++++ .../Tests/ScriptCanvas_RuntimeInterpreted.cpp | 5 + 5 files changed, 2590 insertions(+), 25 deletions(-) create mode 100644 Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_ParseFunctionIfBranchWithConnectedInput.scriptcanvas diff --git a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandPrettyName.inl b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandPrettyName.inl index 26e269573d..4f4a21301c 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandPrettyName.inl +++ b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandPrettyName.inl @@ -161,7 +161,56 @@ namespace AZ return "A pair is an fixed size collection of two elements."; } }; - + + template + void GetTypeNamesFold(AZStd::vector& result, AZ::BehaviorContext& context) + { + result.push_back(OnDemandPrettyName::Get(context)); + }; + + template + void GetTypeNames(AZStd::vector& result, AZ::BehaviorContext& context) + { + (GetTypeNamesFold(result, context), ...); + }; + + template + void GetTypeNamesFold(AZStd::string& result, AZ::BehaviorContext& context) + { + if (!result.empty()) + { + result += ", "; + } + + result += OnDemandPrettyName::Get(context); + }; + + template + void GetTypeNames(AZStd::string& result, AZ::BehaviorContext& context) + { + (GetTypeNamesFold(result, context), ...); + }; + + template + struct OnDemandPrettyName> + { + static AZStd::string Get(AZ::BehaviorContext& context) + { + AZStd::string typeNames; + GetTypeNames(typeNames, context); + return AZStd::string::format("Tuple<%s>", typeNames.c_str()); + } + }; + + template + struct OnDemandToolTip> + { + static AZStd::string Get(AZ::BehaviorContext&) + { + return "A tuple is an fixed size collection of any number of any type of element."; + } + }; + template struct OnDemandPrettyName< AZStd::unordered_map > { diff --git a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl index 537d3e5c83..2132dff3c4 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl +++ b/Code/Framework/AzCore/AzCore/RTTI/AzStdOnDemandReflection.inl @@ -813,20 +813,27 @@ namespace AZ { using ContainerType = AZStd::tuple; - template - static void ReflectUnpackMethodFold(BehaviorContext::ClassBuilder& builder) + template + static void ReflectUnpackMethodFold(BehaviorContext::ClassBuilder& builder, const AZStd::vector& typeNames, [[maybe_unused]] size_t inputIndex) { const AZStd::string methodName = AZStd::string::format("Get%zu", Index); - builder->Method(methodName.data(), [](ContainerType& value) { return AZStd::get(value); }) - ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + builder->Method(methodName.data(), [](ContainerType& thisPointer) { return AZStd::get(thisPointer); }) + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::List) ->Attribute(AZ::ScriptCanvasAttributes::TupleGetFunctionIndex, Index) ; + + builder->Property + ( AZStd::string::format("element_%zu_%s", Index, typeNames[Index].c_str()).c_str() + , [](ContainerType& thisPointer) { return AZStd::get(thisPointer); } + , [](ContainerType& thisPointer, const t_Arg& element) { AZStd::get(thisPointer) = element; }); } - template + template static void ReflectUnpackMethods(BehaviorContext::ClassBuilder& builder, AZStd::index_sequence) { - (ReflectUnpackMethodFold(builder), ...); + AZStd::vector typeNames; + ScriptCanvasOnDemandReflection::GetTypeNames(typeNames, *builder.m_context); + (ReflectUnpackMethodFold(builder, typeNames, Indices), ...); } static void Reflect(ReflectContext* context) @@ -851,9 +858,10 @@ namespace AZ ->Attribute(AZ::ScriptCanvasAttributes::TupleConstructorFunction, constructorHolder) ; - ReflectUnpackMethods(builder, AZStd::make_index_sequence{}); + ReflectUnpackMethods(builder, AZStd::make_index_sequence{}); + builder->Method("GetSize", []() { return AZStd::tuple_size::value; }) - ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::All) + ->Attribute(AZ::Script::Attributes::ExcludeFrom, AZ::Script::Attributes::ExcludeFlags::List) ; } } diff --git a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/AbstractCodeModel.cpp b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/AbstractCodeModel.cpp index 2a485c9501..bc07d16a7e 100644 --- a/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/AbstractCodeModel.cpp +++ b/Gems/ScriptCanvas/Code/Include/ScriptCanvas/Grammar/AbstractCodeModel.cpp @@ -3356,23 +3356,27 @@ namespace ScriptCanvas if (executionIf->GetId().m_node->IsIfBranchPrefacedWithBooleanExpression()) { - auto removeChildOutcome = RemoveChild(executionIf->ModParent(), executionIf); - if (!removeChildOutcome.IsSuccess()) + ExecutionTreePtr booleanExpression; + { - AddError(executionIf->GetNodeId(), executionIf, ScriptCanvas::ParseErrors::FailedToRemoveChild); + auto removeChildOutcome = RemoveChild(executionIf->ModParent(), executionIf); + if (!removeChildOutcome.IsSuccess()) + { + AddError(executionIf->GetNodeId(), executionIf, ScriptCanvas::ParseErrors::FailedToRemoveChild); + } + + if (!IsErrorFree()) + { + return; + } + + const auto indexAndChild = removeChildOutcome.TakeValue(); + + booleanExpression = CreateChild(executionIf->ModParent(), executionIf->GetId().m_node, executionIf->GetId().m_slot); + executionIf->ModParent()->InsertChild(indexAndChild.first, { indexAndChild.second.m_slot, indexAndChild.second.m_output, booleanExpression }); + executionIf->SetParent(booleanExpression); } - if (!IsErrorFree()) - { - return; - } - - const auto indexAndChild = removeChildOutcome.TakeValue(); - - ExecutionTreePtr booleanExpression = CreateChild(executionIf->ModParent(), executionIf->GetId().m_node, executionIf->GetId().m_slot); - executionIf->ModParent()->InsertChild(indexAndChild.first, { indexAndChild.second.m_slot, indexAndChild.second.m_output, booleanExpression }); - executionIf->SetParent(booleanExpression); - // make a condition here auto symbol = CheckLogicalExpressionSymbol(booleanExpression); if (symbol != Symbol::FunctionCall && symbol != Symbol::Count) @@ -3402,7 +3406,7 @@ namespace ScriptCanvas return; } - const auto indexAndChild2 = removeChildOutcome.TakeValue(); + const auto indexAndChild2 = removeChildOutcome2.TakeValue(); // parse if statement internal function ExecutionTreePtr internalFunction = CreateChild(booleanExpression->ModParent(), booleanExpression->GetId().m_node, booleanExpression->GetId().m_slot); @@ -4782,7 +4786,7 @@ namespace ScriptCanvas { PropertyExtractionPtr extraction = AZStd::make_shared(); extraction->m_slot = slot; - extraction->m_name = propertyField.first; + extraction->m_name = AZ::ReplaceCppArtifacts(propertyField.first); execution->AddPropertyExtractionSource(slot, extraction); } else diff --git a/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_ParseFunctionIfBranchWithConnectedInput.scriptcanvas b/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_ParseFunctionIfBranchWithConnectedInput.scriptcanvas new file mode 100644 index 0000000000..38df5159c2 --- /dev/null +++ b/Gems/ScriptCanvasTesting/Assets/ScriptCanvas/UnitTests/LY_SC_UnitTest_ParseFunctionIfBranchWithConnectedInput.scriptcanvas @@ -0,0 +1,2499 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp index 1633b0fc51..5bda0f3941 100644 --- a/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp +++ b/Gems/ScriptCanvasTesting/Code/Tests/ScriptCanvas_RuntimeInterpreted.cpp @@ -90,6 +90,11 @@ public: } }; +TEST_F(ScriptCanvasTestFixture, ParseFunctionIfBranchWithConnectedInput) +{ + RunUnitTestGraph("LY_SC_UnitTest_ParseFunctionIfBranchWithConnectedInput"); +} + TEST_F(ScriptCanvasTestFixture, UseRawBehaviorProperties) { RunUnitTestGraph("LY_SC_UnitTest_UseRawBehaviorProperties"); From 4b3d0d1054d88833de47d07840b356fa436562b2 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Tue, 8 Jun 2021 14:01:50 -0700 Subject: [PATCH 044/244] LYN-4327 [SDK] External Gem's aren't added to the project solution when using SDK (#1191) * should pickup the external directories registered by the project * Add support for AzTest and AzTestRunner in the SDK * missing IMPORT_LIB * Moved where .Assets targets get generated so they are visible in the SDK * generate the Directory.Build.props in the right path * excluding target on platforms that dont support it --- CMakeLists.txt | 36 +++++++-------- Code/Framework/AzTest/CMakeLists.txt | 46 +++++++++---------- Code/LauncherUnified/launcher_generator.cmake | 23 ++++++++++ Code/Tools/AzTestRunner/CMakeLists.txt | 36 ++++++++------- .../Android/platform_traits_android.cmake | 2 +- .../Linux/platform_traits_linux.cmake | 2 +- .../Platform/Mac/platform_traits_mac.cmake | 2 +- .../Windows/platform_traits_windows.cmake | 2 +- .../Platform/iOS/platform_traits_ios.cmake | 2 +- cmake/Platform/Common/Install_common.cmake | 13 +++++- .../Platform/Common/VisualStudio_common.cmake | 2 +- scripts/ctest/CMakeLists.txt | 29 ------------ 12 files changed, 100 insertions(+), 95 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 387f536966..6ca9aeacb8 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -88,28 +88,28 @@ if(NOT INSTALLED_ENGINE) # Add external subdirectories listed in the engine.json. LY_EXTERNAL_SUBDIRS is a cache variable so the user can add extra # external subdirectories add_engine_json_external_subdirectories() - get_property(external_subdirs GLOBAL PROPERTY LY_EXTERNAL_SUBDIRS) - list(APPEND LY_EXTERNAL_SUBDIRS ${external_subdirs}) - - # Loop over the additional external subdirectories and invoke add_subdirectory on them - foreach(external_directory ${LY_EXTERNAL_SUBDIRS}) - # Hash the extenal_directory name and append it to the Binary Directory section of add_subdirectory - # This is to deal with potential situations where multiple external directories has the same last directory name - # For example if D:/Company1/RayTracingGem and F:/Company2/Path/RayTracingGem were both added as a subdirectory - file(REAL_PATH ${external_directory} full_directory_path) - string(SHA256 full_directory_hash ${full_directory_path}) - # Truncate the full_directory_hash down to 8 characters to avoid hitting the Windows 260 character path limit - # when the external subdirectory contains relative paths of significant length - string(SUBSTRING ${full_directory_hash} 0 8 full_directory_hash) - # Use the last directory as the suffix path to use for the Binary Directory - get_filename_component(directory_name ${external_directory} NAME) - add_subdirectory(${external_directory} ${CMAKE_BINARY_DIR}/External/${directory_name}-${full_directory_hash}) - endforeach() - else() ly_find_o3de_packages() endif() +get_property(external_subdirs GLOBAL PROPERTY LY_EXTERNAL_SUBDIRS) +list(APPEND LY_EXTERNAL_SUBDIRS ${external_subdirs}) + +# Loop over the additional external subdirectories and invoke add_subdirectory on them +foreach(external_directory ${LY_EXTERNAL_SUBDIRS}) + # Hash the extenal_directory name and append it to the Binary Directory section of add_subdirectory + # This is to deal with potential situations where multiple external directories has the same last directory name + # For example if D:/Company1/RayTracingGem and F:/Company2/Path/RayTracingGem were both added as a subdirectory + file(REAL_PATH ${external_directory} full_directory_path) + string(SHA256 full_directory_hash ${full_directory_path}) + # Truncate the full_directory_hash down to 8 characters to avoid hitting the Windows 260 character path limit + # when the external subdirectory contains relative paths of significant length + string(SUBSTRING ${full_directory_hash} 0 8 full_directory_hash) + # Use the last directory as the suffix path to use for the Binary Directory + get_filename_component(directory_name ${external_directory} NAME) + add_subdirectory(${external_directory} ${CMAKE_BINARY_DIR}/External/${directory_name}-${full_directory_hash}) +endforeach() + ################################################################################ # Post-processing ################################################################################ diff --git a/Code/Framework/AzTest/CMakeLists.txt b/Code/Framework/AzTest/CMakeLists.txt index ff31b32a24..fe5ec2d0ff 100644 --- a/Code/Framework/AzTest/CMakeLists.txt +++ b/Code/Framework/AzTest/CMakeLists.txt @@ -8,29 +8,25 @@ # remove or modify any license notices. This file is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # + +ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/AzTest/Platform/${PAL_PLATFORM_NAME}) -if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) - - ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/AzTest/Platform/${PAL_PLATFORM_NAME}) - - ly_add_target( - NAME AzTest STATIC - NAMESPACE AZ - FILES_CMAKE - AzTest/aztest_files.cmake - ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake - INCLUDE_DIRECTORIES - PUBLIC - . - ${pal_dir} - BUILD_DEPENDENCIES - PUBLIC - 3rdParty::googletest::GMock - 3rdParty::googletest::GTest - 3rdParty::GoogleBenchmark - AZ::AzCore - PLATFORM_INCLUDE_FILES - ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake - ) - -endif() +ly_add_target( + NAME AzTest STATIC + NAMESPACE AZ + FILES_CMAKE + AzTest/aztest_files.cmake + ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}_files.cmake + INCLUDE_DIRECTORIES + PUBLIC + . + ${pal_dir} + BUILD_DEPENDENCIES + PUBLIC + 3rdParty::googletest::GMock + 3rdParty::googletest::GTest + 3rdParty::GoogleBenchmark + AZ::AzCore + PLATFORM_INCLUDE_FILES + ${pal_dir}/platform_${PAL_PLATFORM_NAME_LOWERCASE}.cmake +) diff --git a/Code/LauncherUnified/launcher_generator.cmake b/Code/LauncherUnified/launcher_generator.cmake index c5d60eb29e..2f4c8a8b74 100644 --- a/Code/LauncherUnified/launcher_generator.cmake +++ b/Code/LauncherUnified/launcher_generator.cmake @@ -16,6 +16,7 @@ set_property(GLOBAL PROPERTY LAUNCHER_UNIFIED_BINARY_DIR ${CMAKE_CURRENT_BINARY_ # When using an installed engine, this file will be included by the FindLauncherGenerator.cmake script get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME) foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJECTS) + # Computes the realpath to the project # If the project_path is relative, it is evaluated relative to the ${LY_ROOT_FOLDER} # Otherwise the the absolute project_path is returned with symlinks resolved @@ -35,6 +36,28 @@ foreach(project_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJEC "to the LY_PROJECTS_TARGET_NAME global property. Other configuration errors might occur") endif() endif() + + ################################################################################ + # Assets + ################################################################################ + if(PAL_TRAIT_BUILD_HOST_TOOLS) + add_custom_target(${project_name}.Assets + COMMENT "Processing ${project_name} assets..." + COMMAND "${CMAKE_COMMAND}" + -DLY_LOCK_FILE=$/project_assets.lock + -P ${LY_ROOT_FOLDER}/cmake/CommandExecution.cmake + EXEC_COMMAND $ + --zeroAnalysisMode + --project-path=${project_real_path} + --platforms=${LY_ASSET_DEPLOY_ASSET_TYPE} + ) + set_target_properties(${project_name}.Assets + PROPERTIES + EXCLUDE_FROM_ALL TRUE + FOLDER ${project_name} + ) + endif() + ################################################################################ # Monolithic game ################################################################################ diff --git a/Code/Tools/AzTestRunner/CMakeLists.txt b/Code/Tools/AzTestRunner/CMakeLists.txt index d3598c397e..e6dd09e15b 100644 --- a/Code/Tools/AzTestRunner/CMakeLists.txt +++ b/Code/Tools/AzTestRunner/CMakeLists.txt @@ -9,12 +9,12 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # -if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) +ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}) - ly_get_list_relative_pal_filename(pal_dir ${CMAKE_CURRENT_LIST_DIR}/Platform/${PAL_PLATFORM_NAME}) - - include(${pal_dir}/platform_traits_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) +include(${pal_dir}/platform_traits_${PAL_PLATFORM_NAME_LOWERCASE}.cmake) +if(PAL_TRAIT_AZTESTRUNNER_SUPPORTED) + ly_add_target( NAME AzTestRunner ${PAL_TRAIT_AZTESTRUNNER_LAUNCHER_TYPE} NAMESPACE AZ @@ -32,19 +32,23 @@ if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) AZ::AzTest AZ::AzFramework ) + + if(PAL_TRAIT_BUILD_TESTS_SUPPORTED) + + ly_add_target( + NAME AzTestRunner.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} + NAMESPACE AZ + FILES_CMAKE + aztestrunner_test_files.cmake + BUILD_DEPENDENCIES + PRIVATE + AZ::AzTest + ) - ly_add_target( - NAME AzTestRunner.Tests ${PAL_TRAIT_TEST_TARGET_TYPE} - NAMESPACE AZ - FILES_CMAKE - aztestrunner_test_files.cmake - BUILD_DEPENDENCIES - PRIVATE - AZ::AzTest - ) + ly_add_googletest( + NAME AZ::AzTestRunner.Tests + ) - ly_add_googletest( - NAME AZ::AzTestRunner.Tests - ) + endif() endif() diff --git a/Code/Tools/AzTestRunner/Platform/Android/platform_traits_android.cmake b/Code/Tools/AzTestRunner/Platform/Android/platform_traits_android.cmake index 40de4bd3eb..77d7b868d4 100644 --- a/Code/Tools/AzTestRunner/Platform/Android/platform_traits_android.cmake +++ b/Code/Tools/AzTestRunner/Platform/Android/platform_traits_android.cmake @@ -9,5 +9,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(PAL_TRAIT_AZTESTRUNNER_SUPPORTED TRUE) set(PAL_TRAIT_AZTESTRUNNER_LAUNCHER_TYPE MODULE) - diff --git a/Code/Tools/AzTestRunner/Platform/Linux/platform_traits_linux.cmake b/Code/Tools/AzTestRunner/Platform/Linux/platform_traits_linux.cmake index 59922965bb..4c623c1f7b 100644 --- a/Code/Tools/AzTestRunner/Platform/Linux/platform_traits_linux.cmake +++ b/Code/Tools/AzTestRunner/Platform/Linux/platform_traits_linux.cmake @@ -9,5 +9,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(PAL_TRAIT_AZTESTRUNNER_SUPPORTED TRUE) set(PAL_TRAIT_AZTESTRUNNER_LAUNCHER_TYPE EXECUTABLE) - diff --git a/Code/Tools/AzTestRunner/Platform/Mac/platform_traits_mac.cmake b/Code/Tools/AzTestRunner/Platform/Mac/platform_traits_mac.cmake index 59922965bb..4c623c1f7b 100644 --- a/Code/Tools/AzTestRunner/Platform/Mac/platform_traits_mac.cmake +++ b/Code/Tools/AzTestRunner/Platform/Mac/platform_traits_mac.cmake @@ -9,5 +9,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(PAL_TRAIT_AZTESTRUNNER_SUPPORTED TRUE) set(PAL_TRAIT_AZTESTRUNNER_LAUNCHER_TYPE EXECUTABLE) - diff --git a/Code/Tools/AzTestRunner/Platform/Windows/platform_traits_windows.cmake b/Code/Tools/AzTestRunner/Platform/Windows/platform_traits_windows.cmake index 59922965bb..4c623c1f7b 100644 --- a/Code/Tools/AzTestRunner/Platform/Windows/platform_traits_windows.cmake +++ b/Code/Tools/AzTestRunner/Platform/Windows/platform_traits_windows.cmake @@ -9,5 +9,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(PAL_TRAIT_AZTESTRUNNER_SUPPORTED TRUE) set(PAL_TRAIT_AZTESTRUNNER_LAUNCHER_TYPE EXECUTABLE) - diff --git a/Code/Tools/AzTestRunner/Platform/iOS/platform_traits_ios.cmake b/Code/Tools/AzTestRunner/Platform/iOS/platform_traits_ios.cmake index 59922965bb..4c623c1f7b 100644 --- a/Code/Tools/AzTestRunner/Platform/iOS/platform_traits_ios.cmake +++ b/Code/Tools/AzTestRunner/Platform/iOS/platform_traits_ios.cmake @@ -9,5 +9,5 @@ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # +set(PAL_TRAIT_AZTESTRUNNER_SUPPORTED TRUE) set(PAL_TRAIT_AZTESTRUNNER_LAUNCHER_TYPE EXECUTABLE) - diff --git a/cmake/Platform/Common/Install_common.cmake b/cmake/Platform/Common/Install_common.cmake index 4aeaf21e95..a579e3128d 100644 --- a/cmake/Platform/Common/Install_common.cmake +++ b/cmake/Platform/Common/Install_common.cmake @@ -162,7 +162,18 @@ function(ly_setup_target OUTPUT_CONFIGURED_TARGET ALIAS_TARGET_NAME) elseif(target_type STREQUAL MODULE_LIBRARY) set(target_location "\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$/${target_library_output_subdirectory}/$") elseif(target_type STREQUAL SHARED_LIBRARY) - string(APPEND target_file_contents "set_property(TARGET ${TARGET_NAME} PROPERTY IMPORTED_IMPLIB_$ \"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$/$\")\n") + string(APPEND target_file_contents +"set_property(TARGET ${TARGET_NAME} + APPEND_STRING PROPERTY IMPORTED_IMPLIB + $<$$:\"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$/$\"$ +) +") + string(APPEND target_file_contents +"set_property(TARGET ${TARGET_NAME} + PROPERTY IMPORTED_IMPLIB_$> + \"\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$/$\" +) +") set(target_location "\${LY_ROOT_FOLDER}/${library_output_directory}/${PAL_PLATFORM_NAME}/$/${target_library_output_subdirectory}/$") else() # STATIC_LIBRARY, OBJECT_LIBRARY, INTERFACE_LIBRARY set(target_location "\${LY_ROOT_FOLDER}/${archive_output_directory}/${PAL_PLATFORM_NAME}/$/$") diff --git a/cmake/Platform/Common/VisualStudio_common.cmake b/cmake/Platform/Common/VisualStudio_common.cmake index fd38a8c7ce..9a23a26d34 100644 --- a/cmake/Platform/Common/VisualStudio_common.cmake +++ b/cmake/Platform/Common/VisualStudio_common.cmake @@ -10,5 +10,5 @@ # if(CMAKE_GENERATOR MATCHES "Visual Studio 16") - configure_file("${CMAKE_CURRENT_LIST_DIR}/Directory.Build.props" "${CMAKE_CURRENT_BINARY_DIR}/Directory.Build.props" COPYONLY) + configure_file("${CMAKE_CURRENT_LIST_DIR}/Directory.Build.props" "${CMAKE_BINARY_DIR}/Directory.Build.props" COPYONLY) endif() \ No newline at end of file diff --git a/scripts/ctest/CMakeLists.txt b/scripts/ctest/CMakeLists.txt index f9824889e3..575be53cc7 100644 --- a/scripts/ctest/CMakeLists.txt +++ b/scripts/ctest/CMakeLists.txt @@ -16,35 +16,6 @@ if(NOT PAL_TRAIT_BUILD_TESTS_SUPPORTED) return() endif() -################################################################################ -# Asset Processing Target -# i.e. Tests depend on AutomatedTesting.Assets -################################################################################ - -if(PAL_TRAIT_BUILD_TESTS_SUPPORTED AND PAL_TRAIT_BUILD_HOST_TOOLS) - get_property(LY_PROJECTS_TARGET_NAME GLOBAL PROPERTY LY_PROJECTS_TARGET_NAME) - foreach(project_target_name project_path IN ZIP_LISTS LY_PROJECTS_TARGET_NAME LY_PROJECTS) - file(REAL_PATH ${project_path} project_real_path BASE_DIRECTORY ${LY_ROOT_FOLDER}) - # With the lock file, asset processing jobs are serialized to avoid race conditions - # on files that are created temporarily in source folders during shader processing. - add_custom_target(${project_target_name}.Assets - COMMENT "Processing ${project_target_name} assets..." - COMMAND "${CMAKE_COMMAND}" - -DLY_LOCK_FILE=$/project_assets.lock - -P ${LY_ROOT_FOLDER}/cmake/CommandExecution.cmake - EXEC_COMMAND $ - --zeroAnalysisMode - --project-path=${project_real_path} - --platforms=${LY_ASSET_DEPLOY_ASSET_TYPE} - ) - set_target_properties(${project_target_name}.Assets - PROPERTIES - EXCLUDE_FROM_ALL TRUE - FOLDER ${project_target_name} - ) - endforeach() -endif() - ################################################################################ # Tests ################################################################################ From 5f82e5a11134a4571a6b69d351a178cd6faf5372 Mon Sep 17 00:00:00 2001 From: bosnichd Date: Tue, 8 Jun 2021 15:15:20 -0600 Subject: [PATCH 045/244] Fix typo. (#1192) --- Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYCommonMenu.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYCommonMenu.cpp b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYCommonMenu.cpp index 5107a02835..c750aea38d 100644 --- a/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYCommonMenu.cpp +++ b/Gems/ImGui/Code/Source/LYCommonMenu/ImGuiLYCommonMenu.cpp @@ -693,7 +693,7 @@ namespace ImGui ImGui::TextColored(ImGui::Colors::s_PlainLabelColor, "Left Stick"); ImGui::NextColumn(); ImGui::Bullet(); - ImGui::TextColored(ImGui::Colors::s_PlainLabelColor, "Mova Mouse Pointer"); + ImGui::TextColored(ImGui::Colors::s_PlainLabelColor, "Move Mouse Pointer"); ImGui::Separator(); ImGui::NextColumn(); From b1fca488bf94b66d65e9421d2e5600af778b4763 Mon Sep 17 00:00:00 2001 From: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com> Date: Tue, 8 Jun 2021 14:24:22 -0700 Subject: [PATCH 046/244] LYN-4332 Metric jobs not passing JOB_NAME, BUILD_NUMBER, NODE_NAME, CHANGE_ID (#1190) * Fix quotes * Revert "Fix quotes" This reverts commit 29ace5ef2bf1c78991a8cfeb840bfb30c4ce5d8d. * evaluating the parameters * Revert "Revert "Fix quotes"" This reverts commit 4f7008e9ccbd5fdc0b33853a4fb1f50285233da9. * just one eval * double escaping * another attempt to happiness * changing NODE_NAME to LABEL_NAME since that one is more stable and doesnt have spaces --- scripts/build/Platform/Linux/build_config.json | 2 +- scripts/build/Platform/Linux/python_linux.sh | 4 ++-- scripts/build/Platform/Mac/build_config.json | 2 +- scripts/build/Platform/Mac/python_mac.sh | 4 ++-- scripts/build/Platform/Windows/build_config.json | 2 +- scripts/build/Platform/iOS/build_config.json | 2 +- 6 files changed, 8 insertions(+), 8 deletions(-) diff --git a/scripts/build/Platform/Linux/build_config.json b/scripts/build/Platform/Linux/build_config.json index ee6da77b29..660bc50da6 100644 --- a/scripts/build/Platform/Linux/build_config.json +++ b/scripts/build/Platform/Linux/build_config.json @@ -24,7 +24,7 @@ "COMMAND": "python_linux.sh", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS": "--platform Linux --jobname '${JOB_NAME}' --jobnumber '${BUILD_NUMBER}' --jobnode '${NODE_NAME}' --changelist '${CHANGE_ID}'" + "SCRIPT_PARAMETERS": "--platform Linux --jobname=\\'${JOB_NAME}\\' --jobnumber \\'${BUILD_NUMBER}\\' --jobnode \\'${NODE_LABEL}\\' --changelist \\'${CHANGE_ID}\\'" } }, "debug": { diff --git a/scripts/build/Platform/Linux/python_linux.sh b/scripts/build/Platform/Linux/python_linux.sh index 6e1bd73b36..0fe205fcc2 100755 --- a/scripts/build/Platform/Linux/python_linux.sh +++ b/scripts/build/Platform/Linux/python_linux.sh @@ -12,5 +12,5 @@ set -o errexit # exit on the first failure encountered -echo [ci_build] python/python.sh -u ${SCRIPT_PATH} ${SCRIPT_PARAMETERS} -python/python.sh -u ${SCRIPT_PATH} ${SCRIPT_PARAMETERS} \ No newline at end of file +echo [ci_build] python/python.sh -u ${SCRIPT_PATH} $(eval echo ${SCRIPT_PARAMETERS}) +python/python.sh -u ${SCRIPT_PATH} $(eval echo ${SCRIPT_PARAMETERS}) \ No newline at end of file diff --git a/scripts/build/Platform/Mac/build_config.json b/scripts/build/Platform/Mac/build_config.json index 971e5e47a1..c02227c613 100644 --- a/scripts/build/Platform/Mac/build_config.json +++ b/scripts/build/Platform/Mac/build_config.json @@ -24,7 +24,7 @@ "COMMAND": "python_mac.sh", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS": "--platform Mac --jobname '${JOB_NAME}' --jobnumber '${BUILD_NUMBER}' --jobnode '${NODE_NAME}' --changelist '${CHANGE_ID}'" + "SCRIPT_PARAMETERS": "--platform Mac --jobname \\'${JOB_NAME}\\' --jobnumber \\'${BUILD_NUMBER}\\' --jobnode \\'${NODE_LABEL}\\' --changelist \\'${CHANGE_ID}\\'" } }, "debug": { diff --git a/scripts/build/Platform/Mac/python_mac.sh b/scripts/build/Platform/Mac/python_mac.sh index 6e1bd73b36..0fe205fcc2 100755 --- a/scripts/build/Platform/Mac/python_mac.sh +++ b/scripts/build/Platform/Mac/python_mac.sh @@ -12,5 +12,5 @@ set -o errexit # exit on the first failure encountered -echo [ci_build] python/python.sh -u ${SCRIPT_PATH} ${SCRIPT_PARAMETERS} -python/python.sh -u ${SCRIPT_PATH} ${SCRIPT_PARAMETERS} \ No newline at end of file +echo [ci_build] python/python.sh -u ${SCRIPT_PATH} $(eval echo ${SCRIPT_PARAMETERS}) +python/python.sh -u ${SCRIPT_PATH} $(eval echo ${SCRIPT_PARAMETERS}) \ No newline at end of file diff --git a/scripts/build/Platform/Windows/build_config.json b/scripts/build/Platform/Windows/build_config.json index 552ef2c6fd..71abf9021f 100644 --- a/scripts/build/Platform/Windows/build_config.json +++ b/scripts/build/Platform/Windows/build_config.json @@ -56,7 +56,7 @@ "COMMAND": "python_windows.cmd", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS": "--platform Windows --jobname \"!JOB_NAME!\" --jobnumber \"!BUILD_NUMBER!\" --jobnode \"!NODE_NAME!\" --changelist \"!CHANGE_ID!\"" + "SCRIPT_PARAMETERS": "--platform Windows --jobname \"!JOB_NAME!\" --jobnumber \"!BUILD_NUMBER!\" --jobnode \"!NODE_LABEL!\" --changelist \"!CHANGE_ID!\"" } }, "windows_packaging_all": { diff --git a/scripts/build/Platform/iOS/build_config.json b/scripts/build/Platform/iOS/build_config.json index 2d9c57f6ee..9fd0f8c7fc 100644 --- a/scripts/build/Platform/iOS/build_config.json +++ b/scripts/build/Platform/iOS/build_config.json @@ -14,7 +14,7 @@ "COMMAND": "../Mac/python_mac.sh", "PARAMETERS": { "SCRIPT_PATH": "scripts/build/ci_build_metrics.py", - "SCRIPT_PARAMETERS": "--platform iOS --jobname '${JOB_NAME}' --jobnumber '${BUILD_NUMBER}' --jobnode '${NODE_NAME}' --changelist '${CHANGE_ID}'" + "SCRIPT_PARAMETERS": "--platform iOS --jobname '${JOB_NAME}' --jobname \\'${JOB_NAME}\\' --jobnumber \\'${BUILD_NUMBER}\\' --jobnode \\'${NODE_LABEL}\\' --changelist \\'${CHANGE_ID}\\'" } }, "debug": { From ef2d89a8435b43b71ee5baeb95b3a72a6f861695 Mon Sep 17 00:00:00 2001 From: "Tom \"spot\" Callaway" <72474383+spotaws@users.noreply.github.com> Date: Tue, 8 Jun 2021 17:38:52 -0400 Subject: [PATCH 047/244] fix AzGenericTypeInfo template handling with clang 12+ (#833) Co-authored-by: Tom spot Callaway --- Code/Framework/AzCore/AzCore/RTTI/TypeInfo.h | 21 ++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Code/Framework/AzCore/AzCore/RTTI/TypeInfo.h b/Code/Framework/AzCore/AzCore/RTTI/TypeInfo.h index 0a7d6367a6..be64f384c7 100644 --- a/Code/Framework/AzCore/AzCore/RTTI/TypeInfo.h +++ b/Code/Framework/AzCore/AzCore/RTTI/TypeInfo.h @@ -150,8 +150,13 @@ namespace AZ // also needs to be an overload for every version because they all represent overloads for different non-types. namespace AzGenericTypeInfo { - template - constexpr bool false_v = false; + /// Needs to match declared parameter type. + template