Commit e60ce3da by Jamie Madill Committed by Commit Bot

Capture/Replay: Allow testing with multiple versions.

This embeds the context version and device type info into the replay. The self-tests then can create the correct display and context types. This fixes testing against SwiftShader which is necessary for the bots. Bug: angleproject:4759 Change-Id: If9da6bfdc1c2b315ccd7e453872fc84063277054 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2643363Reviewed-by: 's avatarTim Van Patten <timvp@google.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Commit-Queue: Jamie Madill <jmadill@chromium.org>
parent b745f6df
......@@ -1110,7 +1110,7 @@ void WriteCppReplay(bool compression,
void WriteCppReplayIndexFiles(bool compression,
const std::string &outDir,
const gl::ContextID contextId,
const gl::Context *context,
const std::string &captureLabel,
uint32_t frameCount,
const SurfaceDimensions &drawSurfaceDimensions,
......@@ -1119,11 +1119,12 @@ void WriteCppReplayIndexFiles(bool compression,
const HasResourceTypeMap &hasResourceType,
bool serializeStateEnabled,
bool writeResetContextCall,
const egl::Config *config,
std::vector<uint8_t> &binaryData)
{
size_t maxClientArraySize = MaxClientArraySize(clientArraySizes);
const gl::ContextID contextId = context->id();
const egl::Config *config = context->getConfig();
size_t maxClientArraySize = MaxClientArraySize(clientArraySizes);
const egl::AttributeMap &attributes = context->getDisplay()->getAttributeMap();
std::stringstream header;
std::stringstream source;
......@@ -1169,6 +1170,14 @@ void WriteCppReplayIndexFiles(bool compression,
header << "_" << captureLabelUpper;
}
header << " " << ANGLE_REVISION << "\n";
header << "constexpr uint32_t kReplayContextClientMajorVersion = "
<< context->getClientMajorVersion() << ";\n";
header << "constexpr uint32_t kReplayContextClientMinorVersion = "
<< context->getClientMinorVersion() << ";\n";
header << "constexpr EGLint kReplayPlatformType = "
<< attributes.getAsInt(EGL_PLATFORM_ANGLE_TYPE_ANGLE) << ";\n";
header << "constexpr EGLint kReplayDeviceType = "
<< attributes.getAsInt(EGL_PLATFORM_ANGLE_DEVICE_TYPE_ANGLE) << ";\n";
header << "constexpr uint32_t kReplayFrameStart = 1;\n";
header << "constexpr uint32_t kReplayFrameEnd = " << frameCount << ";\n";
header << "constexpr EGLint kReplayDrawSurfaceWidth = "
......@@ -4432,10 +4441,10 @@ void FrameCapture::onEndFrame(const gl::Context *context)
if (mFrameIndex == mCaptureEndFrame)
{
// Save the index files after the last frame.
WriteCppReplayIndexFiles(mCompression, mOutDirectory, context->id(), mCaptureLabel,
WriteCppReplayIndexFiles(mCompression, mOutDirectory, context, mCaptureLabel,
getFrameCount(), mDrawSurfaceDimensions, mReadBufferSize,
mClientArraySizes, mHasResourceType, mSerializeStateEnabled,
false, context->getConfig(), mBinaryData);
false, mBinaryData);
if (!mBinaryData.empty())
{
SaveBinaryData(mCompression, mOutDirectory, context->id(), mCaptureLabel,
......@@ -4483,10 +4492,10 @@ void FrameCapture::onDestroyContext(const gl::Context *context)
// It doesnt make sense to write the index files when no frame has been recorded
mFrameIndex -= 1;
mCaptureEndFrame = mFrameIndex;
WriteCppReplayIndexFiles(mCompression, mOutDirectory, context->id(), mCaptureLabel,
WriteCppReplayIndexFiles(mCompression, mOutDirectory, context, mCaptureLabel,
getFrameCount(), mDrawSurfaceDimensions, mReadBufferSize,
mClientArraySizes, mHasResourceType, mSerializeStateEnabled, true,
context->getConfig(), mBinaryData);
mBinaryData);
if (!mBinaryData.empty())
{
SaveBinaryData(mCompression, mOutDirectory, context->id(), mCaptureLabel, mBinaryData);
......
......@@ -85,6 +85,10 @@ switch_statement_template = \
test_trace_info_init_template = \
""" {{
"{namespace}",
{namespace}::kReplayContextClientMajorVersion,
{namespace}::kReplayContextClientMinorVersion,
{namespace}::kReplayPlatformType,
{namespace}::kReplayDeviceType,
{namespace}::kReplayFrameStart,
{namespace}::kReplayFrameEnd,
{namespace}::kReplayDrawSurfaceWidth,
......@@ -117,6 +121,10 @@ void SetBinaryDataDir(uint32_t test, const char *dataDir);
struct TestTraceInfo {{
std::string testName;
uint32_t replayContextMajorVersion;
uint32_t replayContextMinorVersion;
EGLint replayPlatformType;
EGLint replayDeviceType;
uint32_t replayFrameStart;
uint32_t replayFrameEnd;
EGLint replayDrawSurfaceWidth;
......
......@@ -34,17 +34,13 @@ constexpr char kResultTag[] = "*RESULT";
class CaptureReplayTests
{
public:
CaptureReplayTests(EGLint glesMajorVersion, EGLint glesMinorVersion)
: mOSWindow(nullptr), mEGLWindow(nullptr)
CaptureReplayTests()
{
mPlatformParams.renderer = EGL_PLATFORM_ANGLE_TYPE_VULKAN_ANGLE;
mPlatformParams.deviceType = EGL_PLATFORM_ANGLE_DEVICE_TYPE_HARDWARE_ANGLE;
// Load EGL library so we can initialize the display.
mEntryPointsLib.reset(
angle::OpenSharedLibrary(ANGLE_EGL_LIBRARY_NAME, angle::SearchType::ApplicationDir));
mEGLWindow = EGLWindow::New(glesMajorVersion, glesMinorVersion);
mOSWindow = OSWindow::New();
mOSWindow = OSWindow::New();
mOSWindow->disableErrorMessageDialog();
}
......@@ -54,16 +50,23 @@ class CaptureReplayTests
OSWindow::Delete(&mOSWindow);
}
bool initializeTest(uint32_t testIndex, TestTraceInfo &testTraceInfo)
bool initializeTest(uint32_t testIndex, const TestTraceInfo &testTraceInfo)
{
if (!mOSWindow->initialize(testTraceInfo.testName, testTraceInfo.replayDrawSurfaceWidth,
testTraceInfo.replayDrawSurfaceHeight))
{
return false;
}
mOSWindow->disableErrorMessageDialog();
mOSWindow->setVisible(true);
if (!mEGLWindow)
{
mEGLWindow = EGLWindow::New(testTraceInfo.replayContextMajorVersion,
testTraceInfo.replayContextMinorVersion);
}
ConfigParameters configParams;
configParams.redBits = testTraceInfo.defaultFramebufferRedBits;
configParams.greenBits = testTraceInfo.defaultFramebufferGreenBits;
......@@ -71,6 +74,10 @@ class CaptureReplayTests
configParams.alphaBits = testTraceInfo.defaultFramebufferAlphaBits;
configParams.depthBits = testTraceInfo.defaultFramebufferDepthBits;
configParams.stencilBits = testTraceInfo.defaultFramebufferStencilBits;
mPlatformParams.renderer = testTraceInfo.replayPlatformType;
mPlatformParams.deviceType = testTraceInfo.replayDeviceType;
if (!mEGLWindow->initializeGL(mOSWindow, mEntryPointsLib.get(),
angle::GLESDriverType::AngleEGL, mPlatformParams,
configParams))
......@@ -109,7 +116,7 @@ class CaptureReplayTests
void swap() { mEGLWindow->swap(); }
int runTest(uint32_t testIndex, TestTraceInfo &testTraceInfo)
int runTest(uint32_t testIndex, const TestTraceInfo &testTraceInfo)
{
if (!initializeTest(testIndex, testTraceInfo))
{
......@@ -160,8 +167,8 @@ class CaptureReplayTests
replaySerializedContextState.size()) == 0;
}
OSWindow *mOSWindow;
EGLWindow *mEGLWindow;
OSWindow *mOSWindow = nullptr;
EGLWindow *mEGLWindow = nullptr;
EGLPlatformParameters mPlatformParams;
// Handle to the entry point binding library.
std::unique_ptr<angle::Library> mEntryPointsLib;
......@@ -169,9 +176,6 @@ class CaptureReplayTests
int main(int argc, char **argv)
{
// TODO (nguyenmh): http://anglebug.com/4759: initialize app with arguments taken from cmdline
const EGLint glesMajorVersion = 2;
const GLint glesMinorVersion = 0;
CaptureReplayTests app(glesMajorVersion, glesMinorVersion);
CaptureReplayTests app;
return app.run();
}
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