You've already forked UnrealEngineUWP
mirror of
https://github.com/izzy2lost/UnrealEngineUWP.git
synced 2026-03-26 18:15:20 -07:00
Motivations of this change: 1) Temporal upscale by default in game builds even when dynamic resolution is not supported; 2) Fixes "Editor Preferences > Performance > Viewport Resolution > Override game screen percentage settings with editor settings in PIE" or (r.Editor.Viewport.OverridePIEScreenPercentage) that used to override r.ScreenPercentage in PIE by default to prevent accidental out of video memory when going PIE on high resolution/DPI display that was not discoverable enought user and generating misunderstanding; 3) Makes editor UI more understandable that the resolution controls under Settings > Engine Scalability Settings is actually PIE resolution settings, since the editor viewport screen percentage is controled independently in editor viewport top left menus; 4) Fixes inconsistency where VR and mobile renderer viewport didn't have their own settings like path tracer or non-realtime editor viewports had; 5) Adds resolution quality presets: just a slider for the 3D rendering resolution is very subjective to a player what to choose, whereas presets allows to more intuitively suggests trade off on the screen percentage range. What this changes does to the end user: 1) Implements default screen percentage project settings in Project Preferences > Rendering > Default Screen Percentage (or r.ScreenPercentage.Default.*) for each indivual uses case that are: desktop renderer, mobile renderer, VR rendering, path tracer 1.1) Desktop renderer renderer default to screen percentage based on display resolution to automatically temporally upscale; 1.2) All other rendering methods (mobile render, VR renderer, path tracer) defaults to native resolution rendering as before. 2) Adds editor viewport screen percentage settings for mobile renderer and VR in Project Settings > Editor Performance > Viewport Resolution 3) Changes defaults of sg.ResolutionQuality and r.ScreenPercentage to 0 and fallbacks to project settings' default screen percentage 4) Rewrite Level Editor UI > Settings > Engine Scalability Settings to: 4.1) Says it only apply to PIE viewport, not including Simulate in Editor since these is still viewed with editor viewports, and warn when there is no PIE game viewports; 4.2) Explicitly says what is the current screen percentage of the PIE game viewport; 4.3) Explicitly says what is the current rendering and display resolutions; 4.4) Says what rendering mode is being applied (Desktop renderer, mobile renderer, VR rendering, path tracer) 4.5) Says where the settings come from, r.ScreenPercentage was directly set by console code, or whether the Engine Scalability was overident (sg.ResolutionQuality>0) or where the default settings come from (project's default screen percentage settings or editor viewport preferences) 4.6) Says the actually setting is being used (Manual, Based on Display Resolution, Based on OS DPI Scale) 4.7) Explicitly says which anti-aliasing method is being used on the anti-aliasing scalability group 5) The "Editor Preferences > Performance > Viewport resolution > Override project's default screen percentage settings with editor viewports' settings in PIE" (r.Editor.Viewport.OverridePIEScreenPercentage) now chooses whether the default screen percentage project settings should be overriden by the editor viewport's default settings. sg.ResolutionQuality and r.ScreenPercentage now behaving as a override, it means they are also applied in PIE to avoid user confusions when they do indeed what to take control of it in the project settings or game logic. 6) Adds resolution quality presets in BaseScalability.ini that can be customised in a project's DefaultScalability.ini: 6.1) Default 3D resolution preset: Sets sg.ResolutionQuality=0 to end up using the default project settings presets which for the case of the desktop renderer means temporal upscaling by default based on the display resolution like Fortnite's Recommended settings. 6.2) Performance 3D resolution preset: Sets sg.ResolutionQuality=100*1080/2160 6.3) Balanced 3D resolution preset: Sets sg.ResolutionQuality=100*1260/2160 6.4) Quality 3D resolution preset: Sets sg.ResolutionQuality=100*1440/2160 6.5) Native 3D resolution preset: Sets sg.ResolutionQuality=100 #rb rob.srinivasiah, jack.porter, juan.canada, allan.bentham #jira UE-184651 [CL 25988162 by guillaume abadie in ue5-main branch]
256 lines
10 KiB
C++
256 lines
10 KiB
C++
// Copyright Epic Games, Inc. All Rights Reserved.
|
|
#pragma once
|
|
|
|
#include "AutomationScreenshotOptions.h"
|
|
#include "CoreMinimal.h"
|
|
#include "Engine/EngineBaseTypes.h"
|
|
#include "Engine/LatentActionManager.h"
|
|
#include "HAL/IConsoleManager.h"
|
|
#include "Kismet/BlueprintFunctionLibrary.h"
|
|
#include "Misc/AutomationTest.h"
|
|
#include "Templates/UniquePtr.h"
|
|
#include "UObject/ObjectMacros.h"
|
|
#include "AutomationBlueprintFunctionLibrary.generated.h"
|
|
|
|
class ACameraActor;
|
|
|
|
/**
|
|
* FAutomationTaskStatusBase - abstract class for task status
|
|
*/
|
|
class FAutomationTaskStatusBase
|
|
{
|
|
public:
|
|
virtual ~FAutomationTaskStatusBase() = default;
|
|
|
|
bool IsDone() const { return Done; };
|
|
virtual void SetDone() { Done = true; };
|
|
|
|
protected:
|
|
bool Done = false;
|
|
};
|
|
|
|
/**
|
|
* UAutomationEditorTask
|
|
*/
|
|
UCLASS(BlueprintType, Transient)
|
|
class FUNCTIONALTESTING_API UAutomationEditorTask : public UObject
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
virtual ~UAutomationEditorTask() = default;
|
|
|
|
/** Query if the Editor task is done */
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
bool IsTaskDone() const;
|
|
|
|
/** Query if a task was setup */
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
bool IsValidTask() const;
|
|
|
|
void BindTask(TUniquePtr<FAutomationTaskStatusBase> inTask);
|
|
|
|
private:
|
|
TUniquePtr<FAutomationTaskStatusBase> Task;
|
|
};
|
|
|
|
USTRUCT(BlueprintType)
|
|
struct FAutomationWaitForLoadingOptions
|
|
{
|
|
GENERATED_BODY()
|
|
|
|
public:
|
|
|
|
UPROPERTY(BlueprintReadWrite, Category = "Automation")
|
|
bool WaitForReplicationToSettle = false;
|
|
};
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UCLASS(meta=(ScriptName="AutomationLibrary"))
|
|
class FUNCTIONALTESTING_API UAutomationBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
|
|
{
|
|
GENERATED_UCLASS_BODY()
|
|
|
|
public:
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
static void FinishLoadingBeforeScreenshot();
|
|
|
|
static bool TakeAutomationScreenshotInternal(UObject* WorldContextObject, const FString& ScreenShotName, const FString& Notes, FAutomationScreenshotOptions Options);
|
|
|
|
static FAutomationScreenshotData BuildScreenshotData(const FString& MapOrContext, const FString& ScreenShotName, int32 Width, int32 Height);
|
|
|
|
static FIntPoint GetAutomationScreenshotSize(const FAutomationScreenshotOptions& Options);
|
|
|
|
/**
|
|
* Takes a screenshot of the game's viewport. Does not capture any UI.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (Latent, HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject", LatentInfo = "LatentInfo", Name = "" ))
|
|
static void TakeAutomationScreenshot(UObject* WorldContextObject, FLatentActionInfo LatentInfo, const FString& Name, const FString& Notes, const FAutomationScreenshotOptions& Options);
|
|
|
|
/**
|
|
* Takes a screenshot of the game's viewport, from a particular camera actors POV. Does not capture any UI.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (Latent, HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject", LatentInfo = "LatentInfo", NameOverride = "" ))
|
|
static void TakeAutomationScreenshotAtCamera(UObject* WorldContextObject, FLatentActionInfo LatentInfo, ACameraActor* Camera, const FString& NameOverride, const FString& Notes, const FAutomationScreenshotOptions& Options);
|
|
|
|
/**
|
|
*
|
|
*/
|
|
static bool TakeAutomationScreenshotOfUI_Immediate(UObject* WorldContextObject, const FString& Name, const FAutomationScreenshotOptions& Options);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = ( Latent, HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject", LatentInfo = "LatentInfo", NameOverride = "" ))
|
|
static void TakeAutomationScreenshotOfUI(UObject* WorldContextObject, FLatentActionInfo LatentInfo, const FString& Name, const FAutomationScreenshotOptions& Options);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
|
|
static void EnableStatGroup(UObject* WorldContextObject, FName GroupName);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
|
|
static void DisableStatGroup(UObject* WorldContextObject, FName GroupName);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
static float GetStatIncAverage(FName StatName);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
static float GetStatIncMax(FName StatName);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
static float GetStatExcAverage(FName StatName);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
static float GetStatExcMax(FName StatName);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
static float GetStatCallCount(FName StatName);
|
|
|
|
/**
|
|
* Lets you know if any automated tests are running, or are about to run and the automation system is spinning up tests.
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="Automation")
|
|
static bool AreAutomatedTestsRunning();
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (Latent, HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject", LatentInfo = "LatentInfo"))
|
|
static void AutomationWaitForLoading(UObject* WorldContextObject, FLatentActionInfo LatentInfo, FAutomationWaitForLoadingOptions Options);
|
|
|
|
/**
|
|
* take high res screenshot in editor.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (AdvancedDisplay="Camera, bMaskEnabled, bCaptureHDR, ComparisonTolerance, ComparisonNotes"))
|
|
static UAutomationEditorTask* TakeHighResScreenshot(int32 ResX, int32 ResY, FString Filename, ACameraActor* Camera = nullptr, bool bMaskEnabled = false, bool bCaptureHDR = false, EComparisonTolerance ComparisonTolerance = EComparisonTolerance::Low, FString ComparisonNotes = TEXT(""), float Delay = 0.0);
|
|
|
|
/**
|
|
* request image comparison.
|
|
* @param ImageFilePath Absolute path to the image location. All 8bit RGBA channels supported formats by the engine are accepted.
|
|
* @param ComparisonName Optional name for the comparison, by default the basename of ImageFilePath is used
|
|
* @return True if comparison was successfully enqueued
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (AdvancedDisplay = "ComparisonName, ComparisonTolerance, ComparisonNotes", HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
|
|
static bool CompareImageAgainstReference(FString ImageFilePath, FString ComparisonName = TEXT(""), EComparisonTolerance ComparisonTolerance = EComparisonTolerance::Low, FString ComparisonNotes = TEXT(""), UObject* WorldContextObject = nullptr);
|
|
|
|
/**
|
|
* Add Telemetry data to currently running automated test.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (AdvancedDisplay = "Context"))
|
|
static void AddTestTelemetryData(FString DataPoint, float Measurement, FString Context = TEXT(""));
|
|
|
|
/**
|
|
* Set Telemetry data storage name of currently running automated test.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
static void SetTestTelemetryStorage(FString StorageName);
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="Automation")
|
|
static FAutomationScreenshotOptions GetDefaultScreenshotOptionsForGameplay(EComparisonTolerance Tolerance = EComparisonTolerance::Low, float Delay = 0.2);
|
|
|
|
/**
|
|
*
|
|
*/
|
|
UFUNCTION(BlueprintPure, Category="Automation")
|
|
static FAutomationScreenshotOptions GetDefaultScreenshotOptionsForRendering(EComparisonTolerance Tolerance = EComparisonTolerance::Low, float Delay = 0.2);
|
|
|
|
/**
|
|
* Mute the report of log error and warning matching a pattern during an automated test
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (AdvancedDisplay = "Occurrences, ExactMatch"))
|
|
static void AddExpectedLogError(FString ExpectedPatternString, int32 Occurrences = 1, bool ExactMatch = false);
|
|
|
|
/**
|
|
* Sets all other settings based on an overall value
|
|
* @param Value 0:Cinematic, 1:Epic...etc.
|
|
*/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
|
|
static void SetScalabilityQualityLevelRelativeToMax(UObject* WorldContextObject, int32 Value = 1);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
|
|
static void SetScalabilityQualityToEpic(UObject* WorldContextObject);
|
|
|
|
UFUNCTION(BlueprintCallable, Category = "Automation", meta = (HidePin = "WorldContextObject", DefaultToSelf = "WorldContextObject"))
|
|
static void SetScalabilityQualityToLow(UObject* WorldContextObject);
|
|
|
|
/** Sets all viewports of the first found level editor to have the given ViewMode (Lit/Unlit/etc.) **/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
static void SetEditorViewportViewMode(EViewModeIndex Index);
|
|
|
|
/** Sets all viewports of the first found level editor to have the VisualizeBuffer ViewMode and also display a given buffer (BaseColor/Metallic/Roughness/etc.) **/
|
|
UFUNCTION(BlueprintCallable, Category = "Automation")
|
|
static void SetEditorViewportVisualizeBuffer(FName BufferName);
|
|
};
|
|
|
|
#if WITH_AUTOMATION_TESTS
|
|
|
|
template<typename T>
|
|
class FConsoleVariableSwapperTempl
|
|
{
|
|
public:
|
|
FConsoleVariableSwapperTempl(FString InConsoleVariableName);
|
|
|
|
void Set(T Value);
|
|
|
|
void Restore();
|
|
|
|
private:
|
|
bool bModified;
|
|
FString ConsoleVariableName;
|
|
|
|
T OriginalValue;
|
|
};
|
|
|
|
class FAutomationTestScreenshotEnvSetup
|
|
{
|
|
public:
|
|
FAutomationTestScreenshotEnvSetup();
|
|
~FAutomationTestScreenshotEnvSetup();
|
|
|
|
// Disable AA, auto-exposure, motion blur, contact shadow if InOutOptions.bDisableNoisyRenderingFeatures.
|
|
// Update screenshot comparison tolerance stored in InOutOptions.
|
|
// Set visualization buffer name if required.
|
|
void Setup(UWorld* InWorld, FAutomationScreenshotOptions& InOutOptions);
|
|
|
|
/** Restore the old settings. */
|
|
void Restore();
|
|
|
|
private:
|
|
FConsoleVariableSwapperTempl<int32> DefaultFeature_AntiAliasing;
|
|
FConsoleVariableSwapperTempl<int32> DefaultFeature_AutoExposure;
|
|
FConsoleVariableSwapperTempl<int32> DefaultFeature_MotionBlur;
|
|
FConsoleVariableSwapperTempl<int32> MotionBlurQuality;
|
|
FConsoleVariableSwapperTempl<int32> ScreenSpaceReflectionQuality;
|
|
FConsoleVariableSwapperTempl<int32> EyeAdaptationQuality;
|
|
FConsoleVariableSwapperTempl<int32> ContactShadows;
|
|
FConsoleVariableSwapperTempl<float> TonemapperGamma;
|
|
FConsoleVariableSwapperTempl<float> TonemapperSharpen;
|
|
FConsoleVariableSwapperTempl<float> ScreenPercentage;
|
|
FConsoleVariableSwapperTempl<int32> DynamicResTestScreenPercentage;
|
|
FConsoleVariableSwapperTempl<int32> DynamicResOperationMode;
|
|
FConsoleVariableSwapperTempl<float> SecondaryScreenPercentage;
|
|
|
|
TWeakObjectPtr<UWorld> WorldPtr;
|
|
TSharedPtr< class FAutomationViewExtension, ESPMode::ThreadSafe > AutomationViewExtension;
|
|
};
|
|
|
|
#endif
|