Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unity 2020.3.25 w/ CloudRendering Engine #1002

Merged
merged 81 commits into from
Mar 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
b52fc21
initial checkin of CloudRendering engine support
Apr 24, 2021
f829ec0
merging main to cloudrendering
Apr 28, 2021
b2c6c68
upgrading packages
Apr 30, 2021
ab46107
updating version and asmdef
May 6, 2021
84a4608
merging main
May 13, 2021
fc52144
updating to create rendertextures
May 13, 2021
cf19662
adding support for retrieving cloudRendering builds
May 13, 2021
c47ff48
adding dotnet install and dotnet tool mpc install
May 13, 2021
c5a8098
adding install mpc from github release
May 14, 2021
3a66d7b
removing IL2CPP blocks around actionReturn and allowing ActionReturnF…
May 14, 2021
c8e072e
merging main to cloudrendering
Jun 9, 2021
0c14fff
resolve merge conflict
Jun 9, 2021
fdb0426
Merge branch 'main' into erick/cloudrendering
Jun 9, 2021
41a2d2d
wrapping cloudrendering calls in preprocessor directive
Jun 9, 2021
382e6da
updating packages
Jun 9, 2021
410ec4b
removing collab-proxy
Jun 9, 2021
ac25fc1
passing buildTarget to build command
Jun 15, 2021
d305504
setting rendering path to deferred for cloudrendering
Jun 29, 2021
205784f
defaulting cloudrendering quality to Ultra
Jun 29, 2021
f637938
upgrading to 2021.2.0a16
Jun 29, 2021
cdaa9b0
merging in erick/cloudrendering
Jun 29, 2021
f6afaeb
switching to 2021.2.0a14
Jun 29, 2021
6e951f4
adding new components
Jun 29, 2021
c6c9b9c
enabling cloudrendering by default
Jun 29, 2021
f94cf4a
adding gpu device option to allow CloudRendering to target a specific…
Jul 14, 2021
2eb3d7e
removing temporary renderTexture and call WaitAllAsyncRequests immedi…
Jul 15, 2021
1edab8a
defaulting gpu_device to first cuda_visible_device if specified
Jul 20, 2021
91139c9
indexing into cuda_visible_devices if gpu_device is set
Jul 20, 2021
63c1701
upgrading linux toolchain package version
Aug 12, 2021
94fd933
merging main into cloudrendering-2021.2
Sep 7, 2021
9ca22ae
fixing name of new agent identifier
Sep 7, 2021
0196906
adding generate-msgpack and import assets to build-cloudrendering task
Sep 8, 2021
a559174
downgrading to 2020.3.18
Sep 23, 2021
a7ebfb9
adding package-lock
Sep 23, 2021
4ba56c5
merging in main
Sep 23, 2021
b1e8a46
fixing duplicate analytics referenc
Sep 23, 2021
8f137e8
adding cloudrendering engine install and change cloudrendering version
Sep 23, 2021
0cc615a
reverting changes introduced by upgrading to 2021
Sep 24, 2021
8dd6f0b
reverting changes introduced by upgrading to 2021
Sep 24, 2021
0287840
merging in main
Sep 26, 2021
b7c98e6
reverting projectsettings and graphicssettings to main
Sep 26, 2021
38176eb
Merge branch 'erick/cloudrendering-2021.2' of github.com:allenai/ai2t…
Sep 26, 2021
03b173a
fixing controller tests
Sep 26, 2021
01422eb
adding initalize_cloudrendering task and comment in Build.cs about in…
Sep 26, 2021
5b8e706
adding executeMethod to InitializeCloudRendering
Sep 26, 2021
86fb8fc
updating CloudRendering default Quality Level to 7
Sep 27, 2021
aecd516
updating packages
Sep 27, 2021
f0e9160
updating project version to 2021.2.0
Sep 27, 2021
214db57
adding remove system plugins method in tasks
Sep 27, 2021
5cc2c46
removing GameObject with missing prefab
Sep 29, 2021
5ea1465
Merge branch 'erick/cloudrendering-2021.2' of github.com:allenai/ai2t…
Sep 29, 2021
c4c37a8
reverting change to scene
Sep 29, 2021
7dafcbe
skipping FloorPlan5xx scenes
Sep 29, 2021
209cc86
Merge branch 'erick/cloudrendering-2021.2' of github.com:allenai/ai2t…
Sep 29, 2021
54535f6
Merge branch 'main' into erick/cloudrendering-2021.2
Oct 1, 2021
6799d14
updating editor to 2020.3.19f1
Oct 5, 2021
ced43d6
changing version for cloudrendering to 2020.3.19f1; adding tmp_dir to…
Oct 7, 2021
9985bf7
adding support for generic collections in ActionReturnFormatter
Nov 2, 2021
809b00a
upgrading to 2020.3.21f1
Nov 2, 2021
de2963c
updating cloudrendering install task
Nov 2, 2021
e4de80c
adding enabling opengl for macstandalone
Nov 2, 2021
c1487bf
forcing GLCore to get used during unit tests since a low power graphi…
Oct 6, 2021
8afbb12
updating macstandalone to not be automatic
Nov 2, 2021
77fa87e
merging in main
Nov 23, 2021
0d2d752
updating unity version for cloudrendering engine install and removing…
Nov 24, 2021
f651de5
switching backending scripting to Mono and removing IL2CPP specific m…
Jan 26, 2022
bcb744b
upgrading to 2020.3.25f1
Jan 27, 2022
22d62af
merging in main
Feb 9, 2022
18aca11
moving InitializeCloudRendering call into Build.cs and out of tasks.py
Feb 11, 2022
33c5f62
updating projectsettings; adding cr to build.py
Feb 13, 2022
a45e360
Merge branch 'main' into erick/cloudrendering-2021.2
Feb 13, 2022
eee2756
Merge branch 'erick/remove-ssao' into erick/cloudrendering-2021.2
Feb 13, 2022
ea673df
Merge branch 'main' into erick/cloudrendering-2021.2
Feb 14, 2022
38efae7
removing build-cloudrendering task; removing il2cpp/msgpack tasks
Feb 14, 2022
8d603bb
removing unneeded comments
Feb 14, 2022
49b8d3c
removing fix_webgl_unity_loader_regex; reported as fixed: https://iss…
Feb 14, 2022
47351cd
adding extraScriptingDefines to allow WebGL build to succeed
Feb 14, 2022
fe907ef
allowing display to set x_display in controller
Mar 17, 2022
9db7c66
enabling javascript interface in fpsagentcontroller instead of debugi…
Mar 17, 2022
d523753
removing default_cloudrendering_commit_id
Mar 17, 2022
54e9d0f
Merge branch 'main' into erick/cloudrendering-2021.2
Mar 29, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,6 @@ unity/.vs/
unity/.idea/
unity/Assets/[Pp]rivate/
unity/Assets/[Pp]rivate.meta
# files in this directory are generated by
# the MessagePackGenerator (mpc)
# invoke generate-msgpack-resolve
unity/Assets/Scripts/ThorMsgPackResolver*
unity/Assets/InitTestScene*
unity/utf_testResults-*

