Add new location remapping when editing shaders on GL

* If they're autogenerated then unfortunately the locations in a shader can
  change over edits depending on what the shader is doing. We need to remap
  across this as well as composing that onto any capture-replay remapping.
This commit is contained in:
baldurk
2019-09-05 15:06:32 +01:00
parent 7f838fc88c
commit c48578fdd9
3 changed files with 24 additions and 5 deletions
+2 -1
View File
@@ -849,7 +849,8 @@ struct PerStageReflections
};
void CopyProgramUniforms(const PerStageReflections &srcStages, GLuint progSrc,
const PerStageReflections &dstStages, GLuint progDst);
const PerStageReflections &dstStages, GLuint progDst,
std::map<GLint, GLint> *locTranslate = NULL);
template <typename SerialiserType>
void SerialiseProgramUniforms(SerialiserType &ser, CaptureState state,
const PerStageReflections &stages, GLuint prog,
+19 -2
View File
@@ -1660,8 +1660,25 @@ void WrappedOpenGL::ReplaceResource(ResourceId from, ResourceId to)
PerStageReflections dstStages;
FillReflectionArray(progdstid, dstStages);
// copy uniforms
CopyProgramUniforms(stages, progsrc, dstStages, progdst);
std::map<GLint, GLint> translate;
// copy uniforms and set up new location translation table
CopyProgramUniforms(stages, progsrc, dstStages, progdst, &translate);
// start with the original location translation table, to account for any
// capture-replay translation
m_Programs[progdstid].locationTranslate = m_Programs[progsrcid].locationTranslate;
// compose on the one from editing.
for(auto lit = m_Programs[progdstid].locationTranslate.begin();
lit != m_Programs[progdstid].locationTranslate.end(); lit++)
{
auto lit2 = translate.find(lit->second);
if(lit2 != translate.end())
lit->second = lit2->second;
else
lit->second = -1;
}
ResourceId origsrcid = GetResourceManager()->GetOriginalID(progsrcid);
+3 -2
View File
@@ -1254,12 +1254,13 @@ static void ForAllProgramUniforms(SerialiserType *ser, CaptureState state,
}
void CopyProgramUniforms(const PerStageReflections &srcStages, GLuint progSrc,
const PerStageReflections &dstStages, GLuint progDst)
const PerStageReflections &dstStages, GLuint progDst,
std::map<GLint, GLint> *locTranslate)
{
const bool CopyUniforms = true;
const bool SerialiseUniforms = false;
ForAllProgramUniforms<CopyUniforms, SerialiseUniforms, ReadSerialiser>(
NULL, CaptureState::ActiveReplaying, srcStages, progSrc, dstStages, progDst, NULL);
NULL, CaptureState::ActiveReplaying, srcStages, progSrc, dstStages, progDst, locTranslate);
}
template <typename SerialiserType>