GLuint WrappedOpenGL::glCreateShaderProgramv(GLenum type, GLsizei count, const GLchar *const*strings) { GLuint real = m_Real.glCreateShaderProgramv(type, count, strings); GLResource res = ProgramRes(GetCtx(), real); ResourceId id = GetResourceManager()->RegisterResource(res); if(m_State >= WRITING) { Chunk *chunk = NULL; { SCOPED_SERIALISE_CONTEXT(CREATE_SHADERPROGRAM); Serialise_glCreateShaderProgramv(real, type, count, strings); chunk = scope.Get(); } GLResourceRecord *record = GetResourceManager()->AddResourceRecord(id); RDCASSERT(record); // we always want to mark programs as dirty so we can serialise their // locations as initial state (and form a remapping table) GetResourceManager()->MarkDirtyResource(id); record->AddChunk(chunk); } else { GetResourceManager()->AddLiveResource(id, res); } return real; }
GLuint WrappedOpenGL::glCreateShaderProgramv(GLenum type, GLsizei count, const GLchar *const *strings) { GLuint real = m_Real.glCreateShaderProgramv(type, count, strings); GLResource res = ProgramRes(GetCtx(), real); ResourceId id = GetResourceManager()->RegisterResource(res); if(m_State >= WRITING) { Chunk *chunk = NULL; { SCOPED_SERIALISE_CONTEXT(CREATE_SHADERPROGRAM); Serialise_glCreateShaderProgramv(real, type, count, strings); chunk = scope.Get(); } GLResourceRecord *record = GetResourceManager()->AddResourceRecord(id); RDCASSERT(record); // we always want to mark programs as dirty so we can serialise their // locations as initial state (and form a remapping table) GetResourceManager()->MarkDirtyResource(id); record->AddChunk(chunk); } else { GetResourceManager()->AddLiveResource(id, res); vector<string> src; for(GLsizei i = 0; i < count; i++) src.push_back(strings[i]); GLuint sepprog = MakeSeparableShaderProgram(*this, type, src, NULL); auto &progDetails = m_Programs[id]; progDetails.linked = true; progDetails.shaders.push_back(id); progDetails.stageShaders[ShaderIdx(type)] = id; auto &shadDetails = m_Shaders[id]; shadDetails.type = type; shadDetails.sources.swap(src); shadDetails.prog = sepprog; shadDetails.Compile(*this); } return real; }