Expand All @@ -32,6 +28,7 @@ ai2thor/tests/test_utf.py
.config/

build.log
tmp/


# General
Expand Down
7 changes: 2 additions & 5 deletions ai2thor/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from ai2thor.util.lock import LockSh, LockEx
from ai2thor.util import atomic_write
import io
from ai2thor.platform import STR_PLATFORM_MAP, OSXIntel64, Linux64
from ai2thor.platform import STR_PLATFORM_MAP, OSXIntel64, Linux64, CloudRendering
import platform

logger = logging.getLogger(__name__)
Expand All @@ -20,7 +20,7 @@
PYPI_S3_BUCKET = "ai2-thor-pypi"

LOCAL_BUILD_COMMIT_ID = "local"
AUTO_BUILD_PLATFORMS = [OSXIntel64, Linux64]
AUTO_BUILD_PLATFORMS = [OSXIntel64, Linux64, CloudRendering]

COMMIT_ID = None
try:
Expand All @@ -30,9 +30,6 @@
except ImportError:
pass

# Since CloudRendering is manually built, this will act as a fallback
# until the process is automated
DEFAULT_CLOUDRENDERING_COMMIT_ID = "22d62af5da45708e7bc40bf07a861e7397f9d2f9"

def build_name(arch, commit_id, include_private_scenes=False):
if include_private_scenes:
Expand Down
7 changes: 0 additions & 7 deletions ai2thor/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -1161,13 +1161,6 @@ def find_build(self, local_build, commit_id, branch, platform):
if platform is None:
candidate_platforms = ai2thor.platform.select_platforms(request)
else:

