Commit 5006a573 by Tim Van Patten Committed by Commit Bot

Capture/Replay: Capture glUniformBlockBinding()

eFootball PES 2021 uses glBindBufferRange(), which requires glUniformBlockBinding() to create the pairing of uniform block indexes to buffer bindings. The uniform buffer indexes that are assigned when each program is linked can differ between drivers, so the glUniformBlockBinding() calls need to be recorded to get the correct index values for the glBindBufferRange() calls. Bug: angleproject:5564 Change-Id: I909e05d5b1cc50e592b887bd130aa80cdb1bb40f Reviewed-on: https://chromium-review.googlesource.com/c/angle/angle/+/2650993 Commit-Queue: Tim Van Patten <timvp@google.com> Reviewed-by: 's avatarCody Northrop <cnorthrop@google.com> Reviewed-by: 's avatarJamie Madill <jmadill@chromium.org>
parent 351e6e8c
...@@ -1236,9 +1236,13 @@ void WriteCppReplayIndexFiles(bool compression, ...@@ -1236,9 +1236,13 @@ void WriteCppReplayIndexFiles(bool compression,
header header
<< "using LocationsMap = std::unordered_map<GLuint, std::unordered_map<GLint, GLint>>;\n"; << "using LocationsMap = std::unordered_map<GLuint, std::unordered_map<GLint, GLint>>;\n";
header << "extern LocationsMap gUniformLocations;\n"; header << "extern LocationsMap gUniformLocations;\n";
header << "using BlockIndexesMap = std::unordered_map<GLuint, std::unordered_map<GLuint, "
"GLuint>>;\n";
header << "extern BlockIndexesMap gUniformBlockIndexes;\n";
header << "extern GLuint gCurrentProgram;\n"; header << "extern GLuint gCurrentProgram;\n";
header << "void UpdateUniformLocation(GLuint program, const char *name, GLint location);\n"; header << "void UpdateUniformLocation(GLuint program, const char *name, GLint location);\n";
header << "void DeleteUniformLocations(GLuint program);\n"; header << "void DeleteUniformLocations(GLuint program);\n";
header << "void UpdateUniformBlockIndex(GLuint program, const char *name, GLuint index);\n";
header << "void UpdateCurrentProgram(GLuint program);\n"; header << "void UpdateCurrentProgram(GLuint program);\n";
header << "\n"; header << "\n";
header << "// Maps from captured Resource ID to run-time Resource ID.\n"; header << "// Maps from captured Resource ID to run-time Resource ID.\n";
...@@ -1292,6 +1296,7 @@ void WriteCppReplayIndexFiles(bool compression, ...@@ -1292,6 +1296,7 @@ void WriteCppReplayIndexFiles(bool compression,
source << "} // namespace\n"; source << "} // namespace\n";
source << "\n"; source << "\n";
source << "LocationsMap gUniformLocations;\n"; source << "LocationsMap gUniformLocations;\n";
source << "BlockIndexesMap gUniformBlockIndexes;\n";
source << "GLuint gCurrentProgram = 0;\n"; source << "GLuint gCurrentProgram = 0;\n";
source << "\n"; source << "\n";
source << "void UpdateUniformLocation(GLuint program, const char *name, GLint location)\n"; source << "void UpdateUniformLocation(GLuint program, const char *name, GLint location)\n";
...@@ -1302,6 +1307,10 @@ void WriteCppReplayIndexFiles(bool compression, ...@@ -1302,6 +1307,10 @@ void WriteCppReplayIndexFiles(bool compression,
source << "{\n"; source << "{\n";
source << " gUniformLocations.erase(program);\n"; source << " gUniformLocations.erase(program);\n";
source << "}\n"; source << "}\n";
source << "void UpdateUniformBlockIndex(GLuint program, const char *name, GLuint index)\n";
source << "{\n";
source << " gUniformBlockIndexes[program][index] = glGetUniformBlockIndex(program, name);\n";
source << "}\n";
source << "void UpdateCurrentProgram(GLuint program)\n"; source << "void UpdateCurrentProgram(GLuint program)\n";
source << "{\n"; source << "{\n";
source << " gCurrentProgram = program;\n"; source << " gCurrentProgram = program;\n";
...@@ -1611,6 +1620,27 @@ void CaptureUpdateUniformLocations(const gl::Program *program, std::vector<CallC ...@@ -1611,6 +1620,27 @@ void CaptureUpdateUniformLocations(const gl::Program *program, std::vector<CallC
} }
} }
void CaptureUpdateUniformBlockIndexes(const gl::Program *program,
std::vector<CallCapture> *callsOut)
{
const std::vector<gl::InterfaceBlock> &uniformBlocks = program->getState().getUniformBlocks();
for (GLuint index = 0; index < uniformBlocks.size(); ++index)
{
ParamBuffer params;
std::string name;
params.addValueParam("program", ParamType::TShaderProgramID, program->id());
ParamCapture nameParam("name", ParamType::TGLcharConstPointer);
CaptureString(uniformBlocks[index].name.c_str(), &nameParam);
params.addParam(std::move(nameParam));
params.addValueParam("index", ParamType::TGLuint, index);
callsOut->emplace_back("UpdateUniformBlockIndex", std::move(params));
}
}
void CaptureDeleteUniformLocations(gl::ShaderProgramID program, std::vector<CallCapture> *callsOut) void CaptureDeleteUniformLocations(gl::ShaderProgramID program, std::vector<CallCapture> *callsOut)
{ {
ParamBuffer params; ParamBuffer params;
...@@ -2907,6 +2937,7 @@ void CaptureMidExecutionSetup(const gl::Context *context, ...@@ -2907,6 +2937,7 @@ void CaptureMidExecutionSetup(const gl::Context *context,
cap(CaptureLinkProgram(replayState, true, id)); cap(CaptureLinkProgram(replayState, true, id));
CaptureUpdateUniformLocations(program, setupCalls); CaptureUpdateUniformLocations(program, setupCalls);
CaptureUpdateUniformValues(replayState, context, program, setupCalls); CaptureUpdateUniformValues(replayState, context, program, setupCalls);
CaptureUpdateUniformBlockIndexes(program, setupCalls);
// Capture uniform block bindings for each program // Capture uniform block bindings for each program
for (unsigned int uniformBlockIndex = 0; for (unsigned int uniformBlockIndex = 0;
...@@ -4302,6 +4333,7 @@ void FrameCapture::maybeCapturePostCallUpdates(const gl::Context *context) ...@@ -4302,6 +4333,7 @@ void FrameCapture::maybeCapturePostCallUpdates(const gl::Context *context)
const gl::Program *program = const gl::Program *program =
context->getProgramResolveLink(param.value.ShaderProgramIDVal); context->getProgramResolveLink(param.value.ShaderProgramIDVal);
CaptureUpdateUniformLocations(program, &mFrameCalls); CaptureUpdateUniformLocations(program, &mFrameCalls);
CaptureUpdateUniformBlockIndexes(program, &mFrameCalls);
break; break;
} }
case EntryPoint::GLUseProgram: case EntryPoint::GLUseProgram:
...@@ -5099,6 +5131,12 @@ void WriteParamValueReplay<ParamType::TUniformBlockIndex>(std::ostream &os, ...@@ -5099,6 +5131,12 @@ void WriteParamValueReplay<ParamType::TUniformBlockIndex>(std::ostream &os,
const CallCapture &call, const CallCapture &call,
gl::UniformBlockIndex value) gl::UniformBlockIndex value)
{ {
os << value.value; // Find the program from the call parameters.
gl::ShaderProgramID programID;
bool foundProgram = FindShaderProgramIDInCall(call, &programID);
ASSERT(foundProgram);
os << "gUniformBlockIndexes[gShaderProgramMap[" << programID.value << "]][" << value.value
<< "]";
} }
} // namespace angle } // namespace angle
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