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