Skip to content

Merge the latest GAPID changes to AGI #3

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

Closed
wants to merge 39 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
e011c1f
Add error reporting to Transforms (#3676)
hevrard Jan 28, 2020
07326e2
Highlight the currently hovered counter sample.
pmuetschard Jan 27, 2020
3a3082a
Move the moseXpos var into the hovercard.
pmuetschard Jan 27, 2020
42794f9
Better location of the counter tooltip.
pmuetschard Jan 27, 2020
d48d30d
Distinguish between delta and event based counters.
pmuetschard Jan 27, 2020
0e7a71b
Give the GPU frequency counter a custom name.
pmuetschard Jan 27, 2020
7e0d619
Add instructions to use VSCode with Delve (#3696)
yalcinmelihyasin Jan 28, 2020
a7b5e7e
Detect render stage capability from prerelease driver (#3693)
rschiu Jan 29, 2020
d723853
Clean-up output of gapit devices (#3706)
hevrard Jan 29, 2020
a03969b
Fixed compilation errors for gcc 9 (#3707)
johnplate Jan 29, 2020
c3e2ced
Don't show the GAPID app in the launcher.
pmuetschard Jan 28, 2020
11cbaaf
Make stage name label bigger (#3700)
hliatis Jan 29, 2020
c07bfcf
Fix a problem that frame loop doesn't terminate (#3708)
RenfengLiu Jan 29, 2020
27bff77
Switched out read_framebuffer.go to use the command_splitter.
AWoloszyn Jan 20, 2020
68fc0fd
Add partial support for timeline semaphores (#3709)
zakerinasab Jan 30, 2020
a64728e
Update Perfetto & UI to show vulkan debug markers in the properties p…
silence-do-good Jan 30, 2020
633117f
Load Vulkan layer via settings regardless of GLES layer support (#3713)
hevrard Jan 30, 2020
a8341d0
Ignore unused attachments in the command splitter.
AWoloszyn Jan 30, 2020
78a2161
Allow custom background color, rather than SWT predefined ones.
pmuetschard Dec 26, 2019
03f3c6d
Adjust the various background borders.
pmuetschard Jan 29, 2020
c2dd66f
Get rid of the inverted text color.
pmuetschard Jan 29, 2020
eb1451a
Update the color palatte used for rendering slices.
pmuetschard Jan 30, 2020
f9cd412
Fix CPU Timing Layer (#3716)
rschiu Jan 30, 2020
7092845
Small improvements to the copy_tree rule.
pmuetschard Aug 23, 2019
5bffb42
Resource nil check.
pmuetschard Jul 3, 2019
3886d38
Correctly handle the '?' keyboard shortcut.
pmuetschard Jan 30, 2020
d06d210
Put the focus on the Perfetto UI when the trace finished loading.
pmuetschard Jan 30, 2020
6f0e2e0
Only show the "GPU Queue" group if there's more than one queue.
pmuetschard Jan 30, 2020
bb11fd7
Only show the "SF Events" group if there's more than one buffer.
pmuetschard Jan 30, 2020
d431b64
Only show the "GPU Counters" group if there's more than one counter.
pmuetschard Jan 30, 2020
bc4a057
Left-truncate CPU slice titles, rather than right-truncate.
pmuetschard Jan 30, 2020
7b1596c
Fix battery track scaling.
pmuetschard Jan 30, 2020
5b22925
Show the process in the thread track tooltip.
pmuetschard Jan 30, 2020
1c87c85
Crisper pin icons on 1x displays.
pmuetschard Jan 30, 2020
395623a
Fix the selection builder warnings.
pmuetschard Jan 30, 2020
9e9e849
Fixes warnings in the PipelineView.
pmuetschard Jan 30, 2020
d94807d
Make sure Perfetto daemons are running. (#3711)
lpy Jan 31, 2020
a92b3ae
Fix duplicate symbol in memory tracker.
AWoloszyn Jan 28, 2020
9a782c8
A few small optimizations.
AWoloszyn Jan 24, 2020
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
59 changes: 54 additions & 5 deletions DEVDOC.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ should still compile under the original AGI checkout directory.

> Despite its name, the gofuse command does NOT use FUSE (filesystem in userspace).
> It just creates directories and links to source files, including generated files.
> It is a good idea to re-run gofuse from time to time to re-sync links to potential
> It is a good idea to re-run gofuse from time to time, to re-sync links to potential
> new files.

In terms of editor, [VsCode](https://code.visualstudio.com/) has good Go support
thanks to its
[Go extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode.Go).
With the GOPATH setup to gofuse, and opening files under the gofuse directory,
you should get some jump-to-definition and autocomplete features working. Make
sure to edit the files through their link found under the gofuse directory.
With the GOPATH setup to gofuse and opening the `<path-to-gapid-gofuse>` directory,
as the root of your workspace, you should get some jump-to-definition and autocomplete
features working. Make sure to edit the files through their link found under the gofuse directory.

## How to debug / breakpoint in Golang code

Expand Down Expand Up @@ -114,7 +114,56 @@ paths to start from another directory, typically your root directory. There may
be a way to adjust using GOPATH to tell to your IDE a possible root for filename
lookups.

Any help to fix this is very welcome!
See the workaround for VSCode below, any help to fix it for other IDEs is very welcome!

#### Integration with VSCode and Delve

To use the delve debugger for Go with VSCode to debug `gapis`. These steps can be followed:

1. Make sure to complete Golang Setup for GAPID.

2. Create a `launch.json` under the workspace directory with `Ctrl + Shift + P` and `Debug: Open launch.json`

3. Paste this as one of the launch configurations. This will ensure that there is a launch configuration for attaching to Delve.
```
{
...
"configurations": [
...,
{
"name": "Attach to Delve",
"type": "go",
"request": "attach",
"mode": "remote",
"apiVersion": 2,
"remotePath": "gapis/",
"cwd": "${workspaceFolder}/src/github.com/google/gapid/gapis",
"dlvLoadConfig": {
"followPointers": true,
"maxVariableRecurse": 1,
"maxStringLen": 120,
"maxArrayValues": 120,
"maxStructFields": -1
},
"host": <host>,
"port": <port>,
},
],
...
}
```
A sample `<host>` can be `127.0.0.1` and `<port>` can be `1234`.

4. Start delve in headless mode at gapid check-in folder.
```
dlv exec --headless --listen=<host>:<port> --api-version 2 ./bazel-bin/pkg/gapis -- <gapis-arguments>
```

This will allow using port `1234` (or any other preferred port) to connect to delve from VSCode.

5. Start debugging with `Debug->Start Debugging` (on Linux with `F5`) and make sure `Attach to Delve` is selected as the launch configuration.

6. Now VSCode can interact with Delve and can be used for debugging `gapis` in VSCode UI instead of command line. Enjoy your debugging :)

## How to debug via printing message

Expand Down
28 changes: 19 additions & 9 deletions cmd/gapit/devices.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,12 @@ import (

type devicesVerb struct{ DevicesFlags }

// deviceObj wraps the device info in a JSON-Marshable type
type deviceObj struct {
DeviceID string
Instance *device.Instance
}

func init() {
verb := &devicesVerb{}
app.AddVerb(&app.Verb{
Expand All @@ -49,25 +55,29 @@ func (verb *devicesVerb) Run(ctx context.Context, flags flag.FlagSet) error {
return log.Err(ctx, err, "Failed to get device list")
}

stdout := os.Stdout
for i, p := range devices {
fmt.Fprintf(stdout, "-- Device %v: %v --\n", i, p.ID.ID())
deviceObjs := []deviceObj{}
for _, p := range devices {
o, err := client.Get(ctx, p.Path(), nil)
if err != nil {
fmt.Fprintf(stdout, "%v\n", log.Err(ctx, err, "Couldn't resolve device"))
log.Err(ctx, err, "Couldn't resolve device")
continue
}
d := o.(*device.Instance)
if verb.OS != device.UnknownOS && verb.OS != d.GetConfiguration().GetOS().GetKind() {
continue
}
jsonBytes, err := json.MarshalIndent(d, "", " ")
if err != nil {
fmt.Fprintf(stdout, "%v\n", log.Err(ctx, err, "Couldn't marshal device to JSON"))
continue
devObj := deviceObj{
DeviceID: fmt.Sprintf("%v", p.ID.ID()),
Instance: d,
}
fmt.Fprintln(stdout, string(jsonBytes))
deviceObjs = append(deviceObjs, devObj)
}

jsonBytes, err := json.MarshalIndent(deviceObjs, "", " ")
if err != nil {
return log.Err(ctx, err, "Failed to marshal devices to JSON")
}
fmt.Fprintln(os.Stdout, string(jsonBytes))

return nil
}
11 changes: 6 additions & 5 deletions core/os/android/adb/adb_data_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,11 +194,12 @@ untagSocket(48) failed with errno -22
`),

// Common responses to all devices
stub.Regex(`adb -s .* shell getprop ro\.build\.product`, stub.Respond("hammerhead")),
stub.Regex(`adb -s .* shell getprop ro\.build\.version\.release`, stub.Respond("6.0.1")),
stub.Regex(`adb -s .* shell getprop ro\.build\.description`, stub.Respond("hammerhead-user 6.0.1 MMB29Q 2480792 release-keys")),
stub.Regex(`adb -s .* shell getprop ro\.product\.cpu\.abi`, stub.Respond("armeabi-v7a")),
stub.Regex(`adb -s .* shell getprop ro\.build\.version\.sdk`, stub.Respond("26")),
stub.Regex(`adb -s .* shell getprop ro\.build\.product`, stub.Respond("flame")),
stub.Regex(`adb -s .* shell getprop ro\.build\.version\.release`, stub.Respond("10")),
stub.Regex(`adb -s .* shell getprop ro\.build\.description`, stub.Respond("flame-user 10 QQ1A.191003.005 5926727 release-keys")),
stub.Regex(`adb -s .* shell getprop ro\.product\.cpu\.abi`, stub.Respond("arm64-v8a")),
stub.Regex(`adb -s .* shell getprop ro\.build\.version\.sdk`, stub.Respond("29")),
stub.Regex(`adb -s .* shell setprop persist\.traced\.enable 1`, stub.Respond("")),

stub.Regex(`adb -s .* shell input .*`, stub.Respond("")),
)
Expand Down
4 changes: 2 additions & 2 deletions core/os/android/adb/adb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ func mustConnect(ctx context.Context, serial string) adb.Device {
func TestADBShell(t_ *testing.T) {
ctx := log.Testing(t_)
d := mustConnect(ctx, "production_device")
assert.For(ctx, "Device").ThatString(d).Equals("hammerhead")
assert.For(ctx, "Device shell").ThatString(d.Shell("").Target).Equals("shell:hammerhead")
assert.For(ctx, "Device").ThatString(d).Equals("flame")
assert.For(ctx, "Device shell").ThatString(d.Shell("").Target).Equals("shell:flame")
}
14 changes: 14 additions & 0 deletions core/os/android/adb/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,20 @@ func (b *binding) ConnectPerfetto(ctx context.Context) (*perfetto.Client, error)
return perfetto.NewClient(ctx, conn, cleanup)
}

// EnsurePerfettoPersistent ensures that Perfetto daemons, traced and
// traced_probes, are running. Note that there is a delay between setting the
// system property and daemons finish starting, hence this function needs to be
// called as early as possible.
func (b *binding) EnsurePerfettoPersistent(ctx context.Context) error {
if !b.SupportsPerfetto(ctx) {
return fmt.Errorf("Perfetto is not supported on this device")
}
if err := b.SetSystemProperty(ctx, "persist.traced.enable", "1"); err != nil {
return err
}
return nil
}

func (b *binding) QueryPerfettoServiceState(ctx context.Context) (*device.PerfettoCapability, error) {
result := b.To.Configuration.PerfettoCapability
if result == nil {
Expand Down
48 changes: 48 additions & 0 deletions core/os/android/adb/device.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ import (
"sync"
"time"

"github.com/google/gapid/core/app"
"github.com/google/gapid/core/event/task"
"github.com/google/gapid/core/fault"
"github.com/google/gapid/core/log"
"github.com/google/gapid/core/os/android"
"github.com/google/gapid/core/os/device"
"github.com/google/gapid/core/os/device/bind"
"github.com/google/gapid/core/os/shell"
Expand All @@ -39,6 +41,8 @@ const (
ErrInvalidStatus = fault.Const("Invalid status string")
// Frequency at which to print scan errors.
printScanErrorsEveryNSeconds = 120
// Global settings for opting to use prerelease driver.
prereleaseDriverSettingVariable = "game_driver_prerelease_opt_in_apps"
)

var (
Expand Down Expand Up @@ -110,6 +114,24 @@ func Devices(ctx context.Context) (DeviceList, error) {
return out, nil
}

func SetupPrereleaseDriver(ctx context.Context, d Device, p *android.InstalledPackage) (app.Cleanup, error) {
oldOptinApps, err := d.SystemSetting(ctx, "global", prereleaseDriverSettingVariable)
if err != nil {
return nil, log.Err(ctx, err, "Failed to get prerelease driver opt in apps.")
}
if strings.Contains(oldOptinApps, p.Name) {
return nil, nil
}
newOptinApps := oldOptinApps + "," + p.Name
// TODO(b/145893290) Check whether application has developer driver enabled once b/145893290 is fixed.
if err := d.SetSystemSetting(ctx, "global", prereleaseDriverSettingVariable, newOptinApps); err != nil {
return nil, log.Errf(ctx, err, "Failed to set up prerelease driver for app: %v.", p.Name)
}
return func(ctx context.Context) {
d.SetSystemSetting(ctx, "global", prereleaseDriverSettingVariable, oldOptinApps)
}, nil
}

func newDevice(ctx context.Context, serial string, status bind.Status) (*binding, error) {
d := &binding{
Simple: bind.Simple{
Expand Down Expand Up @@ -167,6 +189,11 @@ func newDevice(ctx context.Context, serial string, status bind.Status) (*binding
}
}

// Make sure Perfetto daemons are running.
if err := d.EnsurePerfettoPersistent(ctx); err != nil {
return nil, err
}

// Run device info providers only if the API is supported
if d.To.Configuration.OS != nil && d.To.Configuration.OS.APIVersion >= device.AndroidMinimalSupportedAPIVersion {
devInfoProvidersMutex.Lock()
Expand All @@ -183,6 +210,27 @@ func newDevice(ctx context.Context, serial string, status bind.Status) (*binding
d.To.Configuration.PerfettoCapability = perfettoCapability
}

// If the VkRenderStagesProducer layer exist, we assume the render stages producer is
// implemented in the layer.
for _, l := range d.To.Configuration.GetDrivers().GetVulkan().GetLayers() {
if l.Name == "VkRenderStagesProducer" {
capability := d.To.Configuration.PerfettoCapability
if capability == nil {
capability = &device.PerfettoCapability{
GpuProfiling: &device.GPUProfiling{},
}
}
gpu := capability.GpuProfiling
if gpu == nil {
gpu = &device.GPUProfiling{}
capability.GpuProfiling = gpu
}
gpu.HasRenderStageProducerLayer = true
gpu.HasRenderStage = true
break
}
}

if d.To.Configuration == nil ||
d.To.Configuration.Hardware == nil {
return nil, log.Errf(ctx, nil, "Cannot get device information")
Expand Down
16 changes: 8 additions & 8 deletions core/os/android/adb/device_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,21 +30,21 @@ func TestParseDevices(t_ *testing.T) {
defer func() { devices.Handlers[0] = validDevices }()
expected := &device.Instance{
Serial: "production_device",
Name: "hammerhead",
Name: "flame",
Configuration: &device.Configuration{
OS: &device.OS{
Kind: device.Android,
Name: "Marshmallow",
Build: "hammerhead-user 6.0.1 MMB29Q 2480792 release-keys",
MajorVersion: 6,
Name: "Android 10",
Build: "flame-user 10 QQ1A.191003.005 5926727 release-keys",
MajorVersion: 10,
MinorVersion: 0,
PointVersion: 1,
APIVersion: 26,
PointVersion: 0,
APIVersion: 29,
},
Hardware: &device.Hardware{
Name: "hammerhead",
Name: "flame",
},
ABIs: []*device.ABI{device.AndroidARMv7a},
ABIs: []*device.ABI{device.AndroidARM64v8a},
},
}
expected.GenID()
Expand Down
25 changes: 17 additions & 8 deletions core/os/android/layers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,9 @@ import (

const eglLayersExt = "EGL_ANDROID_GLES_layers"

// SupportsLayersViaSystemSettings returns whether the given device supports
// loading GLES and Vulkan layers via the system settings.
func SupportsLayersViaSystemSettings(d Device) bool {
// TODO: this currently looks for the EGL extension that advertises the
// GLES layer loading capability. Technically, the extension could be
// absent, but the device could still support loading Vulkan layers via
// the settings. There doesn't appear to be a way to detect Vulkan support
// and we currently assume a device either supports both, or none.
// SupportsGLESLayersViaSystemSettings returns whether the given device supports
// loading GLES layers via the system settings.
func SupportsGLESLayersViaSystemSettings(d Device) bool {
exts := d.Instance().GetConfiguration().GetDrivers().GetOpengl().GetExtensions()
for _, ext := range exts {
if ext == eglLayersExt {
Expand All @@ -41,6 +36,14 @@ func SupportsLayersViaSystemSettings(d Device) bool {
return false
}

// SupportsVulkanLayersViaSystemSettings returns whether the given device supports
// loading Vulkan layers via the system settings.
func SupportsVulkanLayersViaSystemSettings(d Device) bool {
// Supported since Android P / API level 28
apiVersion := d.Instance().GetConfiguration().GetOS().GetAPIVersion()
return apiVersion >= 28
}

// SetupLayer initializes d to use either a Vulkan or GLES layer from layerPkgs
// limited to the app with package appPkg using the system settings and returns
// a cleanup to remove the layer settings.
Expand Down Expand Up @@ -74,6 +77,12 @@ func SetupLayers(ctx context.Context, d Device, appPkg string, layerPkgs []strin
return cleanup.Invoke(ctx), err
}
}
} else {
if vulkan {
d.DeleteSystemSetting(ctx, "global", "gpu_debug_layers")
} else {
d.DeleteSystemSetting(ctx, "global", "gpu_debug_layers_gles")
}
}

return cleanup, nil
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 @@ -191,6 +191,7 @@ message GPUProfiling {
// The GPU performance counters.
GpuCounterDescriptor gpu_counter_descriptor = 2;
bool hasFrameLifecycle = 3;
bool has_render_stage_producer_layer = 4;
}

// Instance represents a physical device.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ void ThreadlocalEmitter<T>::EmitProcessData() {
uint64_t category_iid = InternCategory("cat", packet, &interned_data);

auto* track_event = packet->set_track_event();
track_event->set_timestamp_absolute_us(time / 1000);
track_event->add_category_iids(category_iid);

auto* debug_annotation = track_event->add_debug_annotations();
Expand Down Expand Up @@ -278,7 +277,6 @@ void ThreadlocalEmitter<T>::StartEvent(const char* category, const char* name) {
InternCategory(category, packet, &interned_data);

auto track_event = packet->set_track_event();
track_event->set_timestamp_absolute_us(time / 1000);
track_event->add_category_iids(category_iid);

auto legacy_event = track_event->set_legacy_event();
Expand Down Expand Up @@ -306,7 +304,6 @@ void ThreadlocalEmitter<T>::EndEvent(const char* category) {
InternCategory(category, packet, &interned_data);

auto track_event = packet->set_track_event();
track_event->set_timestamp_absolute_us(time / 1000);
track_event->add_category_iids(category_iid);

auto legacy_event = track_event->set_legacy_event();
Expand Down
13 changes: 0 additions & 13 deletions core/vulkan/vk_memory_tracker_layer/cc/memory_tracker_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,6 @@

namespace memory_tracker {

VkResult vkCreateDevice(PFN_vkCreateDevice fn, VkPhysicalDevice physicalDevice,
const VkDeviceCreateInfo* pCreateInfo,
AllocationCallbacks pAllocator, VkDevice* pDevice) {
return fn(physicalDevice, pCreateInfo, pAllocator, pDevice);
}

void vkCmdDraw(PFN_vkCmdDraw fn, VkCommandBuffer commandBuffer,
uint32_t vertexCount, uint32_t instanceCount,
uint32_t firstVertex, uint32_t firstInstance) {
Expand All @@ -37,11 +31,4 @@ VkResult vkQueueSubmit(PFN_vkQueueSubmit fn, VkQueue queue,
return fn(queue, submitCount, pSubmits, fence);
}

VkResult vkCreateInstance(PFN_vkCreateInstance fn,
const VkInstanceCreateInfo* pCreateInfo,
AllocationCallbacks pAllocator,
VkInstance* pInstance) {
return fn(pCreateInfo, pAllocator, pInstance);
}

} // namespace memory_tracker
Binary file modified gapic/res/icons/pin_active.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified gapic/res/icons/pin_inactive.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading