Commit 653ee5f1 by Jamie Madill Committed by Commit Bot

Capture/Replay: Introduce capture index file.

This index file lets us very easily write a generic capture sample. Previously the dev had to maintain a list of multiple sources files. Potentially hundreds. By writing the source file list to an index file we can load this easily in GN as a variable and plug that into the sources. Also updates docs. Bug: angleproject:3611 Change-Id: I69ba961e271d6d13d06ae01c89a0605a6fd725ec Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1902189 Commit-Queue: Jamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com>
parent e167f76b
...@@ -52,27 +52,19 @@ $ ANGLE_CAPTURE_FRAME_END=4 ANGLE_CAPTURE_OUT_DIR=samples/capture_replay out/Deb ...@@ -52,27 +52,19 @@ $ ANGLE_CAPTURE_FRAME_END=4 ANGLE_CAPTURE_OUT_DIR=samples/capture_replay out/Deb
## Running a CPP replay ## Running a CPP replay
To run a CPP replay you can use a template located in To run a CPP replay you can use a template located in
[samples/capture_replay](../samples/capture_replay). Update [samples/capture_replay](../samples/capture_replay). First run your capture and ensure all capture
[samples/BUILD.gn](../samples/BUILD.gn) to enable `capture_replay_sample` files are written to `samples/capture_replay`. You can conveniently use `ANGLE_CAPTURE_OUT_DIR`.
sample to include your replay frames: Then enable the `capture_replay_sample` via `gn args`:
``` ```
angle_capture_replay_sample("capture_replay_sample") { angle_build_capture_replay_sample = true
sources = [
"capture_replay/angle_capture_context1_frame000.cpp",
"capture_replay/angle_capture_context1_frame001.cpp",
"capture_replay/angle_capture_context1_frame002.cpp",
"capture_replay/angle_capture_context1_frame003.cpp",
"capture_replay/angle_capture_context1_frame004.cpp",
]
}
``` ```
Then build and run your replay sample: See [samples/BUILD.gn](../samples/BUILD.gn) for details. Then build and run your replay sample:
``` ```
$ autoninja -C out/Debug capture_replay $ autoninja -C out/Debug capture_replay_sample
$ ANGLE_CAPTURE_ENABLED=0 out/Debug/capture_replay $ ANGLE_CAPTURE_ENABLED=0 out/Debug/capture_replay_sample
``` ```
Note that we specify `ANGLE_CAPTURE_ENABLED=0` to prevent re-capturing your replay. Note that we specify `ANGLE_CAPTURE_ENABLED=0` to prevent re-capturing when running the replay.
...@@ -4,6 +4,11 @@ ...@@ -4,6 +4,11 @@
import("../gni/angle.gni") import("../gni/angle.gni")
declare_args() {
# Determines if we build the capture_replay sample. Off by default.
angle_build_capture_replay_sample = false
}
angle_executable("shader_translator") { angle_executable("shader_translator") {
sources = [ sources = [
"shader_translator/shader_translator.cpp", "shader_translator/shader_translator.cpp",
...@@ -218,13 +223,19 @@ angle_sample("gles1_draw_texture") { ...@@ -218,13 +223,19 @@ angle_sample("gles1_draw_texture") {
] ]
} }
template("angle_capture_replay_sample") { if (angle_build_capture_replay_sample) {
angle_sample(target_name) { # The capture_replay sample is set up to work with a single Context.
sources = invoker.sources + [ # To use the capture replay sample first move your capture sources into
"capture_replay/CaptureReplay.cpp", # the capture_replay folder and enable the gn arg above.
"capture_replay/angle_capture_context1.cpp", angle_sample("capture_replay_sample") {
"capture_replay/angle_capture_context1.h", sources =
] rebase_path(read_file("capture_replay/angle_capture_context1_files.txt",
"list lines"), ".", "capture_replay") +
[
"capture_replay/CaptureReplay.cpp",
"capture_replay/angle_capture_context1.cpp",
"capture_replay/angle_capture_context1.h",
]
_data_path = rebase_path("capture_replay", root_out_dir) _data_path = rebase_path("capture_replay", root_out_dir)
defines = [ "ANGLE_CAPTURE_REPLAY_SAMPLE_DATA_DIR=\"${_data_path}\"" ] defines = [ "ANGLE_CAPTURE_REPLAY_SAMPLE_DATA_DIR=\"${_data_path}\"" ]
...@@ -232,20 +243,6 @@ template("angle_capture_replay_sample") { ...@@ -232,20 +243,6 @@ template("angle_capture_replay_sample") {
} }
} }
# The capture_replay sample is set up to work with a single Context.
# To use the capture replay sample fist move your capture sources into
# the capture_replay folder. Uncomment and update this target:
# capture_replay("my_sample") {
# sources = [
# "capture_replay/angle_capture_context1_frame000.cpp",
# "capture_replay/angle_capture_context1_frame001.cpp",
# "capture_replay/angle_capture_context1_frame002.cpp",
# "capture_replay/angle_capture_context1_frame003.cpp",
# "capture_replay/angle_capture_context1_frame004.cpp",
# ]
# }
group("all") { group("all") {
testonly = true testonly = true
deps = [ deps = [
......
...@@ -697,6 +697,18 @@ void WriteCppReplayIndexFiles(const std::string &outDir, ...@@ -697,6 +697,18 @@ void WriteCppReplayIndexFiles(const std::string &outDir,
SaveFileHelper saveSource(sourcePath); SaveFileHelper saveSource(sourcePath);
saveSource << sourceContents; saveSource << sourceContents;
} }
{
std::stringstream indexPathStream;
indexPathStream << outDir << FmtCapturePrefix(contextId) << "_files.txt";
std::string indexPath = indexPathStream.str();
SaveFileHelper saveIndex(indexPath);
for (uint32_t frameIndex = frameStart; frameIndex <= frameEnd; ++frameIndex)
{
saveIndex << GetCaptureFileName(contextId, frameIndex, ".cpp") << "\n";
}
}
} }
ProgramSources GetAttachedProgramSources(const gl::Program *program) ProgramSources GetAttachedProgramSources(const gl::Program *program)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment