]> git.cworth.org Git - apitrace/commitdiff
Merge branch 'egl-image'
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 5 Aug 2012 09:24:28 +0000 (10:24 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Sun, 5 Aug 2012 09:24:28 +0000 (10:24 +0100)
Conflicts:
wrappers/egltrace.py

retrace/d3dretrace.hpp
retrace/d3dretrace.py
retrace/d3dretrace_ws.cpp
retrace/glstate_images.cpp
retrace/glws_egl_xlib.cpp
retrace/json.hpp
wrappers/egltrace.py
wrappers/glxtrace.py
wrappers/wgltrace.py

index 91f235766284474c0cf412ba7fcf2d8099cc714a..b552c0bf3935a609d06fe9be07f34bf4095897ec 100644 (file)
@@ -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 */
 
index a43289cc64ea6ef9b855ddc4c851d1c4ee4f4009..ddd37b95a8b7c3d4b3ca34e1b287846fed5d6f8a 100644 (file)
@@ -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)) {'
index 8626a764597e49507aa9cb6e6eb2ae654720eb71..42bd0abef159cd068a00d7cacbbee42050060b65 100644 (file)
@@ -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 */
index 55afdd0a00392eba28c69b3eae459f1fe2d92f94..6390980966a91c8e17048718b20f01630e6aa338 100644 (file)
@@ -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();
index 0b8f34c17bc595d192d297cf5517901632abbb05..58824c29b2b897765e0af4c8fe36753e907ef79e 100644 (file)
@@ -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<const EglVisual *>(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) {
index 6af1f4c6c4fab898fae8ca730c5092cefc850459..2f50a8c55aedc28fccad91c1493031289113cc2b 100644 (file)
 #include <stddef.h>
 #include <wchar.h>
 
+#ifdef _MSC_VER
+#  include <float.h>
+#  define isfinite _finite
+#else
+#  include <math.h> // isfinite
+#endif
+
 #include <iomanip>
 #include <limits>
 #include <ostream>
@@ -328,8 +335,8 @@ public:
 
     template<class T>
     inline void writeNumber(T n) {
-        if (n != n) {
-            // NaN
+        if (!isfinite(n)) {
+            // NaN/Inf
             writeNull();
         } else {
             separator();
index c5ead2d52598ea31f16e97389d0f9d6ab1f9b3a9..a6ff17f8eaa1f37509b6ad094f07e8e2306f02d4 100644 (file)
@@ -109,7 +109,6 @@ class EglTracer(GlTracer):
 
 
 
-
 if __name__ == '__main__':
     print '#include <stdlib.h>'
     print '#include <string.h>'
index ff3eb4cd62652ec216b0e83e516aefd011c41241..670f8f39a1785254d3b9d8bc497777e22b846a38 100644 (file)
@@ -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);'
index 1b0035799fdd648f32bda397b2e4ddb5f86c67e4..317c5422a7d5400e17c9d791c084c630b1ee9d7f 100644 (file)
@@ -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);'