Skip to content

Commit

Permalink
Add Stadia Support.
Browse files Browse the repository at this point in the history
  • Loading branch information
AWoloszyn committed May 22, 2019
1 parent 4e24a5e commit 83f0e5d
Show file tree
Hide file tree
Showing 34 changed files with 1,368 additions and 78 deletions.
8 changes: 8 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Description:
#
# Gapid is a graphics API debugger.

licenses(["notice"]) # Apache 2.0

exports_files(["LICENSE"])

load("@bazel_gazelle//:def.bzl", "gazelle")
load("//tools/build:rules.bzl", "copy_to")

Expand Down
1 change: 1 addition & 0 deletions cmd/gapis/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ go_library(
"//core/log:go_default_library",
"//core/os/android/adb:go_default_library",
"//core/os/device/bind:go_default_library",
"//core/os/device/ggp:go_default_library",
"//core/os/device/host:go_default_library",
"//core/os/device/remotessh:go_default_library",
"//core/os/file:go_default_library",
Expand Down
23 changes: 23 additions & 0 deletions cmd/gapis/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ import (
"github.com/google/gapid/core/log"
"github.com/google/gapid/core/os/android/adb"
"github.com/google/gapid/core/os/device/bind"
"github.com/google/gapid/core/os/device/ggp"
"github.com/google/gapid/core/os/device/host"
"github.com/google/gapid/core/os/device/remotessh"
"github.com/google/gapid/core/os/file"
Expand Down Expand Up @@ -128,6 +129,9 @@ func run(ctx context.Context) error {
crash.Go(func() { monitorRemoteSSHDevices(ctx, r, wg.Done) })
}

wg.Add(1)
crash.Go(func() { monitorGGPDevices(ctx, r, wg.Done) })

deviceScanDone, onDeviceScanDone := task.NewSignal()
crash.Go(func() {
wg.Wait()
Expand Down Expand Up @@ -201,6 +205,25 @@ func monitorRemoteSSHDevices(ctx context.Context, r *bind.Registry, scanDone fun
}
}

func monitorGGPDevices(ctx context.Context, r *bind.Registry, scanDone func()) {

func() {
// Populate the registry with all the existing devices.
defer scanDone() // Signal that we have a primed registry.

if devs, err := ggp.Devices(ctx); err == nil {
for _, d := range devs {
r.AddDevice(ctx, d)
r.SetDeviceProperty(ctx, d, client.LaunchArgsKey, text.SplitArgs(*gapirArgStr))
}
}
}()

if err := ggp.Monitor(ctx, r, time.Second*15); err != nil {
log.W(ctx, "Could not scan for remote GGP devices. Error: %v", err)
}
}

func loadStrings(ctx context.Context) []*stringtable.StringTable {
files, err := filepath.Glob(filepath.Join(*stringsPath, "*.stb"))
if err != nil {
Expand Down
27 changes: 17 additions & 10 deletions core/app/layout/layout.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,17 +119,24 @@ func (l pkgLayout) Gapit(ctx context.Context) (file.Path, error) {
return l.root.Join(withExecutablePlatformSuffix("gapit", hostOS(ctx))), nil
}

var osToDir = map[device.OSKind]string{
device.Linux: "linux",
device.OSX: "macos",
device.Windows: "windows",
func osToDir(k device.OSKind) string {
if device.IsLinuxLike(k) {
return "linux"
}
if k == device.OSX {
return "macos"
}
if k == device.Windows {
return "windows"
}
return ""
}

func (l pkgLayout) Gapir(ctx context.Context, abi *device.ABI) (file.Path, error) {
if abi == nil || hostOS(ctx) == abi.OS {
return l.root.Join(withExecutablePlatformSuffix("gapir", hostOS(ctx))), nil
}
return l.root.Join(osToDir[abi.OS], withExecutablePlatformSuffix("gapir", abi.OS)), nil
return l.root.Join(osToDir(abi.OS), withExecutablePlatformSuffix("gapir", abi.OS)), nil
}

func (l pkgLayout) Gapis(ctx context.Context) (file.Path, error) {
Expand All @@ -144,7 +151,7 @@ func (l pkgLayout) Library(ctx context.Context, lib LibraryType, abi *device.ABI
if abi == nil || hostOS(ctx) == abi.OS {
return l.root.Join("lib", withLibraryPlatformSuffix(libTypeToName[lib], hostOS(ctx))), nil
}
return l.root.Join(osToDir[abi.OS], "lib", withLibraryPlatformSuffix(libTypeToName[lib], abi.OS)), nil
return l.root.Join(osToDir(abi.OS), "lib", withLibraryPlatformSuffix(libTypeToName[lib], abi.OS)), nil
}

func (l pkgLayout) Json(ctx context.Context, lib LibraryType) (file.Path, error) {
Expand All @@ -159,7 +166,7 @@ func (l pkgLayout) DeviceInfo(ctx context.Context, os device.OSKind) (file.Path,
if hostOS(ctx) == os {
return l.root.Join(withExecutablePlatformSuffix("device-info", os)), nil
}
return l.root.Join(osToDir[os], withExecutablePlatformSuffix("device-info", os)), nil
return l.root.Join(osToDir(os), withExecutablePlatformSuffix("device-info", os)), nil
}

// NewPkgLayout returns a FileLayout rooted at the given directory with the standard package layout.
Expand Down Expand Up @@ -364,7 +371,7 @@ func (l *ZipLayout) Gapir(ctx context.Context, abi *device.ABI) (*zip.File, erro
if abi == nil || l.os == abi.OS {
return l.file(withExecutablePlatformSuffix("gapir", l.os))
}
return l.file(osToDir[abi.OS] + "/" + withExecutablePlatformSuffix("gapir", abi.OS))
return l.file(osToDir(abi.OS) + "/" + withExecutablePlatformSuffix("gapir", abi.OS))
}

// Gapis returns the path to the gapis binary in this layout.
Expand All @@ -382,7 +389,7 @@ func (l *ZipLayout) Library(ctx context.Context, lib LibraryType, abi *device.AB
if abi == nil || l.os == abi.OS {
return l.file("lib/" + withLibraryPlatformSuffix(libTypeToName[lib], l.os))
}
return l.file(osToDir[abi.OS] + "lib/" + withLibraryPlatformSuffix(libTypeToName[lib], abi.OS))
return l.file(osToDir(abi.OS) + "lib/" + withLibraryPlatformSuffix(libTypeToName[lib], abi.OS))
}

// Json returns the path to the Vulkan layer JSON definition for the given library.
Expand All @@ -395,5 +402,5 @@ func (l *ZipLayout) DeviceInfo(ctx context.Context, os device.OSKind) (*zip.File
if l.os == os {
return l.file(withExecutablePlatformSuffix("device-info", os))
}
return l.file(osToDir[os] + "/" + withExecutablePlatformSuffix("device-info", os))
return l.file(osToDir(os) + "/" + withExecutablePlatformSuffix("device-info", os))
}
2 changes: 2 additions & 0 deletions core/codegen/triple.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ func TargetTriple(dev *device.ABI) Triple {
out.vendor, out.os = "apple", "darwin"
case device.Linux:
out.os = "linux"
case device.Stadia:
out.os = "linux"
case device.Android:
out.os, out.abi = "linux", "androideabi"
}
Expand Down
2 changes: 2 additions & 0 deletions core/net/useragent.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ func UserAgent(d *device.Configuration, ai ApplicationInfo) string {

case device.Linux:
info = append(info, "Linux")
case device.Stadia:
info = append(info, "Stadia")

case device.Android:
info = append(info, "Linux", "U", fmt.Sprintf("Android %v.%v.%v", os.MajorVersion, os.MinorVersion, os.PointVersion))
Expand Down
1 change: 1 addition & 0 deletions core/os/device/abi.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ var (
LinuxX86_64 = abi("linux_x64", Linux, X86_64, Little64)
OSXX86_64 = abi("osx_x64", OSX, X86_64, Little64)
WindowsX86_64 = abi("windows_x64", Windows, X86_64, Little64)
StadiaX86_64 = abi("stadia", Stadia, X86_64, Little64)
)

var abiByName = map[string]*ABI{}
Expand Down
5 changes: 5 additions & 0 deletions core/os/device/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,13 @@ const (
OSX = OSKind_OSX
Linux = OSKind_Linux
Android = OSKind_Android
Stadia = OSKind_Stadia
)

func IsLinuxLike(k OSKind) bool {
return k == OSKind_Linux || k == OSKind_Stadia
}

var (
// ARMv7aLayout is the memory layout for the armv7a ABI.
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0042f/IHI0042F_aapcs.pdf
Expand Down
1 change: 1 addition & 0 deletions core/os/device/device.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ enum OSKind {
OSX = 2;
Linux = 3;
Android = 4;
Stadia = 5;
}

// MemoryLayout holds information about how memory is fundamentally laid out for
Expand Down
35 changes: 35 additions & 0 deletions core/os/device/ggp/BUILD.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# Copyright (C) 2019 Google Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

load("@io_bazel_rules_go//go:def.bzl", "go_library")

go_library(
name = "go_default_library",
srcs = [
"device.go",
"doc.go",
"parse.go",
],
importpath = "github.com/google/gapid/core/os/device/ggp",
visibility = ["//visibility:public"],
deps = [
"//core/event/task:go_default_library",
"//core/log:go_default_library",
"//core/os/device:go_default_library",
"//core/os/device/bind:go_default_library",
"//core/os/device/remotessh:go_default_library",
"//core/os/file:go_default_library",
"//core/os/shell:go_default_library",
],
)
Loading

0 comments on commit 83f0e5d

Please sign in to comment.