diff --git a/AutomatedReview/Jenkinsfile b/AutomatedReview/Jenkinsfile index 9132b7558b..8cf7a62726 100644 --- a/AutomatedReview/Jenkinsfile +++ b/AutomatedReview/Jenkinsfile @@ -96,7 +96,7 @@ def IsJobEnabled(buildTypeMap, pipelineName, platformName) { if (params[platformName]) { if(buildTypeMap.value.TAGS) { return buildTypeMap.value.TAGS.contains(pipelineName) - } + } } } return false @@ -194,9 +194,9 @@ def GetBuildEnvVars(Map platformEnv, Map buildTypeEnv, String pipelineName) { } buildTypeEnv.each { var -> // This may override the above one if there is an entry defined by the job - envVarMap[var.key] = var.value + envVarMap[var.key] = var.value } - + // Environment that only applies to to Jenkins tweaks. // For 3rdParty downloads, we store them in the EBS volume so we can reuse them across node // instances. This allow us to scale up and down without having to re-download 3rdParty @@ -223,7 +223,7 @@ def PullFilesFromGit(String filenamePath, String branchName, boolean failIfNotFo folderPathParts.remove(folderPathParts.size()-1) // remove the filename def folderPath = folderPathParts.join('/') if (folderPath.contains('*')) { - + def currentPath = '' for (int i = 0; i < folderPathParts.size(); i++) { if (folderPathParts[i] == '*') { @@ -259,7 +259,7 @@ def PullFilesFromGit(String filenamePath, String branchName, boolean failIfNotFo } else { - def errorFile = "${folderPath}/error.txt" + def errorFile = "${folderPath}/error.txt" palMkdir(folderPath) retry(3) { try { @@ -273,7 +273,7 @@ def PullFilesFromGit(String filenamePath, String branchName, boolean failIfNotFo win_filenamePath = filenamePath.replace('/', '\\') bat label: "Downloading ${win_filenamePath}", script: "aws codecommit get-file --repository-name ${repositoryName} --commit-specifier ${branchName} --file-path ${filenamePath} --query fileContent --output text 2>${errorFile} > ${win_filenamePath}_encoded" - bat label: 'Decoding', + bat label: 'Decoding', script: "certutil -decode ${win_filenamePath}_encoded ${win_filenamePath}" } palRm("${filenamePath}_encoded") @@ -296,7 +296,7 @@ def SetLfsCredentials(cmd, lbl = '') { if (env.IS_UNIX) { sh label: lbl, script: cmd - } else { + } else { bat label: lbl, script: cmd } @@ -330,7 +330,7 @@ def CheckoutRepo(boolean disableSubmodules = false) { if(fileExists('.git')) { // If the repository after checkout is locked, likely we took a snapshot while git was running, - // to leave the repo in a usable state, garbagecollect. This also helps in situations where + // to leave the repo in a usable state, garbagecollect. This also helps in situations where def indexLockFile = '.git/index.lock' if(fileExists(indexLockFile)) { palSh('git gc', 'Git GarbageCollect') @@ -380,7 +380,7 @@ def CheckoutRepo(boolean disableSubmodules = false) { // Add folder where we will store the 3rdParty downloads and packages if(!fileExists('3rdParty')) { palMkdir('3rdParty') - } + } dir(ENGINE_REPOSITORY_NAME) { // Run lfs in a separate step. Jenkins is unable to load the credentials for the custom LFS endpoint @@ -419,7 +419,7 @@ def PreBuildCommonSteps(Map pipelineConfig, String projectName, String pipeline, sh label: 'Setting volume\'s ownership', script: """ if sudo test ! -d "${workspace}"; then - sudo mkdir -p ${workspace} + sudo mkdir -p ${workspace} cd ${workspace}/.. sudo chown -R lybuilder:root . fi diff --git a/Code/Sandbox/Editor/EditorViewportWidget.cpp b/Code/Sandbox/Editor/EditorViewportWidget.cpp index 1be7411f8a..a3b2542418 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.cpp +++ b/Code/Sandbox/Editor/EditorViewportWidget.cpp @@ -30,6 +30,7 @@ #include #include #include +#include // AzFramework #include @@ -98,6 +99,10 @@ #include +AZ_CVAR( + bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null, + "Output the timing of the new IVisibilitySystem query"); + EditorViewportWidget* EditorViewportWidget::m_pPrimaryViewport = nullptr; #if AZ_TRAIT_OS_PLATFORM_APPLE @@ -145,35 +150,6 @@ namespace AZ::ViewportHelpers }; } // namespace AZ::ViewportHelpers -struct EditorViewportWidget::SScopedCurrentContext -{ - const EditorViewportWidget* m_viewport; - EditorViewportWidget::SPreviousContext m_previousContext; - - explicit SScopedCurrentContext(const EditorViewportWidget* viewport) - : m_viewport(viewport) - { - m_previousContext = viewport->SetCurrentContext(); - - // During normal updates of RenderViewport the value of m_cameraSetForWidgetRenderingCount is expected to be 0. - // This is to guarantee no loss in performance by tracking unnecessary calls to SetCurrentContext/RestorePreviousContext. - // If some code makes additional calls to Pre/PostWidgetRendering then the assert will be triggered because - // m_cameraSetForWidgetRenderingCount will be greater than 0. - // There is a legitimate case where the counter can be greater than 0. This is when QtViewport is processing mouse callbacks. - // QtViewport::MouseCallback() is surrounded by Pre/PostWidgetRendering and the m_processingMouseCallbacksCounter - // tracks this specific case. If an update of a RenderViewport happens while processing the mouse callback, - // for example when showing a QMessageBox, then both counters must match. - AZ_Assert(viewport->m_cameraSetForWidgetRenderingCount == viewport->m_processingMouseCallbacksCounter, - "SScopedCurrentContext constructor was called while viewport widget context is active " - "- this is unnecessary"); - } - - ~SScopedCurrentContext() - { - m_viewport->RestorePreviousContext(m_previousContext); - } -}; - ////////////////////////////////////////////////////////////////////////// // EditorViewportWidget ////////////////////////////////////////////////////////////////////////// @@ -230,7 +206,7 @@ EditorViewportWidget::EditorViewportWidget(const QString& name, QWidget* parent) m_manipulatorManager = GetIEditor()->GetViewManager()->GetManipulatorManager(); if (!m_pPrimaryViewport) { - m_pPrimaryViewport = this; + SetAsActiveViewport(); } } @@ -495,7 +471,7 @@ void EditorViewportWidget::Update() { if (CheckRespondToInput()) // If this is the focused window, set primary viewport. { - m_pPrimaryViewport = this; + SetAsActiveViewport(); } else if (!m_bUpdateViewport) // Skip this viewport. { @@ -552,8 +528,6 @@ void EditorViewportWidget::Update() // Render { - SScopedCurrentContext context(this); - // TODO: Move out this logic to a controller and refactor to work with Atom // m_renderer->SetClearColor(Vec3(0.4f, 0.4f, 0.4f)); // 3D engine stats @@ -587,6 +561,19 @@ void EditorViewportWidget::Update() gEnv->pSystem->SetViewCamera(CurCamera); } + { + auto start = std::chrono::steady_clock::now(); + + m_entityVisibilityQuery.UpdateVisibility(GetCameraState()); + + if (ed_visibility_logTiming) + { + auto stop = std::chrono::steady_clock::now(); + std::chrono::duration diff = stop - start; + AZ_Printf("Visibility", "FindVisibleEntities (new) - Duration: %f", diff); + } + } + QtViewport::Update(); PopDisableRendering(); @@ -686,17 +673,13 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event) if (deviceInfo) { + // Note: This may also need to adjust the viewport size outputToHMD->Set(1); - m_previousContext = SetCurrentContext(deviceInfo->renderWidth, deviceInfo->renderHeight); SetActiveWindow(); SetFocus(); SetSelected(true); } } - else - { - m_previousContext = SetCurrentContext(); - } SetCurrentCursor(STD_CURSOR_GAME); } } @@ -710,7 +693,6 @@ void EditorViewportWidget::OnEditorNotifyEvent(EEditorNotifyEvent event) { outputToHMD->Set(0); } - RestorePreviousContext(m_previousContext); m_bInRotateMode = false; m_bInMoveMode = false; m_bInOrbitMode = false; @@ -1180,15 +1162,7 @@ void EditorViewportWidget::FindVisibleEntities(AZStd::vector& visi { FUNCTION_PROFILER(GetIEditor()->GetSystem(), PROFILE_EDITOR); - if (m_displayContext.GetView() == nullptr) - { - return; - } - - const AZStd::vector& entityIdCache = - m_displayContext.GetView()->GetVisibleObjectsCache()->GetEntityIdCache(); - - visibleEntitiesOut.assign(entityIdCache.begin(), entityIdCache.end()); + visibleEntitiesOut.assign(m_entityVisibilityQuery.Begin(), m_entityVisibilityQuery.End()); } QPoint EditorViewportWidget::ViewportWorldToScreen(const AZ::Vector3& worldPosition) @@ -1233,6 +1207,7 @@ void EditorViewportWidget::SetViewportId(int id) // Now that we have an ID, we can initialize our viewport. m_renderViewport = new AtomToolsFramework::RenderViewportWidget(id, this); + m_defaultViewportContextName = m_renderViewport->GetViewportContext()->GetName(); QBoxLayout* layout = new QBoxLayout(QBoxLayout::Direction::TopToBottom, this); layout->setContentsMargins(QMargins()); layout->addWidget(m_renderViewport); @@ -1253,6 +1228,11 @@ void EditorViewportWidget::SetViewportId(int id) } UpdateScene(); + + if (m_pPrimaryViewport == this) + { + SetAsActiveViewport(); + } } void EditorViewportWidget::ConnectViewportInteractionRequestBus() @@ -1999,9 +1979,6 @@ void EditorViewportWidget::RenderSelectedRegion() Vec3 EditorViewportWidget::WorldToView3D(const Vec3& wp, [[maybe_unused]] int nFlags) const { - AZ_Assert(m_cameraSetForWidgetRenderingCount > 0, - "WorldToView3D was called but viewport widget rendering was not set. PreWidgetRendering must be called before."); - Vec3 out(0, 0, 0); float x, y, z; @@ -2020,10 +1997,6 @@ Vec3 EditorViewportWidget::WorldToView3D(const Vec3& wp, [[maybe_unused]] int nF ////////////////////////////////////////////////////////////////////////// QPoint EditorViewportWidget::WorldToView(const Vec3& wp) const { - AZ_Assert(m_cameraSetForWidgetRenderingCount > 0, - "WorldToView was called but viewport widget rendering was not set. PreWidgetRendering must be called before."); - - return m_renderViewport->ViewportWorldToScreen(LYVec3ToAZVec3(wp)); } ////////////////////////////////////////////////////////////////////////// @@ -2191,9 +2164,6 @@ void EditorViewportWidget::ProjectToScreen(float ptx, float pty, float ptz, floa ////////////////////////////////////////////////////////////////////////// void EditorViewportWidget::ViewToWorldRay(const QPoint& vp, Vec3& raySrc, Vec3& rayDir) const { - AZ_Assert(m_cameraSetForWidgetRenderingCount > 0, - "ViewToWorldRay was called but SScopedCurrentContext was not set at a higher scope! This means the camera for this call is incorrect."); - QRect rc = m_rcClient; Vec3 pos0, pos1; @@ -2258,7 +2228,7 @@ bool EditorViewportWidget::CheckRespondToInput() const return false; } - if (!hasFocus()) + if (!hasFocus() && !m_renderViewport->hasFocus()) { return false; } @@ -2663,55 +2633,6 @@ void EditorViewportWidget::OnStopPlayInEditor() } } -////////////////////////////////////////////////////////////////////////// -EditorViewportWidget::SPreviousContext EditorViewportWidget::SetCurrentContext(int /*newWidth*/, int /*newHeight*/) const -{ - SPreviousContext x; - - return x; -} - -////////////////////////////////////////////////////////////////////////// -EditorViewportWidget::SPreviousContext EditorViewportWidget::SetCurrentContext() const -{ - const auto r = rect(); - return SetCurrentContext(r.width(), r.height()); -} - -////////////////////////////////////////////////////////////////////////// -void EditorViewportWidget::RestorePreviousContext(const SPreviousContext& /*x*/) const -{ -} - -void EditorViewportWidget::PreWidgetRendering() -{ - // if we have not already set the render context for the viewport, do it now - // based on the current state of the renderer/viewport, record the previous - // context to restore afterwards - if (m_cameraSetForWidgetRenderingCount == 0) - { - m_preWidgetContext = SetCurrentContext(); - } - - // keep track of how many times we've attempted to update the context - m_cameraSetForWidgetRenderingCount++; -} - -void EditorViewportWidget::PostWidgetRendering() -{ - if (m_cameraSetForWidgetRenderingCount > 0) - { - m_cameraSetForWidgetRenderingCount--; - - // unwinding - when the viewport context is no longer required, - // restore the previous context when widget rendering first began - if (m_cameraSetForWidgetRenderingCount == 0) - { - RestorePreviousContext(m_preWidgetContext); - } - } -} - ////////////////////////////////////////////////////////////////////////// void EditorViewportWidget::OnCameraFOVVariableChanged([[maybe_unused]] IVariable* var) { @@ -2915,4 +2836,36 @@ void EditorViewportWidget::UpdateCameraFromViewportContext() m_Camera.SetZRange(cameraState.m_nearClip, cameraState.m_farClip); } +void EditorViewportWidget::SetAsActiveViewport() +{ + auto viewportContextManager = AZ::Interface::Get(); + + const AZ::Name defaultContextName = viewportContextManager->GetDefaultViewportContextName(); + + // If another viewport was active before, restore its name to its per-ID one. + if (m_pPrimaryViewport && m_pPrimaryViewport != this && m_pPrimaryViewport->m_renderViewport) + { + auto viewportContext = m_pPrimaryViewport->m_renderViewport->GetViewportContext(); + if (viewportContext) + { + // Remove the old viewport's camera from the stack, as it's no longer the owning viewport + viewportContextManager->PopView(defaultContextName, viewportContext->GetDefaultView()); + viewportContextManager->RenameViewportContext(viewportContext, m_pPrimaryViewport->m_defaultViewportContextName); + } + } + + m_pPrimaryViewport = this; + if (m_renderViewport) + { + auto viewportContext = m_renderViewport->GetViewportContext(); + if (viewportContext) + { + // Push our camera onto the default viewport's view stack to preserve camera state continuity + // Other views can still be pushed on top of our view for e.g. game mode + viewportContextManager->PushView(defaultContextName, viewportContext->GetDefaultView()); + viewportContextManager->RenameViewportContext(viewportContext, defaultContextName); + } + } +} + #include diff --git a/Code/Sandbox/Editor/EditorViewportWidget.h b/Code/Sandbox/Editor/EditorViewportWidget.h index b7f9bda6d2..1244e61242 100644 --- a/Code/Sandbox/Editor/EditorViewportWidget.h +++ b/Code/Sandbox/Editor/EditorViewportWidget.h @@ -354,26 +354,6 @@ protected: void RenderAll(); - struct SPreviousContext - { - CCamera rendererCamera; - HWND window; - int width; - int height; - bool mainViewport; - }; - - SPreviousContext m_preWidgetContext; - - // Create an auto-sized render context that is sized based on the Editor's current - // viewport. - SPreviousContext SetCurrentContext() const; - - SPreviousContext SetCurrentContext(int newWidth, int newHeight) const; - void RestorePreviousContext(const SPreviousContext& x) const; - - void PreWidgetRendering() override; - void PostWidgetRendering() override; void OnBeginPrepareRender() override; // Update the safe frame, safe action, safe title, and borders rectangles based on @@ -579,6 +559,7 @@ protected: void BuildDragDropContext(AzQtComponents::ViewportDragContext& context, const QPoint& pt) override; private: + void SetAsActiveViewport(); void PushDisableRendering(); void PopDisableRendering(); bool IsRenderingDisabled() const; @@ -606,13 +587,10 @@ private: AzFramework::EntityVisibilityQuery m_entityVisibilityQuery; - SPreviousContext m_previousContext; QSet m_keyDown; bool m_freezeViewportInput = false; - size_t m_cameraSetForWidgetRenderingCount = 0; ///< How many calls to PreWidgetRendering happened before - ///< subsequent calls to PostWidetRendering. AZStd::shared_ptr m_manipulatorManager; // Used to prevent circular set camera events @@ -627,5 +605,7 @@ private: AZ::RPI::ViewportContext::MatrixChangedEvent::Handler m_cameraProjectionMatrixChangeHandler; AzFramework::DebugDisplayRequests* m_debugDisplay = nullptr; + AZ::Name m_defaultViewportContextName; + AZ_POP_DISABLE_DLL_EXPORT_MEMBER_WARNING }; diff --git a/Code/Sandbox/Editor/RenderViewport.cpp b/Code/Sandbox/Editor/RenderViewport.cpp index e8de2e7b51..213a4ed895 100644 --- a/Code/Sandbox/Editor/RenderViewport.cpp +++ b/Code/Sandbox/Editor/RenderViewport.cpp @@ -94,9 +94,6 @@ AZ_CVAR( bool, ed_visibility_use, true, nullptr, AZ::ConsoleFunctorFlags::Null, "Enable/disable using the new IVisibilitySystem for Entity visibility determination"); -AZ_CVAR( - bool, ed_visibility_logTiming, false, nullptr, AZ::ConsoleFunctorFlags::Null, - "Output the timing of the new IVisibilitySystem query"); CRenderViewport* CRenderViewport::m_pPrimaryViewport = nullptr; @@ -1394,13 +1391,6 @@ void CRenderViewport::Update() auto start = std::chrono::steady_clock::now(); m_entityVisibilityQuery.UpdateVisibility(GetCameraState()); - - if (ed_visibility_logTiming) - { - auto stop = std::chrono::steady_clock::now(); - std::chrono::duration diff = stop - start; - AZ_Printf("Visibility", "FindVisibleEntities (new) - Duration: %f", diff); - } } { diff --git a/Code/Sandbox/Editor/Viewport.cpp b/Code/Sandbox/Editor/Viewport.cpp index dbedb01228..ae2de224cb 100644 --- a/Code/Sandbox/Editor/Viewport.cpp +++ b/Code/Sandbox/Editor/Viewport.cpp @@ -218,10 +218,11 @@ QtViewport::QtViewport(QWidget* parent) // Create drop target to handle Qt drop events. setAcceptDrops(true); - m_renderOverlay.setVisible(false); + m_renderOverlay.setVisible(true); m_renderOverlay.setUpdatesEnabled(false); m_renderOverlay.setMouseTracking(true); m_renderOverlay.setObjectName("renderOverlay"); + m_renderOverlay.winId(); // Force the render overlay to create a backing native window m_viewportUi.InitializeViewportUi(this, &m_renderOverlay); diff --git a/Code/Sandbox/Editor/Viewport.h b/Code/Sandbox/Editor/Viewport.h index 6e483e7150..acc5a3acfb 100644 --- a/Code/Sandbox/Editor/Viewport.h +++ b/Code/Sandbox/Editor/Viewport.h @@ -280,7 +280,7 @@ public: virtual CViewport *asCViewport() { return this; } protected: - CLayoutViewPane* m_viewPane; + CLayoutViewPane* m_viewPane = nullptr; CViewManager* m_viewManager; AZ_PUSH_DISABLE_DLL_EXPORT_MEMBER_WARNING // Viewport matrix. diff --git a/Code/Sandbox/Editor/ViewportManipulatorController.cpp b/Code/Sandbox/Editor/ViewportManipulatorController.cpp index fd8ed4dfbf..b45dc711ee 100644 --- a/Code/Sandbox/Editor/ViewportManipulatorController.cpp +++ b/Code/Sandbox/Editor/ViewportManipulatorController.cpp @@ -21,8 +21,8 @@ #include -static const auto ManipulatorPriority = AzFramework::ViewportControllerPriority::High; -static const auto InteractionPriority = AzFramework::ViewportControllerPriority::Low; +static const auto ManipulatorPriority = AzFramework::ViewportControllerPriority::Highest; +static const auto InteractionPriority = AzFramework::ViewportControllerPriority::High; namespace SandboxEditor { @@ -126,12 +126,20 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram m_state.m_mouseButtons.m_mouseButtons |= static_cast(mouseButton); if (IsDoubleClick(mouseButton)) { - m_pendingDoubleClicks.erase(mouseButton); + // Only remove the double click flag once we're done processing both Manipulator and Interaction events + if (event.m_priority == InteractionPriority) + { + m_pendingDoubleClicks.erase(mouseButton); + } eventType = MouseEvent::DoubleClick; } else { - m_pendingDoubleClicks[mouseButton] = m_curTime; + // Only insert the double click timing once we're done processing both Manipulator and Interaction events, to avoid a false IsDoubleClick positive + if (event.m_priority == InteractionPriority) + { + m_pendingDoubleClicks[mouseButton] = m_curTime; + } eventType = MouseEvent::Down; } } @@ -160,7 +168,7 @@ bool ViewportManipulatorControllerInstance::HandleInputChannelEvent(const AzFram { mouseInteraction.m_mouseButtons.m_mouseButtons = static_cast(overrideButton.value()); } - MouseInteractionEvent mouseEvent = MouseInteractionEvent(mouseInteraction, eventType.value()); + mouseInteraction.m_interactionId.m_viewportId = GetViewportId(); // Depending on priority, we dispatch to either the manipulator or viewport interaction event const auto& targetInteractionEvent = diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp index ad9fb1c47e..b67ead9896 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContext.cpp @@ -195,6 +195,9 @@ namespace AZ { m_defaultView = view; UpdatePipelineView(); + + m_viewMatrixChangedEvent.Signal(view->GetWorldToViewMatrix()); + m_projectionMatrixChangedEvent.Signal(view->GetViewToClipMatrix()); } } diff --git a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp index 8427fd0ef1..8d578352d8 100644 --- a/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp +++ b/Gems/Atom/RPI/Code/Source/RPI.Public/ViewportContextManager.cpp @@ -143,7 +143,7 @@ namespace AZ params.renderScene ); viewportContext->GetWindowContext()->RegisterAssociatedViewportContext(viewportContext); - RegisterViewportContext(contextName, viewportContext); + RegisterViewportContext(nameToUse, viewportContext); return viewportContext; } @@ -171,7 +171,9 @@ namespace AZ AZ_Assert(false, "Attempted to rename ViewportContext \"%s\" to \"%s\", but \"%s\" is already assigned to another ViewportContext", viewportContext->m_name.GetCStr(), newContextName.GetCStr(), newContextName.GetCStr()); return; } - RegisterViewportContext(newContextName, viewportContext); + GetOrCreateViewStackForContext(newContextName); + viewportContext->m_name = newContextName; + UpdateViewForContext(newContextName); } void ViewportContextManager::EnumerateViewportContexts(AZStd::function visitorFunction) diff --git a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp index 142de886e2..e08a5a045c 100644 --- a/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp +++ b/Gems/Atom/Tools/AtomToolsFramework/Code/Source/Viewport/RenderViewportWidget.cpp @@ -43,6 +43,7 @@ namespace AtomToolsFramework params.device = AZ::RHI::RHISystemInterface::Get()->GetDevice(); params.windowHandle = reinterpret_cast(winId()); params.id = id; + AzFramework::WindowRequestBus::Handler::BusConnect(params.windowHandle); m_viewportContext = viewportContextManager->CreateViewportContext(AZ::Name(), params); SetControllerList(AZStd::make_shared()); diff --git a/Gems/AtomLyIntegration/AtomBridge/Code/CMakeLists.txt b/Gems/AtomLyIntegration/AtomBridge/Code/CMakeLists.txt index 0eb6898b07..b684e445b3 100644 --- a/Gems/AtomLyIntegration/AtomBridge/Code/CMakeLists.txt +++ b/Gems/AtomLyIntegration/AtomBridge/Code/CMakeLists.txt @@ -21,7 +21,7 @@ ly_add_target( Include COMPILE_DEFINITIONS PRIVATE - ENABLE_ATOM_DEBUG_DISPLAY=0 + ENABLE_ATOM_DEBUG_DISPLAY=1 BUILD_DEPENDENCIES PUBLIC AZ::AtomCore @@ -43,7 +43,7 @@ ly_add_target( Include COMPILE_DEFINITIONS PRIVATE - ENABLE_ATOM_DEBUG_DISPLAY=0 + ENABLE_ATOM_DEBUG_DISPLAY=1 BUILD_DEPENDENCIES PRIVATE Gem::Atom_AtomBridge.Static diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RendPipeline.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RendPipeline.cpp index e5cb83dd1f..1686c56400 100644 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RendPipeline.cpp +++ b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_RendPipeline.cpp @@ -163,7 +163,7 @@ void CAtomShimRenderer::EF_EndEf3D([[maybe_unused]] const int nFlags, [[maybe_un // Only render the UI Canvas and the Console on the main window // If we're not in the editor, don't bother to check viewport. - if (!gEnv->IsEditor() || m_currContext->m_isMainViewport) + if (!gEnv->IsEditor() || m_currContext == nullptr || m_currContext->m_isMainViewport) { EBUS_EVENT(AZ::RenderNotificationsBus, OnScene3DEnd); } diff --git a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.cpp b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.cpp index 08bf5e509f..838dd9a20c 100644 --- a/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.cpp +++ b/Gems/AtomLyIntegration/CryRenderAtomShim/AtomShim_Renderer.cpp @@ -294,7 +294,12 @@ void CAtomShimRenderer::EndFrame() if (!m_viewportContext) { auto viewContextManager = AZ::Interface::Get(); - m_viewportContext = viewContextManager->GetViewportContextByName(viewContextManager->GetDefaultViewportContextName()); + auto viewportContext = viewContextManager->GetViewportContextByName(viewContextManager->GetDefaultViewportContextName()); + // If the viewportContext exists and is created with the default ID, we can safely assume control + if (viewportContext && viewportContext->GetId() == -10) + { + m_viewportContext = viewportContext; + } } if (m_viewportContext) diff --git a/Gems/PythonAssetBuilder/3rdParty/readme.md b/Gems/PythonAssetBuilder/3rdParty/readme.md index c462b15cdb..7a986b06dc 100644 --- a/Gems/PythonAssetBuilder/3rdParty/readme.md +++ b/Gems/PythonAssetBuilder/3rdParty/readme.md @@ -1,4 +1,3 @@ # Python Asset Builder This gem is meant to run Python scripts that want to run as asset builders in the Lumberyard asset processing system. - diff --git a/scripts/build/Jenkins/Jenkinsfile b/scripts/build/Jenkins/Jenkinsfile index 2b146da027..d313cc40ea 100644 --- a/scripts/build/Jenkins/Jenkinsfile +++ b/scripts/build/Jenkins/Jenkinsfile @@ -84,7 +84,7 @@ def IsJobEnabled(buildTypeMap, pipelineName, platformName) { if (params[platformName]) { if(buildTypeMap.value.TAGS) { return buildTypeMap.value.TAGS.contains(pipelineName) - } + } } } return false @@ -161,9 +161,9 @@ def GetBuildEnvVars(Map platformEnv, Map buildTypeEnv, String pipelineName) { } buildTypeEnv.each { var -> // This may override the above one if there is an entry defined by the job - envVarMap[var.key] = var.value + envVarMap[var.key] = var.value } - + // Environment that only applies to to Jenkins tweaks. // For 3rdParty downloads, we store them in the EBS volume so we can reuse them across node // instances. This allow us to scale up and down without having to re-download 3rdParty @@ -185,7 +185,7 @@ def SetLfsCredentials(cmd, lbl = '') { if (env.IS_UNIX) { sh label: lbl, script: cmd - } else { + } else { bat label: lbl, script: cmd } @@ -214,19 +214,17 @@ def CheckoutBootstrapScripts(String branchName) { } def CheckoutRepo(boolean disableSubmodules = false) { - dir(ENGINE_REPOSITORY_NAME) { - palSh('git lfs uninstall', 'Git LFS Uninstall') // Prevent git from pulling lfs objects during checkout + palSh('git lfs uninstall', 'Git LFS Uninstall') // Prevent git from pulling lfs objects during checkout - if(fileExists('.git')) { - // If the repository after checkout is locked, likely we took a snapshot while git was running, - // to leave the repo in a usable state, garbagecollect. This also helps in situations where - def indexLockFile = '.git/index.lock' - if(fileExists(indexLockFile)) { - palSh('git gc', 'Git GarbageCollect') - } - if(fileExists(indexLockFile)) { // if it is still there, remove it - palRm(indexLockFile) - } + if(fileExists('.git')) { + // If the repository after checkout is locked, likely we took a snapshot while git was running, + // to leave the repo in a usable state, garbagecollect. This also helps in situations where + def indexLockFile = '.git/index.lock' + if(fileExists(indexLockFile)) { + palSh('git gc', 'Git GarbageCollect') + } + if(fileExists(indexLockFile)) { // if it is still there, remove it + palRm(indexLockFile) } } @@ -237,38 +235,29 @@ def CheckoutRepo(boolean disableSubmodules = false) { sleep random.nextInt(60 * retryAttempt) // Stagger checkouts to prevent HTTP 429 (Too Many Requests) response from CodeCommit } retryAttempt = retryAttempt + 1 - dir(ENGINE_REPOSITORY_NAME) { - checkout scm: [ - $class: 'GitSCM', - branches: scm.branches, - extensions: [ - [$class: 'SubmoduleOption', disableSubmodules: disableSubmodules, recursiveSubmodules: true], - [$class: 'CheckoutOption', timeout: 60] - ], - userRemoteConfigs: scm.userRemoteConfigs - ] - } + checkout scm: [ + $class: 'GitSCM', + branches: scm.branches, + extensions: [ + [$class: 'SubmoduleOption', disableSubmodules: disableSubmodules, recursiveSubmodules: true], + [$class: 'CheckoutOption', timeout: 60] + ], + userRemoteConfigs: scm.userRemoteConfigs + ] } - // Add folder where we will store the 3rdParty downloads and packages - if(!fileExists('3rdParty')) { - palMkdir('3rdParty') - } - - dir(ENGINE_REPOSITORY_NAME) { - // Run lfs in a separate step. Jenkins is unable to load the credentials for the custom LFS endpoint - withCredentials([usernamePassword(credentialsId: "${env.GITHUB_USER}", passwordVariable: 'accesstoken', usernameVariable: 'username')]) { - SetLfsCredentials("git config -f .lfsconfig lfs.url https://${username}:${accesstoken}@${env.LFS_URL}", 'Set credentials') - } - palSh('git lfs install', 'Git LFS Install') - palSh('git lfs pull', 'Git LFS Pull') - - // CHANGE_ID is used by some scripts to identify uniquely the current change (usually metric jobs) - palSh('git rev-parse HEAD > commitid', 'Getting commit id') - env.CHANGE_ID = readFile file: 'commitid' - env.CHANGE_ID = env.CHANGE_ID.trim() - palRm('commitid') + // Run lfs in a separate step. Jenkins is unable to load the credentials for the custom LFS endpoint + withCredentials([usernamePassword(credentialsId: "${env.GITHUB_USER}", passwordVariable: 'accesstoken', usernameVariable: 'username')]) { + SetLfsCredentials("git config -f .lfsconfig lfs.url https://${username}:${accesstoken}@${env.LFS_URL}", 'Set credentials') } + palSh('git lfs install', 'Git LFS Install') + palSh('git lfs pull', 'Git LFS Pull') + + // CHANGE_ID is used by some scripts to identify uniquely the current change (usually metric jobs) + palSh('git rev-parse HEAD > commitid', 'Getting commit id') + env.CHANGE_ID = readFile file: 'commitid' + env.CHANGE_ID = env.CHANGE_ID.trim() + palRm('commitid') } def PreBuildCommonSteps(Map pipelineConfig, String projectName, String pipeline, String branchName, String platform, String buildType, String workspace, boolean mount = true, boolean disableSubmodules = false) { @@ -292,7 +281,7 @@ def PreBuildCommonSteps(Map pipelineConfig, String projectName, String pipeline, sh label: 'Setting volume\'s ownership', script: """ if sudo test ! -d "${workspace}"; then - sudo mkdir -p ${workspace} + sudo mkdir -p ${workspace} cd ${workspace}/.. sudo chown -R lybuilder:root . fi @@ -309,28 +298,31 @@ def PreBuildCommonSteps(Map pipelineConfig, String projectName, String pipeline, } dir(workspace) { - + // Add folder where we will store the 3rdParty downloads and packages + if(!fileExists('3rdParty')) { + palMkdir('3rdParty') + } + } + dir("${workspace}/${ENGINE_REPOSITORY_NAME}") { CheckoutRepo(disableSubmodules) // Get python - dir(ENGINE_REPOSITORY_NAME) { - if(env.IS_UNIX) { - sh label: 'Getting python', - script: 'python/get_python.sh' - } else { - bat label: 'Getting python', - script: 'python/get_python.bat' - } + if(env.IS_UNIX) { + sh label: 'Getting python', + script: 'python/get_python.sh' + } else { + bat label: 'Getting python', + script: 'python/get_python.bat' + } - if(env.CLEAN_OUTPUT_DIRECTORY.toBoolean() || env.CLEAN_ASSETS.toBoolean()) { - def command = "${pipelineConfig.BUILD_ENTRY_POINT} --platform ${platform} --type clean" - if (env.IS_UNIX) { - sh label: "Running ${platform} clean", - script: "${pipelineConfig.PYTHON_DIR}/python.sh -u ${command}" - } else { - bat label: "Running ${platform} clean", - script: "${pipelineConfig.PYTHON_DIR}/python.cmd -u ${command}".replace('/','\\') - } + if(env.CLEAN_OUTPUT_DIRECTORY.toBoolean() || env.CLEAN_ASSETS.toBoolean()) { + def command = "${pipelineConfig.BUILD_ENTRY_POINT} --platform ${platform} --type clean" + if (env.IS_UNIX) { + sh label: "Running ${platform} clean", + script: "${pipelineConfig.PYTHON_DIR}/python.sh -u ${command}" + } else { + bat label: "Running ${platform} clean", + script: "${pipelineConfig.PYTHON_DIR}/python.cmd -u ${command}".replace('/','\\') } } } @@ -446,10 +438,10 @@ try { echo "Running \"${pipelineName}\" for \"${branchName}\"..." CheckoutBootstrapScripts(branchName) - + // Load configs pipelineConfig = LoadPipelineConfig(pipelineName, branchName) - + // Add each platform as a parameter that the user can disable if needed pipelineConfig.platforms.each { platform -> pipelineParameters.add(booleanParam(defaultValue: true, description: '', name: platform.key)) @@ -460,13 +452,13 @@ try { // Stash the INCREMENTAL_BUILD_SCRIPT_PATH since all nodes will use it stash name: 'incremental_build_script', includes: INCREMENTAL_BUILD_SCRIPT_PATH - } + } } } } if(env.BUILD_NUMBER == '1') { - // Exit pipeline early on the intial build. This allows Jenkins to load the pipeline for the branch and enables users + // Exit pipeline early on the intial build. This allows Jenkins to load the pipeline for the branch and enables users // to select build parameters on their first actual build. See https://issues.jenkins.io/browse/JENKINS-41929 currentBuild.result = 'SUCCESS' return @@ -483,16 +475,16 @@ try { envVars['JOB_NAME'] = "${branchName}_${platform.key}_${build_job.key}" // backwards compatibility, some scripts rely on this def nodeLabel = envVars['NODE_LABEL'] - buildConfigs["${platform.key} [${build_job.key}]"] = { + buildConfigs["${platform.key} [${build_job.key}]"] = { node("${nodeLabel}") { if(isUnix()) { // Has to happen inside a node envVars['IS_UNIX'] = 1 - } + } withEnv(GetEnvStringList(envVars)) { timeout(time: envVars['TIMEOUT'], unit: 'MINUTES', activity: true) { try { def build_job_name = build_job.key - + CreateSetupStage(pipelineConfig, projectName, pipelineName, branchName, platform.key, build_job.key, envVars).call() if(build_job.value.steps) { //this is a pipe with many steps so create all the build stages @@ -503,7 +495,7 @@ try { } else { CreateBuildStage(pipelineConfig, platform.key, build_job.key, envVars).call() } - + if (env.MARS_REPO && platform.key == 'Windows' && build_job_name.startsWith('test')) { def output_directory = platform.value.build_types[build_job_name].PARAMETERS.OUTPUT_DIRECTORY def configuration = platform.value.build_types[build_job_name].PARAMETERS.CONFIGURATION @@ -549,8 +541,8 @@ finally { try { if(env.SNS_TOPIC) { snsPublish( - topicArn: env.SNS_TOPIC, - subject:'Build Result', + topicArn: env.SNS_TOPIC, + subject:'Build Result', message:"${currentBuild.currentResult}:${BUILD_URL}:${env.RECREATE_VOLUME}:${env.CLEAN_OUTPUT_DIRECTORY}:${env.CLEAN_ASSETS}" ) }