Commit ffb31229 by Mohan Maiya Committed by Commit Bot

Capture/Replay: Enable capturing slingshot scenes

Implemented parameter capture functions for: glGetActiveUniformsiv glGetActiveUniformBlockName glGetActiveUniformBlockiv Added a check for bound unused locations when capturing glLinkProgram Changed CaptureGetParameter to always request a gReadBuffer allocation of the maximum reported possible array size needed to query GL_COMPRESSED_TEXTURE_FORMATS. Recording the value on the capturing device would previously have buffer overflow issues when the replaying the capture on a device with more formats available. Changed VertexAttribType::UnsignedInt2101010's string to reflect the correct type Bug: angleproject:4834 Change-Id: Icd1ff404369ae9f18cad7cd4f56fbcccc89e7e98 Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2306735Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org> Commit-Queue: Mohan Maiya <m.maiya@samsung.com>
parent a4535c18
...@@ -396,7 +396,7 @@ std::ostream &operator<<(std::ostream &os, VertexAttribType value) ...@@ -396,7 +396,7 @@ std::ostream &operator<<(std::ostream &os, VertexAttribType value)
os << "GL_UNSIGNED_INT"; os << "GL_UNSIGNED_INT";
break; break;
case VertexAttribType::UnsignedInt2101010: case VertexAttribType::UnsignedInt2101010:
os << "GL_UNSIGNED_INT_10_10_10_2"; os << "GL_UNSIGNED_INT_2_10_10_10_REV";
break; break;
case VertexAttribType::UnsignedInt1010102: case VertexAttribType::UnsignedInt1010102:
os << "GL_UNSIGNED_INT_10_10_10_2_OES"; os << "GL_UNSIGNED_INT_10_10_10_2_OES";
......
...@@ -1371,30 +1371,43 @@ void CaptureUpdateUniformLocations(const gl::Program *program, std::vector<CallC ...@@ -1371,30 +1371,43 @@ void CaptureUpdateUniformLocations(const gl::Program *program, std::vector<CallC
for (GLint location = 0; location < static_cast<GLint>(locations.size()); ++location) for (GLint location = 0; location < static_cast<GLint>(locations.size()); ++location)
{ {
const gl::VariableLocation &locationVar = locations[location]; const gl::VariableLocation &locationVar = locations[location];
const gl::LinkedUniform &uniform = uniforms[locationVar.index];
// This handles the case where the application calls glBindUniformLocationCHROMIUM
// on an unused uniform. We must still store a -1 into gUniformLocations in case the
// application attempts to call a glUniform* call. To do this we'll pass in a blank name to
// force glGetUniformLocation to return -1.
std::string name;
ParamBuffer params; ParamBuffer params;
params.addValueParam("program", ParamType::TShaderProgramID, program->id()); params.addValueParam("program", ParamType::TShaderProgramID, program->id());
std::string name = uniform.name; if (locationVar.index >= uniforms.size())
if (uniform.isArray())
{ {
if (locationVar.arrayIndex > 0) name = "";
{ }
// Non-sequential array uniform locations are not currently handled. else
// In practice array locations shouldn't ever be non-sequential. {
ASSERT(uniform.location == -1 || const gl::LinkedUniform &uniform = uniforms[locationVar.index];
location == uniform.location + static_cast<int>(locationVar.arrayIndex));
continue;
}
if (uniform.isArrayOfArrays()) name = uniform.name;
if (uniform.isArray())
{ {
UNIMPLEMENTED(); if (locationVar.arrayIndex > 0)
} {
// Non-sequential array uniform locations are not currently handled.
// In practice array locations shouldn't ever be non-sequential.
ASSERT(uniform.location == -1 ||
location == uniform.location + static_cast<int>(locationVar.arrayIndex));
continue;
}
if (uniform.isArrayOfArrays())
{
UNIMPLEMENTED();
}
name = gl::StripLastArrayIndex(name); name = gl::StripLastArrayIndex(name);
}
} }
ParamCapture nameParam("name", ParamType::TGLcharConstPointer); ParamCapture nameParam("name", ParamType::TGLcharConstPointer);
...@@ -4223,19 +4236,43 @@ gl::Program *GetProgramForCapture(const gl::State &glState, gl::ShaderProgramID ...@@ -4223,19 +4236,43 @@ gl::Program *GetProgramForCapture(const gl::State &glState, gl::ShaderProgramID
return program; return program;
} }
void CaptureGetActiveUniformBlockivParameters(const gl::State &glState,
gl::ShaderProgramID handle,
GLuint uniformBlockIndex,
GLenum pname,
ParamCapture *paramCapture)
{
int numParams = 1;
// From the OpenGL ES 3.0 spec:
// If pname is UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES, then a list of the
// active uniform indices for the uniform block identified by uniformBlockIndex is
// returned. The number of elements that will be written to params is the value of
// UNIFORM_BLOCK_ACTIVE_UNIFORMS for uniformBlockIndex
if (pname == GL_UNIFORM_BLOCK_ACTIVE_UNIFORM_INDICES)
{
gl::Program *program = GetProgramForCapture(glState, handle);
if (program)
{
gl::QueryActiveUniformBlockiv(program, uniformBlockIndex,
GL_UNIFORM_BLOCK_ACTIVE_UNIFORMS, &numParams);
}
}
paramCapture->readBufferSizeBytes = sizeof(GLint) * numParams;
}
void CaptureGetParameter(const gl::State &glState, void CaptureGetParameter(const gl::State &glState,
GLenum pname, GLenum pname,
size_t typeSize, size_t typeSize,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
GLenum nativeType; // kMaxReportedCapabilities is the biggest array we'll need to hold data from glGet calls.
unsigned int numParams; // This value needs to be updated if any new extensions are introduced that would allow for
if (!gl::GetQueryParameterInfo(glState, pname, &nativeType, &numParams)) // more compressed texture formats. The current value is taken from:
{ // http://opengles.gpuinfo.org/displaycapability.php?name=GL_NUM_COMPRESSED_TEXTURE_FORMATS&esversion=2
numParams = 1; constexpr unsigned int kMaxReportedCapabilities = 69;
} paramCapture->readBufferSizeBytes = typeSize * kMaxReportedCapabilities;
paramCapture->readBufferSizeBytes = typeSize * numParams;
} }
void CaptureGenHandlesImpl(GLsizei n, GLuint *handles, ParamCapture *paramCapture) void CaptureGenHandlesImpl(GLsizei n, GLuint *handles, ParamCapture *paramCapture)
......
...@@ -389,6 +389,12 @@ void CaptureGetParameter(const gl::State &glState, ...@@ -389,6 +389,12 @@ void CaptureGetParameter(const gl::State &glState,
size_t typeSize, size_t typeSize,
ParamCapture *paramCapture); ParamCapture *paramCapture);
void CaptureGetActiveUniformBlockivParameters(const gl::State &glState,
gl::ShaderProgramID handle,
GLuint uniformBlockIndex,
GLenum pname,
ParamCapture *paramCapture);
template <typename T> template <typename T>
void CaptureClearBufferValue(GLenum buffer, const T *value, ParamCapture *paramCapture) void CaptureClearBufferValue(GLenum buffer, const T *value, ParamCapture *paramCapture)
{ {
......
...@@ -205,7 +205,13 @@ void CaptureGetActiveUniformBlockName_length(const State &glState, ...@@ -205,7 +205,13 @@ void CaptureGetActiveUniformBlockName_length(const State &glState,
GLchar *uniformBlockName, GLchar *uniformBlockName,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); // From the OpenGL ES 3.0 spec:
// The actual number of characters written into uniformBlockName, excluding the null terminator,
// is returned in length. If length is NULL, no length is returned.
if (length)
{
paramCapture->readBufferSizeBytes = sizeof(GLsizei);
}
} }
void CaptureGetActiveUniformBlockName_uniformBlockName(const State &glState, void CaptureGetActiveUniformBlockName_uniformBlockName(const State &glState,
...@@ -217,7 +223,10 @@ void CaptureGetActiveUniformBlockName_uniformBlockName(const State &glState, ...@@ -217,7 +223,10 @@ void CaptureGetActiveUniformBlockName_uniformBlockName(const State &glState,
GLchar *uniformBlockName, GLchar *uniformBlockName,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); // From the OpenGL ES 3.0 spec:
// bufSize contains the maximum number of characters (including the null terminator) that will
// be written back to uniformBlockName.
CaptureStringLimit(uniformBlockName, bufSize, paramCapture);
} }
void CaptureGetActiveUniformBlockiv_params(const State &glState, void CaptureGetActiveUniformBlockiv_params(const State &glState,
...@@ -228,7 +237,8 @@ void CaptureGetActiveUniformBlockiv_params(const State &glState, ...@@ -228,7 +237,8 @@ void CaptureGetActiveUniformBlockiv_params(const State &glState,
GLint *params, GLint *params,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); CaptureGetActiveUniformBlockivParameters(glState, program, uniformBlockIndex, pname,
paramCapture);
} }
void CaptureGetActiveUniformsiv_uniformIndices(const State &glState, void CaptureGetActiveUniformsiv_uniformIndices(const State &glState,
...@@ -240,7 +250,11 @@ void CaptureGetActiveUniformsiv_uniformIndices(const State &glState, ...@@ -240,7 +250,11 @@ void CaptureGetActiveUniformsiv_uniformIndices(const State &glState,
GLint *params, GLint *params,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); // From the OpenGL ES 3.0 spec:
// For GetActiveUniformsiv, uniformCountindicates both the number of
// elements in the array of indices uniformIndices and the number of
// parameters written to params upon successful return.
CaptureMemory(uniformIndices, sizeof(GLuint) * uniformCount, paramCapture);
} }
void CaptureGetActiveUniformsiv_params(const State &glState, void CaptureGetActiveUniformsiv_params(const State &glState,
...@@ -252,7 +266,11 @@ void CaptureGetActiveUniformsiv_params(const State &glState, ...@@ -252,7 +266,11 @@ void CaptureGetActiveUniformsiv_params(const State &glState,
GLint *params, GLint *params,
ParamCapture *paramCapture) ParamCapture *paramCapture)
{ {
UNIMPLEMENTED(); // From the OpenGL ES 3.0 spec:
// For GetActiveUniformsiv, uniformCountindicates both the number of
// elements in the array of indices uniformIndices and the number of
// parameters written to params upon successful return.
paramCapture->readBufferSizeBytes = sizeof(GLint) * uniformCount;
} }
void CaptureGetBufferParameteri64v_params(const State &glState, void CaptureGetBufferParameteri64v_params(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