Commit b69c4e14 by Cody Northrop Committed by Commit Bot

Capture/Replay: Update CaptureReplay sample for compression

* Move DecompressBinaryData to a shared helper * Start using it in CaptureReplay sample * Error out if decompress callback isn't set correctly Test: AngryBirds and CandyCrush captures replay on desktop Test: angle_perftests --gtest_filter="*Trace*" Bug: angleproject:4484 Change-Id: I0432004fdb0cfb0fd61f9a66f792591c9aa40d9b Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2118790 Commit-Queue: Cody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 78c77361
...@@ -58,9 +58,10 @@ template("angle_sample") { ...@@ -58,9 +58,10 @@ template("angle_sample") {
[ [
"cflags", "cflags",
"defines", "defines",
"deps",
"sources", "sources",
]) ])
deps = [ ":sample_util" ] deps += [ ":sample_util" ]
if (defined(invoker.data)) { if (defined(invoker.data)) {
deps += [ ":${target_name}_data" ] deps += [ ":${target_name}_data" ]
} }
...@@ -71,6 +72,10 @@ template("angle_sample") { ...@@ -71,6 +72,10 @@ template("angle_sample") {
} }
} }
set_defaults("angle_sample") {
deps = []
}
angle_sample("hello_triangle") { angle_sample("hello_triangle") {
sources = [ "hello_triangle/HelloTriangle.cpp" ] sources = [ "hello_triangle/HelloTriangle.cpp" ]
} }
...@@ -188,6 +193,8 @@ if (angle_build_capture_replay_sample) { ...@@ -188,6 +193,8 @@ if (angle_build_capture_replay_sample) {
"capture_replay/angle_capture_context${_contextid}.h", "capture_replay/angle_capture_context${_contextid}.h",
] ]
deps = [ "$angle_root:angle_compression" ]
_data_path = rebase_path("capture_replay", root_out_dir) _data_path = rebase_path("capture_replay", root_out_dir)
defines = [ defines = [
"ANGLE_CAPTURE_REPLAY_SAMPLE_DATA_DIR=\"${_data_path}\"", "ANGLE_CAPTURE_REPLAY_SAMPLE_DATA_DIR=\"${_data_path}\"",
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include <functional> #include <functional>
#include "util/frame_capture_utils.h"
#define ANGLE_MACRO_STRINGIZE_AUX(a) #a #define ANGLE_MACRO_STRINGIZE_AUX(a) #a
#define ANGLE_MACRO_STRINGIZE(a) ANGLE_MACRO_STRINGIZE_AUX(a) #define ANGLE_MACRO_STRINGIZE(a) ANGLE_MACRO_STRINGIZE_AUX(a)
#define ANGLE_MACRO_CONCAT_AUX(a, b) a##b #define ANGLE_MACRO_CONCAT_AUX(a, b) a##b
...@@ -39,6 +41,10 @@ class CaptureReplaySample : public SampleApplication ...@@ -39,6 +41,10 @@ class CaptureReplaySample : public SampleApplication
std::string exeDir = angle::GetExecutableDirectory(); std::string exeDir = angle::GetExecutableDirectory();
if (!angle::SetCWD(exeDir.c_str())) if (!angle::SetCWD(exeDir.c_str()))
return false; return false;
if (kIsBinaryDataCompressed)
{
SetBinaryDataDecompressCallback(angle::DecompressBinaryData);
}
SetBinaryDataDir(ANGLE_CAPTURE_REPLAY_SAMPLE_DATA_DIR); SetBinaryDataDir(ANGLE_CAPTURE_REPLAY_SAMPLE_DATA_DIR);
SetupContextReplay(); SetupContextReplay();
......
...@@ -961,12 +961,22 @@ void WriteCppReplayIndexFiles(bool compression, ...@@ -961,12 +961,22 @@ void WriteCppReplayIndexFiles(bool compression,
source << " fseek(fp, 0, SEEK_SET);\n"; source << " fseek(fp, 0, SEEK_SET);\n";
source << " if (gDecompressCallback)\n"; source << " if (gDecompressCallback)\n";
source << " {\n"; source << " {\n";
source << " if (!strstr(fileName, \".gz\"))\n";
source << " {\n";
source << " fprintf(stderr, \"Filename does not end in .gz\");\n";
source << " exit(1);\n";
source << " }\n";
source << " std::vector<uint8_t> compressedData(size);\n"; source << " std::vector<uint8_t> compressedData(size);\n";
source << " (void)fread(compressedData.data(), 1, size, fp);\n"; source << " (void)fread(compressedData.data(), 1, size, fp);\n";
source << " gBinaryData = gDecompressCallback(compressedData);\n"; source << " gBinaryData = gDecompressCallback(compressedData);\n";
source << " }\n"; source << " }\n";
source << " else\n"; source << " else\n";
source << " {\n"; source << " {\n";
source << " if (!strstr(fileName, \".angledata\"))\n";
source << " {\n";
source << " fprintf(stderr, \"Filename does not end in .angledata\");\n";
source << " exit(1);\n";
source << " }\n";
source << " gBinaryData = new uint8_t[size];\n"; source << " gBinaryData = new uint8_t[size];\n";
source << " (void)fread(gBinaryData, 1, size, fp);\n"; source << " (void)fread(gBinaryData, 1, size, fp);\n";
source << " }\n"; source << " }\n";
......
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "tests/perf_tests/ANGLEPerfTest.h" #include "tests/perf_tests/ANGLEPerfTest.h"
#include "tests/perf_tests/DrawCallPerfParams.h" #include "tests/perf_tests/DrawCallPerfParams.h"
#include "util/egl_loader_autogen.h" #include "util/egl_loader_autogen.h"
#include "util/frame_capture_utils.h"
#include "restricted_traces/manhattan_10/manhattan_10_capture_context1.h" #include "restricted_traces/manhattan_10/manhattan_10_capture_context1.h"
#include "restricted_traces/trex_200/trex_200_capture_context1.h" #include "restricted_traces/trex_200/trex_200_capture_context1.h"
...@@ -21,9 +22,6 @@ ...@@ -21,9 +22,6 @@
#include <functional> #include <functional>
#include <sstream> #include <sstream>
#define USE_SYSTEM_ZLIB
#include "compression_utils_portable.h"
using namespace angle; using namespace angle;
using namespace egl_platform; using namespace egl_platform;
...@@ -31,26 +29,6 @@ namespace ...@@ -31,26 +29,6 @@ namespace
{ {
void FramebufferChangeCallback(void *userData, GLenum target, GLuint framebuffer); void FramebufferChangeCallback(void *userData, GLenum target, GLuint framebuffer);
ANGLE_MAYBE_UNUSED uint8_t *DecompressBinaryData(const std::vector<uint8_t> &compressedData)
{
uint32_t uncompressedSize =
zlib_internal::GetGzipUncompressedSize(compressedData.data(), compressedData.size());
std::unique_ptr<uint8_t[]> uncompressedData(new uint8_t[uncompressedSize]);
uLong destLen = uncompressedSize;
int zResult =
zlib_internal::GzipUncompressHelper(uncompressedData.get(), &destLen, compressedData.data(),
static_cast<uLong>(compressedData.size()));
if (zResult != Z_OK)
{
std::cerr << "Failure to decompressed binary data: " << zResult << "\n";
return nullptr;
}
return uncompressedData.release();
}
enum class TracePerfTestID enum class TracePerfTestID
{ {
Manhattan10, Manhattan10,
......
...@@ -15,6 +15,7 @@ _util_sources = [ ...@@ -15,6 +15,7 @@ _util_sources = [
"OSWindow.cpp", "OSWindow.cpp",
"OSWindow.h", "OSWindow.h",
"com_utils.h", "com_utils.h",
"frame_capture_utils.h",
"geometry_utils.cpp", "geometry_utils.cpp",
"geometry_utils.h", "geometry_utils.h",
"keyboard.h", "keyboard.h",
......
//
// Copyright 2020 The ANGLE Project Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
//
// frame_capture_utils:
// Helper functions for capture and replay of traces.
//
#ifndef UTIL_FRAME_CAPTURE_UTILS_H_
#define UTIL_FRAME_CAPTURE_UTILS_H_
#include <iostream>
#include <memory>
#include <vector>
#include "common/angleutils.h"
#define USE_SYSTEM_ZLIB
#include "compression_utils_portable.h"
namespace angle
{
inline uint8_t *DecompressBinaryData(const std::vector<uint8_t> &compressedData)
{
uint32_t uncompressedSize =
zlib_internal::GetGzipUncompressedSize(compressedData.data(), compressedData.size());
std::unique_ptr<uint8_t[]> uncompressedData(new uint8_t[uncompressedSize]);
uLong destLen = uncompressedSize;
int zResult =
zlib_internal::GzipUncompressHelper(uncompressedData.get(), &destLen, compressedData.data(),
static_cast<uLong>(compressedData.size()));
if (zResult != Z_OK)
{
std::cerr << "Failure to decompressed binary data: " << zResult << "\n";
return nullptr;
}
return uncompressedData.release();
}
} // namespace angle
#endif // UTIL_FRAME_CAPTURE_UTILS_H_
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