mirror of
https://github.com/baldurk/renderdoc.git
synced 2026-05-06 01:50:38 +00:00
Semi-hack, make last known context current if NULL is current on cap
* We need a context to be current when the frame capture happens so that we can fetch initial contents and such. This is a hack as there's no guarantee it's correct or will work, but we temporarily make the last context that was active on this thread active again, to fetch our data. * This could break if that context is active elsewhere, or isn't a valid context (ie. maybe it was a temporary context used to fetch func pointers). * A better fix would be to delay any GL work we need to do until the next time a good context becomes current, but that becomes dicey in itself.
This commit is contained in:
@@ -968,6 +968,9 @@ void WrappedOpenGL::CreateContext(GLWindowingData winData, void *shareContext, G
|
||||
void WrappedOpenGL::ActivateContext(GLWindowingData winData)
|
||||
{
|
||||
m_ActiveContexts[Threading::GetCurrentID()] = winData;
|
||||
if(winData.ctx)
|
||||
m_DefaultContexts[Threading::GetCurrentID()] = winData;
|
||||
|
||||
// TODO: support multiple GL contexts more explicitly
|
||||
Keyboard::AddInputWindow((void *)winData.wnd);
|
||||
|
||||
@@ -1895,6 +1898,15 @@ void WrappedOpenGL::Present(void *windowHandle)
|
||||
{
|
||||
m_State = WRITING_CAPFRAME;
|
||||
|
||||
GLWindowingData &prevctx = m_ActiveContexts[Threading::GetCurrentID()];
|
||||
|
||||
bool switchedContext = false;
|
||||
if(prevctx.ctx == NULL)
|
||||
{
|
||||
MakeContextCurrent(m_DefaultContexts[Threading::GetCurrentID()]);
|
||||
switchedContext = true;
|
||||
}
|
||||
|
||||
FetchFrameRecord record;
|
||||
record.frameInfo.frameNumber = m_FrameCounter+1;
|
||||
record.frameInfo.captureTime = Timing::GetUnixTimestamp();
|
||||
@@ -1908,6 +1920,9 @@ void WrappedOpenGL::Present(void *windowHandle)
|
||||
AttemptCapture();
|
||||
BeginCaptureFrame();
|
||||
|
||||
if(switchedContext)
|
||||
MakeContextCurrent(prevctx);
|
||||
|
||||
RDCLOG("Starting capture, frame %u", m_FrameCounter);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,6 +131,10 @@ class WrappedOpenGL
|
||||
|
||||
map<uint64_t, GLWindowingData> m_ActiveContexts;
|
||||
|
||||
// we use this context if we need one e.g. for fetching initial states
|
||||
// if no context is current
|
||||
map<uint64_t, GLWindowingData> m_DefaultContexts;
|
||||
|
||||
bool m_ActiveQueries[8][8]; // first index type, second index (for some, always 0)
|
||||
bool m_ActiveConditional;
|
||||
bool m_ActiveFeedback;
|
||||
|
||||
Reference in New Issue
Block a user