mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-14 05:50:51 +00:00
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:
@@ -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,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
@@ -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>
|
||||
|
||||
Reference in New Issue
Block a user