Commit e580ca8b by Cody Northrop Committed by Commit Bot

Capture/Replay: Implement Manhattan ES 3.0 support

Populate the entrypoints required to get gfxBench Manhattan scene to capture and replay correctly from the beginning of the trace. Test: Captured and replayed Manhattan frames 0-500 on both Windows and Linux (Nvidia GPUs) Bug: angleproject:4091 Change-Id: I5447a6835e55e944772d37219f2bd414606f0a70 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2029216Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Commit-Queue: Cody Northrop <cnorthrop@google.com>
parent c73475fb
...@@ -221,12 +221,42 @@ void WriteParamStaticVarName(const CallCapture &call, ...@@ -221,12 +221,42 @@ void WriteParamStaticVarName(const CallCapture &call,
out << call.name() << "_" << param.name << "_" << counter; out << call.name() << "_" << param.name << "_" << counter;
} }
void WriteGLFloatValue(std::ostream &out, GLfloat value)
{
// Check for non-representable values
ASSERT(std::numeric_limits<float>::has_infinity);
ASSERT(std::numeric_limits<float>::has_quiet_NaN);
if (std::isinf(value))
{
float negativeInf = -std::numeric_limits<float>::infinity();
if (value == negativeInf)
{
out << "-";
}
out << "std::numeric_limits<float>::infinity()";
}
else if (std::isnan(value))
{
out << "std::numeric_limits<float>::quiet_NaN()";
}
else
{
out << value;
}
}
template <typename T, typename CastT = T> template <typename T, typename CastT = T>
void WriteInlineData(const std::vector<uint8_t> &vec, std::ostream &out) void WriteInlineData(const std::vector<uint8_t> &vec, std::ostream &out)
{ {
const T *data = reinterpret_cast<const T *>(vec.data()); const T *data = reinterpret_cast<const T *>(vec.data());
size_t count = vec.size() / sizeof(T); size_t count = vec.size() / sizeof(T);
if (data == nullptr)
{
return;
}
out << static_cast<CastT>(data[0]); out << static_cast<CastT>(data[0]);
for (size_t dataIndex = 1; dataIndex < count; ++dataIndex) for (size_t dataIndex = 1; dataIndex < count; ++dataIndex)
...@@ -235,6 +265,26 @@ void WriteInlineData(const std::vector<uint8_t> &vec, std::ostream &out) ...@@ -235,6 +265,26 @@ void WriteInlineData(const std::vector<uint8_t> &vec, std::ostream &out)
} }
} }
template <>
void WriteInlineData<GLfloat>(const std::vector<uint8_t> &vec, std::ostream &out)
{
const float *data = reinterpret_cast<const GLfloat *>(vec.data());
size_t count = vec.size() / sizeof(GLfloat);
if (data == nullptr)
{
return;
}
WriteGLFloatValue(out, data[0]);
for (size_t dataIndex = 1; dataIndex < count; ++dataIndex)
{
out << ", ";
WriteGLFloatValue(out, data[dataIndex]);
}
}
constexpr size_t kInlineDataThreshold = 128; constexpr size_t kInlineDataThreshold = 128;
void WriteStringParamReplay(std::ostream &out, const ParamCapture &param) void WriteStringParamReplay(std::ostream &out, const ParamCapture &param)
...@@ -287,7 +337,7 @@ void WriteResourceIDPointerParamReplay(DataCounters *counters, ...@@ -287,7 +337,7 @@ void WriteResourceIDPointerParamReplay(DataCounters *counters,
ASSERT(resourceIDType != ResourceIDType::InvalidEnum); ASSERT(resourceIDType != ResourceIDType::InvalidEnum);
const char *name = GetResourceIDTypeName(resourceIDType); const char *name = GetResourceIDTypeName(resourceIDType);
GLsizei n = call.params.getParam("n", ParamType::TGLsizei, 0).value.GLsizeiVal; GLsizei n = call.params.getParamFlexName("n", "count", ParamType::TGLsizei, 0).value.GLsizeiVal;
ASSERT(param.data.size() == 1); ASSERT(param.data.size() == 1);
const ParamT *returnedIDs = reinterpret_cast<const ParamT *>(param.data[0].data()); const ParamT *returnedIDs = reinterpret_cast<const ParamT *>(param.data[0].data());
for (GLsizei resIndex = 0; resIndex < n; ++resIndex) for (GLsizei resIndex = 0; resIndex < n; ++resIndex)
...@@ -419,6 +469,10 @@ void WriteCppReplayForCall(const CallCapture &call, ...@@ -419,6 +469,10 @@ void WriteCppReplayForCall(const CallCapture &call,
{ {
OutputGLbitfieldString(callOut, param.enumGroup, param.value.GLbitfieldVal); OutputGLbitfieldString(callOut, param.enumGroup, param.value.GLbitfieldVal);
} }
else if (param.type == ParamType::TGLfloat)
{
WriteGLFloatValue(callOut, param.value.GLfloatVal);
}
else else
{ {
callOut << param; callOut << param;
...@@ -669,6 +723,7 @@ void WriteCppReplayIndexFiles(const std::string &outDir, ...@@ -669,6 +723,7 @@ void WriteCppReplayIndexFiles(const std::string &outDir,
header << "#include <cstdint>\n"; header << "#include <cstdint>\n";
header << "#include <cstdio>\n"; header << "#include <cstdio>\n";
header << "#include <cstring>\n"; header << "#include <cstring>\n";
header << "#include <limits>\n";
header << "#include <unordered_map>\n"; header << "#include <unordered_map>\n";
header << "\n"; header << "\n";
header << "// Replay functions\n"; header << "// Replay functions\n";
...@@ -779,7 +834,7 @@ void WriteCppReplayIndexFiles(const std::string &outDir, ...@@ -779,7 +834,7 @@ void WriteCppReplayIndexFiles(const std::string &outDir,
source << " char pathBuffer[1000] = {};\n"; source << " char pathBuffer[1000] = {};\n";
source << " sprintf(pathBuffer, \"%s/%s\", gBinaryDataDir, fileName);\n"; source << " sprintf(pathBuffer, \"%s/%s\", gBinaryDataDir, fileName);\n";
source << " FILE *fp = fopen(pathBuffer, \"rb\");\n"; source << " FILE *fp = fopen(pathBuffer, \"rb\");\n";
source << " fread(gBinaryData, 1, size, fp);\n"; source << " (void)fread(gBinaryData, 1, size, fp);\n";
source << " fclose(fp);\n"; source << " fclose(fp);\n";
source << "}\n"; source << "}\n";
...@@ -870,7 +925,7 @@ void CaptureUpdateResourceIDs(const CallCapture &call, ...@@ -870,7 +925,7 @@ void CaptureUpdateResourceIDs(const CallCapture &call,
const ParamCapture &param, const ParamCapture &param,
std::vector<CallCapture> *callsOut) std::vector<CallCapture> *callsOut)
{ {
GLsizei n = call.params.getParam("n", ParamType::TGLsizei, 0).value.GLsizeiVal; GLsizei n = call.params.getParamFlexName("n", "count", ParamType::TGLsizei, 0).value.GLsizeiVal;
ASSERT(param.data.size() == 1); ASSERT(param.data.size() == 1);
ResourceIDType resourceIDType = GetResourceIDTypeFromParamType(param.type); ResourceIDType resourceIDType = GetResourceIDTypeFromParamType(param.type);
ASSERT(resourceIDType != ResourceIDType::InvalidEnum); ASSERT(resourceIDType != ResourceIDType::InvalidEnum);
...@@ -992,7 +1047,7 @@ void MaybeCaptureUpdateResourceIDs(std::vector<CallCapture> *callsOut) ...@@ -992,7 +1047,7 @@ void MaybeCaptureUpdateResourceIDs(std::vector<CallCapture> *callsOut)
case gl::EntryPoint::GenVertexArraysOES: case gl::EntryPoint::GenVertexArraysOES:
{ {
const ParamCapture &vertexArrays = const ParamCapture &vertexArrays =
call.params.getParam("vetexArraysPacked", ParamType::TVertexArrayIDPointer, 1); call.params.getParam("arraysPacked", ParamType::TVertexArrayIDPointer, 1);
CaptureUpdateResourceIDs<gl::VertexArrayID>(call, vertexArrays, callsOut); CaptureUpdateResourceIDs<gl::VertexArrayID>(call, vertexArrays, callsOut);
break; break;
} }
...@@ -1808,6 +1863,26 @@ const ParamCapture &ParamBuffer::getParam(const char *paramName, ...@@ -1808,6 +1863,26 @@ const ParamCapture &ParamBuffer::getParam(const char *paramName,
return const_cast<ParamBuffer *>(this)->getParam(paramName, paramType, index); return const_cast<ParamBuffer *>(this)->getParam(paramName, paramType, index);
} }
ParamCapture &ParamBuffer::getParamFlexName(const char *paramName1,
const char *paramName2,
ParamType paramType,
int index)
{
ParamCapture &capture = mParamCaptures[index];
ASSERT(capture.name == paramName1 || capture.name == paramName2);
ASSERT(capture.type == paramType);
return capture;
}
const ParamCapture &ParamBuffer::getParamFlexName(const char *paramName1,
const char *paramName2,
ParamType paramType,
int index) const
{
return const_cast<ParamBuffer *>(this)->getParamFlexName(paramName1, paramName2, paramType,
index);
}
void ParamBuffer::addParam(ParamCapture &&param) void ParamBuffer::addParam(ParamCapture &&param)
{ {
if (param.arrayClientPointerIndex != -1) if (param.arrayClientPointerIndex != -1)
......
...@@ -60,6 +60,14 @@ class ParamBuffer final : angle::NonCopyable ...@@ -60,6 +60,14 @@ class ParamBuffer final : angle::NonCopyable
ParamCapture &getParam(const char *paramName, ParamType paramType, int index); ParamCapture &getParam(const char *paramName, ParamType paramType, int index);
const ParamCapture &getParam(const char *paramName, ParamType paramType, int index) const; const ParamCapture &getParam(const char *paramName, ParamType paramType, int index) const;
ParamCapture &getParamFlexName(const char *paramName1,
const char *paramName2,
ParamType paramType,
int index);
const ParamCapture &getParamFlexName(const char *paramName1,
const char *paramName2,
ParamType paramType,
int index) const;
const ParamCapture &getReturnValue() const { return mReturnValueCapture; } const ParamCapture &getReturnValue() const { return mReturnValueCapture; }
void addParam(ParamCapture &&param); void addParam(ParamCapture &&param);
......
...@@ -91,7 +91,8 @@ void CaptureCompressedTexSubImage2D_data(const State &glState, ...@@ -91,7 +91,8 @@ void CaptureCompressedTexSubImage2D_data(const State &glState,
const void *data, const void *data,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureCompressedTexImage2D_data(glState, isCallValid, targetPacked, level, 0, width, height, 0,
imageSize, data, paramCapture);
} }
void CaptureDeleteBuffers_buffersPacked(const State &glState, void CaptureDeleteBuffers_buffersPacked(const State &glState,
...@@ -735,7 +736,8 @@ void CaptureTexSubImage2D_pixels(const State &glState, ...@@ -735,7 +736,8 @@ void CaptureTexSubImage2D_pixels(const State &glState,
const void *pixels, const void *pixels,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureTexImage2D_pixels(glState, isCallValid, targetPacked, level, 0, width, height, 0, format,
type, pixels, paramCapture);
} }
void CaptureUniform1fv_value(const State &glState, void CaptureUniform1fv_value(const State &glState,
......
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
// capture_gles3_params.cpp: // capture_gles3_params.cpp:
// Pointer parameter capture functions for the OpenGL ES 3.0 entry points. // Pointer parameter capture functions for the OpenGL ES 3.0 entry points.
#include "libANGLE/capture_gles_2_0_autogen.h"
#include "libANGLE/capture_gles_3_0_autogen.h" #include "libANGLE/capture_gles_3_0_autogen.h"
using namespace angle; using namespace angle;
...@@ -55,7 +56,17 @@ void CaptureCompressedTexImage3D_data(const State &glState, ...@@ -55,7 +56,17 @@ void CaptureCompressedTexImage3D_data(const State &glState,
const void *data, const void *data,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); if (glState.getTargetBuffer(gl::BufferBinding::PixelUnpack))
{
return;
}
if (!data)
{
return;
}
CaptureMemory(data, imageSize, paramCapture);
} }
void CaptureCompressedTexSubImage3D_data(const State &glState, void CaptureCompressedTexSubImage3D_data(const State &glState,
...@@ -73,7 +84,8 @@ void CaptureCompressedTexSubImage3D_data(const State &glState, ...@@ -73,7 +84,8 @@ void CaptureCompressedTexSubImage3D_data(const State &glState,
const void *data, const void *data,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureCompressedTexImage3D_data(glState, isCallValid, targetPacked, level, 0, width, height,
depth, 0, imageSize, data, paramCapture);
} }
void CaptureDeleteQueries_idsPacked(const State &glState, void CaptureDeleteQueries_idsPacked(const State &glState,
...@@ -118,7 +130,7 @@ void CaptureDrawBuffers_bufs(const State &glState, ...@@ -118,7 +130,7 @@ void CaptureDrawBuffers_bufs(const State &glState,
const GLenum *bufs, const GLenum *bufs,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureMemory(bufs, sizeof(GLenum) * n, paramCapture);
} }
void CaptureDrawElementsInstanced_indices(const State &glState, void CaptureDrawElementsInstanced_indices(const State &glState,
...@@ -130,7 +142,8 @@ void CaptureDrawElementsInstanced_indices(const State &glState, ...@@ -130,7 +142,8 @@ void CaptureDrawElementsInstanced_indices(const State &glState,
GLsizei instancecount, GLsizei instancecount,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureDrawElements_indices(glState, isCallValid, modePacked, count, typePacked, indices,
paramCapture);
} }
void CaptureDrawRangeElements_indices(const State &glState, void CaptureDrawRangeElements_indices(const State &glState,
...@@ -354,7 +367,8 @@ void CaptureGetQueryObjectuiv_params(const State &glState, ...@@ -354,7 +367,8 @@ void CaptureGetQueryObjectuiv_params(const State &glState,
GLuint *params, GLuint *params,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); // This only returns one value
paramCapture->readBufferSizeBytes = sizeof(GLint);
} }
void CaptureGetQueryiv_params(const State &glState, void CaptureGetQueryiv_params(const State &glState,
...@@ -473,7 +487,7 @@ void CaptureGetUniformBlockIndex_uniformBlockName(const State &glState, ...@@ -473,7 +487,7 @@ void CaptureGetUniformBlockIndex_uniformBlockName(const State &glState,
const GLchar *uniformBlockName, const GLchar *uniformBlockName,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureString(uniformBlockName, paramCapture);
} }
void CaptureGetUniformIndices_uniformNames(const State &glState, void CaptureGetUniformIndices_uniformNames(const State &glState,
...@@ -597,7 +611,27 @@ void CaptureTexImage3D_pixels(const State &glState, ...@@ -597,7 +611,27 @@ void CaptureTexImage3D_pixels(const State &glState,
const void *pixels, const void *pixels,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); if (glState.getTargetBuffer(gl::BufferBinding::PixelUnpack))
{
return;
}
if (!pixels)
{
return;
}
const gl::InternalFormat &internalFormatInfo = gl::GetInternalFormatInfo(format, type);
const gl::PixelUnpackState &unpack = glState.getUnpackState();
const Extents size(width, height, depth);
GLuint endByte = 0;
bool unpackSize =
internalFormatInfo.computePackUnpackEndByte(type, size, unpack, true, &endByte);
ASSERT(unpackSize);
CaptureMemory(pixels, static_cast<size_t>(endByte), paramCapture);
} }
void CaptureTexSubImage3D_pixels(const State &glState, void CaptureTexSubImage3D_pixels(const State &glState,
...@@ -615,7 +649,8 @@ void CaptureTexSubImage3D_pixels(const State &glState, ...@@ -615,7 +649,8 @@ void CaptureTexSubImage3D_pixels(const State &glState,
const void *pixels, const void *pixels,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureTexImage3D_pixels(glState, isCallValid, targetPacked, level, 0, width, height, depth, 0,
format, type, pixels, paramCapture);
} }
void CaptureTransformFeedbackVaryings_varyings(const State &glState, void CaptureTransformFeedbackVaryings_varyings(const State &glState,
...@@ -626,7 +661,10 @@ void CaptureTransformFeedbackVaryings_varyings(const State &glState, ...@@ -626,7 +661,10 @@ void CaptureTransformFeedbackVaryings_varyings(const State &glState,
GLenum bufferMode, GLenum bufferMode,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); for (GLsizei index = 0; index < count; ++index)
{
CaptureString(varyings[index], paramCapture);
}
} }
void CaptureUniform1uiv_value(const State &glState, void CaptureUniform1uiv_value(const State &glState,
......
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