Commit f2bee304 by Cody Northrop Committed by Commit Bot

Capture/Replay: Implement more GLES entrypoints

Tested with several apps that can't be captured otherwise. Bug: angleproject:3611 Change-Id: I2ad18c3bfcab48b0b385b2a868f57369c292b602 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/1998838Reviewed-by: 's avatarCourtney Goeltzenleuchter <courtneygo@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Cody Northrop <cnorthrop@google.com>
parent d8c1b03c
...@@ -299,6 +299,30 @@ void WriteInlineData<GLfloat>(const std::vector<uint8_t> &vec, std::ostream &out ...@@ -299,6 +299,30 @@ void WriteInlineData<GLfloat>(const std::vector<uint8_t> &vec, std::ostream &out
} }
} }
template <>
void WriteInlineData<GLchar>(const std::vector<uint8_t> &vec, std::ostream &out)
{
const GLchar *data = reinterpret_cast<const GLchar *>(vec.data());
size_t count = vec.size() / sizeof(GLchar);
if (data == nullptr || data[0] == '\0')
{
return;
}
out << "\"";
for (size_t dataIndex = 0; dataIndex < count; ++dataIndex)
{
if (data[dataIndex] == '\0')
break;
out << static_cast<GLchar>(data[dataIndex]);
}
out << "\"";
}
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)
...@@ -429,7 +453,12 @@ void WriteBinaryParamReplay(DataCounters *counters, ...@@ -429,7 +453,12 @@ void WriteBinaryParamReplay(DataCounters *counters,
case ParamType::TGLenumConstPointer: case ParamType::TGLenumConstPointer:
WriteInlineData<GLuint>(data, header); WriteInlineData<GLuint>(data, header);
break; break;
case ParamType::TGLcharPointer:
WriteInlineData<GLchar>(data, header);
break;
default: default:
INFO() << "Unhandled ParamType: " << angle::ParamTypeToString(overrideType)
<< " in " << call.name();
UNIMPLEMENTED(); UNIMPLEMENTED();
break; break;
} }
...@@ -3290,6 +3319,24 @@ void CaptureString(const GLchar *str, ParamCapture *paramCapture) ...@@ -3290,6 +3319,24 @@ void CaptureString(const GLchar *str, ParamCapture *paramCapture)
CaptureMemory(str, strlen(str) + 1, paramCapture); CaptureMemory(str, strlen(str) + 1, paramCapture);
} }
void CaptureStringLimit(const GLchar *str, uint32_t limit, ParamCapture *paramCapture)
{
// Write the incoming string up to limit, including null terminator
size_t length = strlen(str) + 1;
if (length > limit)
{
// If too many characters, resize the string to fit in the limit
std::string newStr = str;
newStr.resize(limit - 1);
CaptureString(newStr.c_str(), paramCapture);
}
else
{
CaptureMemory(str, length, paramCapture);
}
}
gl::Program *GetLinkedProgramForCapture(const gl::State &glState, gl::ShaderProgramID handle) gl::Program *GetLinkedProgramForCapture(const gl::State &glState, gl::ShaderProgramID handle)
{ {
gl::Program *program = glState.getShaderProgramManagerForCapture().getProgram(handle); gl::Program *program = glState.getShaderProgramManagerForCapture().getProgram(handle);
......
...@@ -283,6 +283,7 @@ std::ostream &operator<<(std::ostream &os, const ParamCapture &capture); ...@@ -283,6 +283,7 @@ std::ostream &operator<<(std::ostream &os, const ParamCapture &capture);
// Pointer capture helpers. // Pointer capture helpers.
void CaptureMemory(const void *source, size_t size, ParamCapture *paramCapture); void CaptureMemory(const void *source, size_t size, ParamCapture *paramCapture);
void CaptureString(const GLchar *str, ParamCapture *paramCapture); void CaptureString(const GLchar *str, ParamCapture *paramCapture);
void CaptureStringLimit(const GLchar *str, uint32_t limit, ParamCapture *paramCapture);
gl::Program *GetLinkedProgramForCapture(const gl::State &glState, gl::ShaderProgramID handle); gl::Program *GetLinkedProgramForCapture(const gl::State &glState, gl::ShaderProgramID handle);
......
...@@ -240,7 +240,7 @@ void CaptureGetActiveAttrib_name(const State &glState, ...@@ -240,7 +240,7 @@ void CaptureGetActiveAttrib_name(const State &glState,
GLchar *name, GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureStringLimit(name, bufSize, paramCapture);
} }
void CaptureGetActiveUniform_length(const State &glState, void CaptureGetActiveUniform_length(const State &glState,
...@@ -254,7 +254,7 @@ void CaptureGetActiveUniform_length(const State &glState, ...@@ -254,7 +254,7 @@ void CaptureGetActiveUniform_length(const State &glState,
GLchar *name, GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); paramCapture->readBufferSizeBytes = sizeof(GLsizei);
} }
void CaptureGetActiveUniform_size(const State &glState, void CaptureGetActiveUniform_size(const State &glState,
...@@ -268,7 +268,7 @@ void CaptureGetActiveUniform_size(const State &glState, ...@@ -268,7 +268,7 @@ void CaptureGetActiveUniform_size(const State &glState,
GLchar *name, GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); paramCapture->readBufferSizeBytes = sizeof(GLint);
} }
void CaptureGetActiveUniform_type(const State &glState, void CaptureGetActiveUniform_type(const State &glState,
...@@ -282,7 +282,7 @@ void CaptureGetActiveUniform_type(const State &glState, ...@@ -282,7 +282,7 @@ void CaptureGetActiveUniform_type(const State &glState,
GLchar *name, GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); paramCapture->readBufferSizeBytes = sizeof(GLenum);
} }
void CaptureGetActiveUniform_name(const State &glState, void CaptureGetActiveUniform_name(const State &glState,
...@@ -296,7 +296,7 @@ void CaptureGetActiveUniform_name(const State &glState, ...@@ -296,7 +296,7 @@ void CaptureGetActiveUniform_name(const State &glState,
GLchar *name, GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureStringLimit(name, bufSize, paramCapture);
} }
void CaptureGetAttachedShaders_count(const State &glState, void CaptureGetAttachedShaders_count(const State &glState,
...@@ -458,7 +458,8 @@ void CaptureGetShaderPrecisionFormat_range(const State &glState, ...@@ -458,7 +458,8 @@ void CaptureGetShaderPrecisionFormat_range(const State &glState,
GLint *precision, GLint *precision,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); // range specifies a pointer to two-element array containing log2 of min and max
paramCapture->readBufferSizeBytes = 2 * sizeof(GLint);
} }
void CaptureGetShaderPrecisionFormat_precision(const State &glState, void CaptureGetShaderPrecisionFormat_precision(const State &glState,
...@@ -469,7 +470,7 @@ void CaptureGetShaderPrecisionFormat_precision(const State &glState, ...@@ -469,7 +470,7 @@ void CaptureGetShaderPrecisionFormat_precision(const State &glState,
GLint *precision, GLint *precision,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); paramCapture->readBufferSizeBytes = sizeof(GLint);
} }
void CaptureGetShaderSource_length(const State &glState, void CaptureGetShaderSource_length(const State &glState,
...@@ -859,7 +860,7 @@ void CaptureVertexAttrib1fv_v(const State &glState, ...@@ -859,7 +860,7 @@ void CaptureVertexAttrib1fv_v(const State &glState,
const GLfloat *v, const GLfloat *v,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureMemory(v, sizeof(GLfloat), paramCapture);
} }
void CaptureVertexAttrib2fv_v(const State &glState, void CaptureVertexAttrib2fv_v(const State &glState,
...@@ -868,7 +869,7 @@ void CaptureVertexAttrib2fv_v(const State &glState, ...@@ -868,7 +869,7 @@ void CaptureVertexAttrib2fv_v(const State &glState,
const GLfloat *v, const GLfloat *v,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureMemory(v, sizeof(GLfloat) * 2, paramCapture);
} }
void CaptureVertexAttrib3fv_v(const State &glState, void CaptureVertexAttrib3fv_v(const State &glState,
...@@ -877,7 +878,7 @@ void CaptureVertexAttrib3fv_v(const State &glState, ...@@ -877,7 +878,7 @@ void CaptureVertexAttrib3fv_v(const State &glState,
const GLfloat *v, const GLfloat *v,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureMemory(v, sizeof(GLfloat) * 3, paramCapture);
} }
void CaptureVertexAttrib4fv_v(const State &glState, void CaptureVertexAttrib4fv_v(const State &glState,
...@@ -886,7 +887,7 @@ void CaptureVertexAttrib4fv_v(const State &glState, ...@@ -886,7 +887,7 @@ void CaptureVertexAttrib4fv_v(const State &glState,
const GLfloat *v, const GLfloat *v,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureMemory(v, sizeof(GLfloat) * 4, paramCapture);
} }
void CaptureVertexAttribPointer_pointer(const State &glState, void CaptureVertexAttribPointer_pointer(const State &glState,
......
...@@ -156,7 +156,8 @@ void CaptureDrawRangeElements_indices(const State &glState, ...@@ -156,7 +156,8 @@ void CaptureDrawRangeElements_indices(const State &glState,
const void *indices, const void *indices,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureDrawElements_indices(glState, isCallValid, modePacked, count, typePacked, indices,
paramCapture);
} }
void CaptureGenQueries_idsPacked(const State &glState, void CaptureGenQueries_idsPacked(const State &glState,
...@@ -321,7 +322,33 @@ void CaptureGetInternalformativ_params(const State &glState, ...@@ -321,7 +322,33 @@ void CaptureGetInternalformativ_params(const State &glState,
GLint *params, GLint *params,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); // From the OpenGL ES 3.0 spec:
//
// The information retrieved will be written to memory addressed by the pointer specified in
// params.
//
// No more than bufSize integers will be written to this memory.
//
// If pname is GL_NUM_SAMPLE_COUNTS, the number of sample counts that would be returned by
// querying GL_SAMPLES will be returned in params.
//
// If pname is GL_SAMPLES, the sample counts supported for internalformat and target are written
// into params in descending numeric order. Only positive values are returned.
//
// Querying GL_SAMPLES with bufSize of one will return just the maximum supported number of
// samples for this format.
if (bufSize == 0)
return;
if (params)
{
// For GL_NUM_SAMPLE_COUNTS, only one value is returned
// For GL_SAMPLES, two values will be returned, unless bufSize limits it to one
uint32_t paramCount = (pname == GL_SAMPLES && bufSize > 1) ? 2 : 1;
paramCapture->readBufferSizeBytes = sizeof(GLint) * paramCount;
}
} }
void CaptureGetProgramBinary_length(const State &glState, void CaptureGetProgramBinary_length(const State &glState,
...@@ -333,7 +360,10 @@ void CaptureGetProgramBinary_length(const State &glState, ...@@ -333,7 +360,10 @@ void CaptureGetProgramBinary_length(const State &glState,
void *binary, void *binary,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); if (length)
{
paramCapture->readBufferSizeBytes = sizeof(GLsizei);
}
} }
void CaptureGetProgramBinary_binaryFormat(const State &glState, void CaptureGetProgramBinary_binaryFormat(const State &glState,
...@@ -345,7 +375,7 @@ void CaptureGetProgramBinary_binaryFormat(const State &glState, ...@@ -345,7 +375,7 @@ void CaptureGetProgramBinary_binaryFormat(const State &glState,
void *binary, void *binary,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); paramCapture->readBufferSizeBytes = sizeof(GLenum);
} }
void CaptureGetProgramBinary_binary(const State &glState, void CaptureGetProgramBinary_binary(const State &glState,
...@@ -357,7 +387,22 @@ void CaptureGetProgramBinary_binary(const State &glState, ...@@ -357,7 +387,22 @@ void CaptureGetProgramBinary_binary(const State &glState,
void *binary, void *binary,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); // If we have length, then actual binarySize was written there
// Otherwise, we don't know how many bytes were written
if (!length)
{
UNIMPLEMENTED();
return;
}
GLsizei binarySize = *length;
if (binarySize > bufSize)
{
// This is a GL error, but clamp it anyway
binarySize = bufSize;
}
paramCapture->readBufferSizeBytes = binarySize;
} }
void CaptureGetQueryObjectuiv_params(const State &glState, void CaptureGetQueryObjectuiv_params(const State &glState,
......
...@@ -418,7 +418,7 @@ void CaptureRequestExtensionANGLE_name(const State &glState, ...@@ -418,7 +418,7 @@ void CaptureRequestExtensionANGLE_name(const State &glState,
const GLchar *name, const GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureString(name, paramCapture);
} }
void CaptureDisableExtensionANGLE_name(const State &glState, void CaptureDisableExtensionANGLE_name(const State &glState,
...@@ -426,7 +426,7 @@ void CaptureDisableExtensionANGLE_name(const State &glState, ...@@ -426,7 +426,7 @@ void CaptureDisableExtensionANGLE_name(const State &glState,
const GLchar *name, const GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureString(name, paramCapture);
} }
void CaptureGetBooleanvRobustANGLE_length(const State &glState, void CaptureGetBooleanvRobustANGLE_length(const State &glState,
...@@ -1968,7 +1968,7 @@ void CaptureBindUniformLocationCHROMIUM_name(const State &glState, ...@@ -1968,7 +1968,7 @@ void CaptureBindUniformLocationCHROMIUM_name(const State &glState,
const GLchar *name, const GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureString(name, paramCapture);
} }
void CaptureMatrixLoadfCHROMIUM_matrix(const State &glState, void CaptureMatrixLoadfCHROMIUM_matrix(const State &glState,
...@@ -2215,7 +2215,7 @@ void CaptureBindFragmentInputLocationCHROMIUM_name(const State &glState, ...@@ -2215,7 +2215,7 @@ void CaptureBindFragmentInputLocationCHROMIUM_name(const State &glState,
const GLchar *name, const GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureString(name, paramCapture);
} }
void CaptureProgramPathFragmentInputGenCHROMIUM_coeffs(const State &glState, void CaptureProgramPathFragmentInputGenCHROMIUM_coeffs(const State &glState,
...@@ -2237,7 +2237,7 @@ void CaptureBindFragDataLocationEXT_name(const State &glState, ...@@ -2237,7 +2237,7 @@ void CaptureBindFragDataLocationEXT_name(const State &glState,
const GLchar *name, const GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureString(name, paramCapture);
} }
void CaptureBindFragDataLocationIndexedEXT_name(const State &glState, void CaptureBindFragDataLocationIndexedEXT_name(const State &glState,
...@@ -2248,7 +2248,7 @@ void CaptureBindFragDataLocationIndexedEXT_name(const State &glState, ...@@ -2248,7 +2248,7 @@ void CaptureBindFragDataLocationIndexedEXT_name(const State &glState,
const GLchar *name, const GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureString(name, paramCapture);
} }
void CaptureGetFragDataIndexEXT_name(const State &glState, void CaptureGetFragDataIndexEXT_name(const State &glState,
...@@ -2257,7 +2257,7 @@ void CaptureGetFragDataIndexEXT_name(const State &glState, ...@@ -2257,7 +2257,7 @@ void CaptureGetFragDataIndexEXT_name(const State &glState,
const GLchar *name, const GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureString(name, paramCapture);
} }
void CaptureGetProgramResourceLocationIndexEXT_name(const State &glState, void CaptureGetProgramResourceLocationIndexEXT_name(const State &glState,
...@@ -2267,7 +2267,7 @@ void CaptureGetProgramResourceLocationIndexEXT_name(const State &glState, ...@@ -2267,7 +2267,7 @@ void CaptureGetProgramResourceLocationIndexEXT_name(const State &glState,
const GLchar *name, const GLchar *name,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureString(name, paramCapture);
} }
void CaptureInsertEventMarkerEXT_marker(const State &glState, void CaptureInsertEventMarkerEXT_marker(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