# if the commit is using the default build commit, and
# the platform target is CloudRendering we default to a known built
# commit until the build can be automated
if commit_id and commit_id == ai2thor.build.COMMIT_ID and platform == ai2thor.platform.CloudRendering:
commits.append(ai2thor.build.DEFAULT_CLOUDRENDERING_COMMIT_ID)

candidate_platforms = [platform]

builds = self.find_platform_builds(candidate_platforms, request, commits, releases_dir, local_build)
Expand Down
75 changes: 36 additions & 39 deletions tasks.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ def add_files(zipf, start_dir, exclude_ext=()):
continue

arcname = os.path.relpath(fn, start_dir)
if arcname.split("/")[0].endswith("_BackUpThisFolder_ButDontShipItWithYourGame"):
# print("skipping %s" % arcname)
continue
# print("adding %s" % arcname)
zipf.write(fn, arcname)

Expand Down Expand Up @@ -128,9 +131,14 @@ def _build(unity_path, arch, build_dir, build_name, env={}):

project_path = os.path.join(os.getcwd(), unity_path)

# osxintel64 is not a BuildTarget
build_target_map = dict(OSXIntel64="OSXUniversal")

# -buildTarget must be passed as an option for the CloudRendering target otherwise a clang error
# will get thrown complaining about missing features.h
command = (
"%s -quit -batchmode -logFile %s/%s.log -projectpath %s -executeMethod Build.%s"
% (_unity_path(), os.getcwd(), build_name, project_path, arch)
"%s -quit -batchmode -logFile %s/%s.log -projectpath %s -buildTarget %s -executeMethod Build.%s"
% (_unity_path(), os.getcwd(), build_name, project_path, build_target_map.get(arch, arch), arch)
)

