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

Add support for rendering during replay to the surface #2112

Merged
merged 12 commits into from
Aug 1, 2018
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
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
14 changes: 14 additions & 0 deletions cmd/gapir/cc/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "gapir/cc/resource_in_memory_cache.h"
#include "gapir/cc/resource_requester.h"
#include "gapir/cc/server.h"
#include "gapir/cc/surface.h"

#include "core/cc/crash_handler.h"
#include "core/cc/debugger.h"
Expand Down Expand Up @@ -129,6 +130,17 @@ const char* pipeName() {
#endif
}

void android_process(struct android_app* app, int32_t cmd) {
switch (cmd) {
case APP_CMD_INIT_WINDOW: {
gapir::android_window = app->window;
__android_log_print(ANDROID_LOG_DEBUG, "GAPIR",
"Received window: %p\n", gapir::android_window);
break;
}
}
}

// Main function for android
void android_main(struct android_app* app) {
MemoryManager memoryManager(memorySizes);
Expand Down Expand Up @@ -156,6 +168,8 @@ void android_main(struct android_app* app) {
GAPID_ERROR("Chmod failed!");
}

app->onAppCmd = android_process;

bool alive = true;
while (alive) {
int ident;
Expand Down
11 changes: 7 additions & 4 deletions cmd/gapit/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,10 @@ type (
DeviceFlags
}
ReportFlags struct {
Gapis GapisFlags
Gapir GapirFlags
Out string `help:"output report path"`
Gapis GapisFlags
Gapir GapirFlags
Out string `help:"output report path"`
DisplayToSurface bool `help:"display the frames rendered in the replay back to the surface"`
CommandFilterFlags
}
VideoFlags struct {
Expand All @@ -122,7 +123,8 @@ type (
Count int `help:"number of frames after Start to capture: -1 for all frames"`
Minimum int `help:"_return error when less than this number of frames is found"`
}
NoOpt bool `help:"disables optimization of the replay stream"`
NoOpt bool `help:"disables optimization of the replay stream"`
DisplayToSurface bool `help:"display the frames rendered in the replay back to the surface"`
CommandFilterFlags
}
DumpShadersFlags struct {
Expand Down Expand Up @@ -235,6 +237,7 @@ type (
Max struct {
Overdraw int `help:"the amount of overdraw to map to white in the output"`
}
DisplayToSurface bool `help:"display the frames rendered in the replay back to the surface"`
CommandFilterFlags
}
UnpackFlags struct {
Expand Down
3 changes: 2 additions & 1 deletion cmd/gapit/report.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,8 @@ func (verb *reportVerb) Run(ctx context.Context, flags flag.FlagSet) error {
}
commands := boxedCommands.(*service.Commands).List

boxedReport, err := client.Get(ctx, capturePath.Report(device, filter).Path())
boxedReport, err := client.Get(ctx, capturePath.Report(device, filter,
verb.DisplayToSurface).Path())
if err != nil {
return log.Err(ctx, err, "Failed to acquire the capture's report")
}
Expand Down
1 change: 1 addition & 0 deletions cmd/gapit/screenshot.go
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,7 @@ func (verb *screenshotVerb) getSingleFrame(ctx context.Context, cmd *path.Comman
&service.ReplaySettings{
Device: device,
DisableReplayOptimization: verb.NoOpt,
DisplayToSurface: verb.DisplayToSurface,
},
cmd, attachment, settings, nil)
if err != nil {
Expand Down
2 changes: 1 addition & 1 deletion cmd/gapit/sxs_video.go
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ func (verb *videoVerb) sxsVideoSource(
Stride: int(v.fbo.Width) * 4,
Rect: image.Rect(0, 0, int(v.fbo.Width), int(v.fbo.Height)),
}
if frame, err := getFrame(ctx, verb.Max.Width, verb.Max.Height, v.command, device, client, verb.NoOpt); err == nil {
if frame, err := getFrame(ctx, verb.Max.Width, verb.Max.Height, v.command, device, client, verb.NoOpt, verb.DisplayToSurface); err == nil {
v.rendered = frame
} else {
v.renderError = err
Expand Down
5 changes: 3 additions & 2 deletions cmd/gapit/video.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ func (verb *videoVerb) regularVideoSource(
for i, e := range eofEvents {
i, e := i, e
executor(ctx, func(ctx context.Context) error {
if frame, err := getFrame(ctx, verb.Max.Width, verb.Max.Height, e.Command, device, client, verb.NoOpt); err == nil {
if frame, err := getFrame(ctx, verb.Max.Width, verb.Max.Height, e.Command, device, client, verb.NoOpt, verb.DisplayToSurface); err == nil {
rendered[i] = flipImg(frame)
} else {
errors[i] = err
Expand Down Expand Up @@ -327,12 +327,13 @@ func (verb *videoVerb) encodeVideo(ctx context.Context, filepath string, vidFun
return nil
}

func getFrame(ctx context.Context, maxWidth, maxHeight int, cmd *path.Command, device *path.Device, client service.Service, noOpt bool) (*image.NRGBA, error) {
func getFrame(ctx context.Context, maxWidth, maxHeight int, cmd *path.Command, device *path.Device, client service.Service, noOpt bool, display bool) (*image.NRGBA, error) {
ctx = log.V{"cmd": cmd.Indices}.Bind(ctx)
settings := &service.RenderSettings{MaxWidth: uint32(maxWidth), MaxHeight: uint32(maxHeight)}
iip, err := client.GetFramebufferAttachment(ctx, &service.ReplaySettings{
Device: device,
DisableReplayOptimization: noOpt,
DisplayToSurface: display,
}, cmd, api.FramebufferAttachment_Color0, settings, nil)
if err != nil {
return nil, log.Errf(ctx, err, "GetFramebufferAttachment failed at %v", cmd)
Expand Down
18 changes: 18 additions & 0 deletions core/vulkan/vk_virtual_swapchain/cc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,24 @@ cc_library(
],
)

cc_library(
name = "headers",
srcs = glob([
"*.h",
]),
copts = cc_copts() + select({
"//tools/build:linux": ["-DVK_USE_PLATFORM_XCB_KHR"],
"//tools/build:darwin": [],
"//tools/build:windows": ["-DVK_USE_PLATFORM_WIN32_KHR"],
# Android
"//conditions:default": ["-DVK_USE_PLATFORM_ANDROID_KHR"],
}),
visibility = ["//visibility:public"],
deps = [
"//core/vulkan/cc/include/vulkan",
],
)

cc_dynamic_library(
name = "libVkLayer_VirtualSwapchain",
visibility = ["//visibility:public"],
Expand Down
Loading