From: José Fonseca Date: Sun, 5 Aug 2012 09:24:28 +0000 (+0100) Subject: Merge branch 'egl-image' X-Git-Url: https://git.cworth.org/git?a=commitdiff_plain;h=b14eab55d848d5c0055c4c512c36248e9578ce24;hp=122c9879c2d4361ee4c46e95f348b6032efeb8f6;p=apitrace Merge branch 'egl-image' Conflicts: wrappers/egltrace.py --- diff --git a/retrace/d3dretrace.hpp b/retrace/d3dretrace.hpp index 91f2357..b552c0b 100644 --- a/retrace/d3dretrace.hpp +++ b/retrace/d3dretrace.hpp @@ -50,6 +50,12 @@ extern const retrace::Entry d3d9_callbacks[]; HWND createWindow(int width, int height); +void +resizeWindow(HWND hWnd, int width, int height); + +bool +processEvents(void); + } /* namespace d3dretrace */ diff --git a/retrace/d3dretrace.py b/retrace/d3dretrace.py index a43289c..ddd37b9 100644 --- a/retrace/d3dretrace.py +++ b/retrace/d3dretrace.py @@ -54,6 +54,11 @@ class D3DRetracer(Retracer): if 'hFocusWindow' in method.argNames(): print r' hFocusWindow = hWnd;' + if method.name in ('Reset', 'ResetEx'): + print r' if (pPresentationParameters->Windowed) {' + print r' d3dretrace::resizeWindow(pPresentationParameters->hDeviceWindow, pPresentationParameters->BackBufferWidth, pPresentationParameters->BackBufferHeight);' + print r' }' + # notify frame has been completed if method.name == 'Present': print r' retrace::frameComplete(call);' @@ -67,6 +72,10 @@ class D3DRetracer(Retracer): Retracer.invokeInterfaceMethod(self, interface, method) + # process events after presents + if method.name == 'Present': + print r' d3dretrace::processEvents();' + # check errors if str(method.type) == 'HRESULT': print r' if (FAILED(_result)) {' diff --git a/retrace/d3dretrace_ws.cpp b/retrace/d3dretrace_ws.cpp index 8626a76..42bd0ab 100644 --- a/retrace/d3dretrace_ws.cpp +++ b/retrace/d3dretrace_ws.cpp @@ -37,6 +37,13 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { MINMAXINFO *pMMI; switch (uMsg) { + case WM_KEYDOWN: + switch (wParam) { + case VK_ESCAPE: + PostMessage(hWnd, WM_CLOSE, 0, 0); + break; + } + break; case WM_GETMINMAXINFO: // Allow to create a window bigger than the desktop pMMI = (MINMAXINFO *)lParam; @@ -45,6 +52,9 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) pMMI->ptMaxTrackSize.x = 60000; pMMI->ptMaxTrackSize.y = 60000; break; + case WM_CLOSE: + exit(0); + break; default: break; } @@ -104,7 +114,38 @@ createWindow(int width, int height) { } +void +resizeWindow(HWND hWnd, int width, int height) { + RECT rClient; + GetClientRect(hWnd, &rClient); + if (width == rClient.right - rClient.left && + height == rClient.bottom - rClient.top) { + return; + } + + RECT rWindow; + GetWindowRect(hWnd, &rWindow); + width += (rWindow.right - rWindow.left) - rClient.right; + height += (rWindow.bottom - rWindow.top) - rClient.bottom; + SetWindowPos(hWnd, NULL, rWindow.left, rWindow.top, width, height, SWP_NOMOVE); +} +bool +processEvents(void) { + MSG uMsg; + while (PeekMessage(&uMsg, NULL, 0, 0, PM_REMOVE)) { + if (uMsg.message == WM_QUIT) { + return false; + } + + if (!TranslateAccelerator(uMsg.hwnd, NULL, &uMsg)) { + TranslateMessage(&uMsg); + DispatchMessage(&uMsg); + } + } + return true; +} + } /* namespace d3dretrace */ diff --git a/retrace/glstate_images.cpp b/retrace/glstate_images.cpp index 55afdd0..6390980 100644 --- a/retrace/glstate_images.cpp +++ b/retrace/glstate_images.cpp @@ -818,6 +818,10 @@ dumpReadBufferImage(JSONWriter &json, GLint width, GLint height, GLenum format, { GLint channels = _gl_format_channels(format); + if (internalFormat == GL_NONE) { + internalFormat = format; + } + Context context; json.beginObject(); diff --git a/retrace/glws_egl_xlib.cpp b/retrace/glws_egl_xlib.cpp index 0b8f34c..58824c2 100644 --- a/retrace/glws_egl_xlib.cpp +++ b/retrace/glws_egl_xlib.cpp @@ -155,6 +155,28 @@ public: eglWaitNative(EGL_CORE_NATIVE_ENGINE); } + void + recreate(void) { + EGLContext currentContext = eglGetCurrentContext(); + EGLSurface currentDrawSurface = eglGetCurrentSurface(EGL_DRAW); + EGLSurface currentReadSurface = eglGetCurrentSurface(EGL_DRAW); + bool rebindDrawSurface = currentDrawSurface == surface; + bool rebindReadSurface = currentReadSurface == surface; + + if (rebindDrawSurface || rebindReadSurface) { + eglMakeCurrent(eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); + } + + eglDestroySurface(eglDisplay, surface); + + EGLConfig config = static_cast(visual)->config; + surface = eglCreateWindowSurface(eglDisplay, config, (EGLNativeWindowType)window, NULL); + + if (rebindDrawSurface || rebindReadSurface) { + eglMakeCurrent(eglDisplay, surface, surface, currentContext); + } + } + void resize(int w, int h) { if (w == width && h == height) { @@ -182,6 +204,27 @@ public: waitForEvent(ConfigureNotify); eglWaitNative(EGL_CORE_NATIVE_ENGINE); + + /* + * Some implementations won't update the backbuffer unless we recreate + * the EGL surface. + */ + + int eglWidth; + int eglHeight; + + eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth); + eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight); + + if (eglWidth != width || eglHeight != height) { + recreate(); + + eglQuerySurface(eglDisplay, surface, EGL_WIDTH, &eglWidth); + eglQuerySurface(eglDisplay, surface, EGL_HEIGHT, &eglHeight); + } + + assert(eglWidth == width); + assert(eglHeight == height); } void show(void) { diff --git a/retrace/json.hpp b/retrace/json.hpp index 6af1f4c..2f50a8c 100644 --- a/retrace/json.hpp +++ b/retrace/json.hpp @@ -34,6 +34,13 @@ #include #include +#ifdef _MSC_VER +# include +# define isfinite _finite +#else +# include // isfinite +#endif + #include #include #include @@ -328,8 +335,8 @@ public: template inline void writeNumber(T n) { - if (n != n) { - // NaN + if (!isfinite(n)) { + // NaN/Inf writeNull(); } else { separator(); diff --git a/wrappers/egltrace.py b/wrappers/egltrace.py index c5ead2d..a6ff17f 100644 --- a/wrappers/egltrace.py +++ b/wrappers/egltrace.py @@ -109,7 +109,6 @@ class EglTracer(GlTracer): - if __name__ == '__main__': print '#include ' print '#include ' diff --git a/wrappers/glxtrace.py b/wrappers/glxtrace.py index ff3eb4c..670f8f3 100644 --- a/wrappers/glxtrace.py +++ b/wrappers/glxtrace.py @@ -45,17 +45,34 @@ class GlxTracer(GlTracer): "glXGetProcAddressARB", ] + createContextFunctionNames = [ + 'glXCreateContext', + 'glXCreateContextAttribsARB', + 'glXCreateContextWithConfigSGIX', + 'glXCreateNewContext', + ] + + destroyContextFunctionNames = [ + 'glXDestroyContext', + ] + + makeCurrentFunctionNames = [ + 'glXMakeCurrent', + 'glXMakeContextCurrent', + 'glXMakeCurrentReadSGI', + ] + def traceFunctionImplBody(self, function): - if function.name == 'glXDestroyContext': + if function.name in self.destroyContextFunctionNames: print ' gltrace::releaseContext((uintptr_t)ctx);' GlTracer.traceFunctionImplBody(self, function) - if function.name == 'glXCreateContext': + if function.name in self.createContextFunctionNames: print ' if (_result != NULL)' print ' gltrace::createContext((uintptr_t)_result);' - if function.name == 'glXMakeCurrent': + if function.name in self.makeCurrentFunctionNames: print ' if (_result) {' print ' if (ctx != NULL)' print ' gltrace::setContext((uintptr_t)ctx);' diff --git a/wrappers/wgltrace.py b/wrappers/wgltrace.py index 1b00357..317c542 100644 --- a/wrappers/wgltrace.py +++ b/wrappers/wgltrace.py @@ -39,8 +39,24 @@ class WglTracer(GlTracer): "wglGetProcAddress", ] + createContextFunctionNames = [ + 'wglCreateContext', + 'wglCreateContextAttribsARB', + 'wglCreateLayerContext', + ] + + destroyContextFunctionNames = [ + 'wglDeleteContext', + ] + + makeCurrentFunctionNames = [ + 'wglMakeCurrent', + 'wglMakeContextCurrentARB', + 'wglMakeContextCurrentEXT', + ] + def traceFunctionImplBody(self, function): - if function.name == 'wglDeleteContext': + if function.name in self.destroyContextFunctionNames: # Unlike other GL APIs like EGL or GLX, WGL will make the context # inactive if it's currently the active context. print ' if (_wglGetCurrentContext() == hglrc) {' @@ -50,11 +66,11 @@ class WglTracer(GlTracer): GlTracer.traceFunctionImplBody(self, function) - if function.name == 'wglCreateContext': + if function.name in self.createContextFunctionNames: print ' if (_result)' print ' gltrace::createContext((uintptr_t)_result);' - if function.name == 'wglMakeCurrent': + if function.name in self.makeCurrentFunctionNames: print ' if (_result) {' print ' if (hglrc != NULL)' print ' gltrace::setContext((uintptr_t)hglrc);'