target_path = os.path.join(build_dir, build_name)
Expand Down Expand Up @@ -420,17 +428,6 @@ def local_build(
generate_quality_settings(context)


def fix_webgl_unity_loader_regex(unity_loader_path):
# Bug in the UnityLoader.js causes Chrome on Big Sur to fail to load
# https://issuetracker.unity3d.com/issues/unity-webgl-builds-do-not-run-on-macos-big-sur
with open(unity_loader_path) as f:
loader = f.read()

loader = loader.replace("Mac OS X (10[\.\_\d]+)", "Mac OS X (1[\.\_\d][\.\_\d]+)")
with open(unity_loader_path, "w") as f:
f.write(loader)


@task
def webgl_build(
context,
Expand Down Expand Up @@ -509,7 +506,6 @@ def file_to_content_addressable(file_path, json_metadata_file_path, json_key):
print("Build Failure")

build_path = _webgl_local_build_path(prefix, directory)
fix_webgl_unity_loader_regex(os.path.join(build_path, "Build/UnityLoader.js"))
generate_quality_settings(context)

# the remainder of this is only used to generate scene metadata, but it
Expand Down Expand Up @@ -548,9 +544,10 @@ def file_to_content_addressable(file_path, json_metadata_file_path, json_key):
print(scene_metadata)

to_content_addressable = [
("{}.data.unityweb".format(build_name), "dataUrl"),
("{}.wasm.code.unityweb".format(build_name), "wasmCodeUrl"),
("{}.wasm.framework.unityweb".format(build_name), "wasmFrameworkUrl"),
("{}.data".format(build_name), "dataUrl"),
("{}.loader.js".format(build_name), "loaderUrl"),
("{}.wasm".format(build_name), "wasmCodeUrl"),
("{}.framework.js".format(build_name), "wasmFrameworkUrl"),
]
for file_name, key in to_content_addressable:
file_to_content_addressable(
Expand Down Expand Up @@ -1127,6 +1124,28 @@ def ci_build(context):
lock_f.close()


@task
def install_cloudrendering_engine(context, force=False):
if not sys.platform.startswith("darwin"):
raise Exception("CloudRendering Engine can only be installed on Mac")
s3 = boto3.resource("s3")
target_base_dir = "/Applications/Unity/Hub/Editor/{}/PlaybackEngines".format(_unity_version())
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps using the _unity_path() function here to not have multiple places to change if this string changes.

full_dir = os.path.join(target_base_dir, "CloudRendering")
if os.path.isdir(full_dir):
if force:
shutil.rmtree(full_dir)
logger.info("CloudRendering engine already installed - removing due to force")
else:
logger.info("skipping installation - CloudRendering engine already installed")
return

print("packages/CloudRendering-%s.zip" % _unity_version())
res = s3.Object(ai2thor.build.PRIVATE_S3_BUCKET, "packages/CloudRendering-%s.zip" % _unity_version()).get()
data = res["Body"].read()
z = zipfile.ZipFile(io.BytesIO(data))
z.extractall(target_base_dir)


@task
def ci_build_webgl(context, commit_id):
branch = "main"
Expand Down Expand Up @@ -3320,28 +3339,6 @@ def act(controller, actions, n):
)
)


@task
def generate_msgpack_resolver(task):
import glob

# mpc can be downloaded from: https://github.com/neuecc/MessagePack-CSharp/releases/download/v2.1.194/mpc.zip
# need to download/unzip into this path, add gatekeeper permission
target_dir = "unity/Assets/Scripts/ThorMsgPackResolver"
shutil.rmtree(target_dir, ignore_errors=True)
mpc_path = os.path.join(os.environ["HOME"], "local/bin/mpc")
subprocess.check_call(
"%s -i unity -o %s -m -r ThorIL2CPPGeneratedResolver" % (mpc_path, target_dir),
shell=True,
)
for g in glob.glob(os.path.join(target_dir, "*.cs")):
with open(g) as f:
source_code = f.read()
source_code = "using UnityEngine;\n" + source_code
with open(g, "w") as f:
f.write(source_code)


@task
def generate_pypi_index(context):
s3 = boto3.resource("s3")
Expand Down
55 changes: 42 additions & 13 deletions unity/Assets/Editor/Build.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,43 +4,63 @@
using UnityEngine;
using System.Collections.Generic;
using System.Linq;
using UnityEditor.Rendering;
using UnityEngine.Rendering;
using UnityEditor.Build.Reporting;

public class Build {

// Since CloudRendering uses a different version of Unity (2020.2) vs production (2019.4), GraphicsSettings and ProjectSettings
// must be copied over from the Standalone platform. As well, continuing to use this ensures that settings made for
// the Standalone platform get used for CloudRendering
static void InitializeCloudRendering() {
PlayerSettings.SetApiCompatibilityLevel(BuildTargetGroup.CloudRendering, PlayerSettings.GetApiCompatibilityLevel(BuildTargetGroup.Standalone));
var graphicsTiers = new List<GraphicsTier>(){GraphicsTier.Tier1, GraphicsTier.Tier2, GraphicsTier.Tier3};
foreach (var graphicsTier in graphicsTiers) {
EditorGraphicsSettings.SetTierSettings(
BuildTargetGroup.CloudRendering,
graphicsTier,
EditorGraphicsSettings.GetTierSettings(BuildTargetGroup.Standalone, graphicsTier)
);
}
}

static void OSXIntel64() {
#if UNITY_2017_3_OR_NEWER
var buildTarget = BuildTarget.StandaloneOSX;
#else
var buildTarget = BuildTarget.StandaloneOSXIntel64;
#endif
build(GetBuildName(), buildTarget);
build(GetBuildName(), BuildTargetGroup.Standalone, BuildTarget.StandaloneOSX);
}

static string GetBuildName() {
return Environment.GetEnvironmentVariable("UNITY_BUILD_NAME");
}

static void Linux64() {
build(GetBuildName(), BuildTarget.StandaloneLinux64);
build(GetBuildName(), BuildTargetGroup.Standalone, BuildTarget.StandaloneLinux64);
}

static void CloudRendering() {
InitializeCloudRendering();
build(GetBuildName(), BuildTargetGroup.CloudRendering, BuildTarget.CloudRendering);
}

static void WebGL() {
build(GetBuildName(), BuildTarget.WebGL);
// USIM_USE_... scripting defines are required
// to disable the native PNG and JPEG encoders present in the simulation capture package
// if these defines are not provide the WebGL build will fail
build(GetBuildName(), BuildTargetGroup.WebGL, BuildTarget.WebGL, new string[]{"USIM_USE_BUILTIN_JPG_ENCODER", "USIM_USE_BUILTIN_PNG_ENCODER"});
}

static void buildResourceAssetJson() {
ResourceAssetManager manager = new ResourceAssetManager();
manager.BuildCatalog();
}

static void build(string buildName, BuildTarget target) {
static void build(string buildName, BuildTargetGroup targetGroup, BuildTarget target, string[] extraScriptingDefines=null) {
buildResourceAssetJson();

var defines = GetDefineSymbolsFromEnv();
if (defines != "") {
var targetGroup = BuildPipeline.GetBuildTargetGroup(target);
PlayerSettings.SetScriptingDefineSymbolsForGroup(targetGroup, GetDefineSymbolsFromEnv());
}

List<string> scenes = GetScenes();
foreach (string scene in scenes) {
Debug.Log("Adding Scene " + scene);
Expand All @@ -54,10 +74,19 @@ static void build(string buildName, BuildTarget target) {
if (ScriptsOnly()) {
options |= BuildOptions.Development | BuildOptions.BuildScriptsOnly;
}

Debug.Log("Build options " + options);
BuildPlayerOptions buildPlayerOptions = new BuildPlayerOptions();
if (extraScriptingDefines != null) {
buildPlayerOptions.extraScriptingDefines = extraScriptingDefines;
}
buildPlayerOptions.scenes = scenes.ToArray();
buildPlayerOptions.locationPathName = buildName;
buildPlayerOptions.target = target;
buildPlayerOptions.options = options;
EditorUserBuildSettings.SwitchActiveBuildTarget(targetGroup, target);
BuildReport report = BuildPipeline.BuildPlayer(buildPlayerOptions);
BuildSummary summary = report.summary;

BuildPipeline.BuildPlayer(scenes.ToArray(), buildName, target, options);
}

private static List<string> GetScenes() {
Expand Down
1 change: 0 additions & 1 deletion unity/Assets/MagicMirror/Prefab/MirrorCameraScript.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using UnityEngine;
using System.Collections;
using System.Collections.Generic;
using UnityEngine.VR;

public class MirrorCameraScript : MonoBehaviour
{
Expand Down
6 changes: 5 additions & 1 deletion unity/Assets/MessagePack/MessagePackSerializer.NonGeneric.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Copyright (c) All contributors. All rights reserved.
#if PLATFORM_CLOUD_RENDERING
#undef ENABLE_IL2CPP
#endif
// CloudRendering does not set ENABLE_IL2CPP correctly when using Mono
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System;
Expand Down
6 changes: 5 additions & 1 deletion unity/Assets/MessagePack/Resolvers/StandardResolver.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
// Copyright (c) All contributors. All rights reserved.
#if PLATFORM_CLOUD_RENDERING
#undef ENABLE_IL2CPP
#endif
// CloudRendering does not set ENABLE_IL2CPP correctly when using Mono
// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

using System.Linq;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
// Copyright (c) All contributors. All rights reserved.
#if PLATFORM_CLOUD_RENDERING
#undef ENABLE_IL2CPP
#endif
// CloudRendering does not set ENABLE_IL2CPP correctly when using Mono

// Copyright (c) All contributors. All rights reserved.
// Licensed under the MIT license. See LICENSE file in the project root for full license information.

#if !UNITY_2018_3_OR_NEWER
Expand Down
5 changes: 4 additions & 1 deletion unity/Assets/Scripts/AI2-THOR-Base.asmdef
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"name": "AI2-THOR-Base",
"rootNamespace": "",
"references": [
"GUID:bbde805d927e795439d7a746d1749cab",
"GUID:5a46ad82eac024e4fbb6a0516a5def17",
Expand All @@ -9,6 +10,8 @@
"GUID:cc5461233835e41b796a5feb5161fafc",
"GUID:fa06079b370704f1bb8a8a4da5f16215",
"GUID:2cd51e32b52dd4b0b888f2392d807abc",
"GUID:c29904cf588a14db08f7961207e4347e",
"GUID:e35a45ac11d444d7db30cc91d9e833b8",
"GUID:e230a993a6c084a0ba10310713d6dd2f"
],
"includePlatforms": [],
Expand All @@ -20,4 +23,4 @@
"defineConstraints": [],
"versionDefines": [],
"noEngineReferences": false
}
}
Loading