]> git.cworth.org Git - apitrace/commitdiff
Merge remote-tracking branch 'jbenton/master'
authorJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 6 Aug 2012 15:35:14 +0000 (16:35 +0100)
committerJosé Fonseca <jose.r.fonseca@gmail.com>
Mon, 6 Aug 2012 15:35:14 +0000 (16:35 +0100)
21 files changed:
CMakeLists.txt
common/formatter.hpp
dispatch/d3d9imports.hpp
helpers/eglsize.cpp [new file with mode: 0644]
helpers/eglsize.hpp [new file with mode: 0644]
helpers/glsize.hpp
retrace/d3dretrace.hpp
retrace/d3dretrace.py
retrace/d3dretrace_ws.cpp
retrace/glretrace_egl.cpp
retrace/glstate_images.cpp
retrace/glws_egl_xlib.cpp
retrace/json.hpp
specs/d3d9types.py
specs/winapi.py
wrappers/CMakeLists.txt
wrappers/egltrace.py
wrappers/gltrace.py
wrappers/glxtrace.py
wrappers/trace.py
wrappers/wgltrace.py

index a7cbf20325baad496c6c18362848f8028004a71b..9fe20026c6e438be1778bd8fff0bf6e64d591f57 100644 (file)
@@ -70,7 +70,7 @@ include (CheckCXXCompilerFlag)
 
 if (WIN32)
     # http://msdn.microsoft.com/en-us/library/aa383745.aspx
-    add_definitions (-D_WIN32_WINNT=0x0501 -DWINVER=0x0501)
+    add_definitions (-D_WIN32_WINNT=0x0601 -DWINVER=0x0601)
 else (WIN32)
     CHECK_CXX_COMPILER_FLAG("-fvisibility=hidden" CXX_COMPILER_FLAG_VISIBILITY)
     if (CXX_COMPILER_FLAG_VISIBILITY)
index 43b816eb1ef1fb453817bd850ac5f6aad6e56191..75a407f7469ee421f3cde1c9bc8b7e4a68a4772d 100644 (file)
 
 #include <iostream>
 
+#ifdef _WIN32
+#include <windows.h>
+
+#ifndef COMMON_LVB_LEADING_BYTE
+#define COMMON_LVB_LEADING_BYTE    0x0100
+#endif
+
+#ifndef COMMON_LVB_TRAILING_BYTE
+#define COMMON_LVB_TRAILING_BYTE   0x0200
+#endif
+
+#ifndef COMMON_LVB_GRID_HORIZONTAL
+#define COMMON_LVB_GRID_HORIZONTAL 0x0400
+#endif
+
+#ifndef COMMON_LVB_GRID_LVERTICAL
+#define COMMON_LVB_GRID_LVERTICAL  0x0800
+#endif
+
+#ifndef COMMON_LVB_GRID_RVERTICAL
+#define COMMON_LVB_GRID_RVERTICAL  0x1000
+#endif
+
+#ifndef COMMON_LVB_REVERSE_VIDEO
+#define COMMON_LVB_REVERSE_VIDEO   0x4000
+#endif
+
+#ifndef COMMON_LVB_UNDERSCORE
+#define COMMON_LVB_UNDERSCORE      0x8000
+#endif
+
+#endif /* _WIN32 */
+
 
 namespace formatter {
 
@@ -113,38 +146,6 @@ inline std::ostream& operator<<(std::ostream& os, const Attribute *attr) {
 #ifdef _WIN32
 
 
-#include <windows.h>
-
-
-#ifndef COMMON_LVB_LEADING_BYTE
-#define COMMON_LVB_LEADING_BYTE    0x0100
-#endif
-
-#ifndef COMMON_LVB_TRAILING_BYTE
-#define COMMON_LVB_TRAILING_BYTE   0x0200
-#endif
-
-#ifndef COMMON_LVB_GRID_HORIZONTAL
-#define COMMON_LVB_GRID_HORIZONTAL 0x0400
-#endif
-
-#ifndef COMMON_LVB_GRID_LVERTICAL
-#define COMMON_LVB_GRID_LVERTICAL  0x0800
-#endif
-
-#ifndef COMMON_LVB_GRID_RVERTICAL
-#define COMMON_LVB_GRID_RVERTICAL  0x1000
-#endif
-
-#ifndef COMMON_LVB_REVERSE_VIDEO
-#define COMMON_LVB_REVERSE_VIDEO   0x4000
-#endif
-
-#ifndef COMMON_LVB_UNDERSCORE
-#define COMMON_LVB_UNDERSCORE      0x8000
-#endif
-
-
 class WindowsAttribute : public Attribute {
 protected:
     WORD wAttributes;
@@ -189,7 +190,8 @@ public:
     }
 };
 
-#endif
+
+#endif /* _WIN32 */
 
 
 inline Formatter *defaultFormatter(bool color = true) {
index 1ecf293fed6b4a358aff6bcb497269a05ed58216..1a22a59b2c604e76947a3d422068f91e46800840 100644 (file)
 #endif
 
 
+#ifndef D3DUSAGE_TEXTAPI
+#define D3DUSAGE_TEXTAPI 0x10000000L
+#endif
+
+#ifndef D3DUSAGE_RESTRICTED_CONTENT
+#define D3DUSAGE_RESTRICTED_CONTENT 0x00000800L
+#endif
+
+#ifndef D3DUSAGE_RESTRICT_SHARED_RESOURCE
+#define D3DUSAGE_RESTRICT_SHARED_RESOURCE 0x00002000L
+#endif
+
+#ifndef D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER
+#define D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER 0x00001000L
+#endif
+
+
 #endif /* _D3D9IMPORTS_HPP_ */
diff --git a/helpers/eglsize.cpp b/helpers/eglsize.cpp
new file mode 100644 (file)
index 0000000..4f2dfdc
--- /dev/null
@@ -0,0 +1,217 @@
+/*********************************************************************
+ *
+ * Copyright 2012 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *********************************************************************/
+
+/*
+ * Auxiliary functions to compute the size of array/blob arguments.
+ */
+
+#include <string.h>
+
+#include "os_thread.hpp"
+#include "glimports.hpp"
+#include "glproc.hpp"
+#include "glsize.hpp"
+#include "eglsize.hpp"
+#include "assert.h"
+
+
+static int
+bisect_val(int min, int max, bool is_valid_val(int val))
+{
+    bool valid;
+
+    while (1) {
+        int try_val = min + (max - min + 1) / 2;
+
+        valid = is_valid_val(try_val);
+        if (min == max)
+            break;
+
+        if (valid)
+            min = try_val;
+        else
+            max = try_val - 1;
+    }
+
+    return valid ? min : -1;
+}
+
+static bool
+is_valid_width(int val)
+{
+    _glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, val, 1);
+    return _glGetError() == GL_NO_ERROR;
+}
+
+static bool
+is_valid_height(int val)
+{
+    _glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, 0, 1, val);
+    return _glGetError() == GL_NO_ERROR;
+}
+
+static int
+detect_size(int *width_ret, int *height_ret)
+{
+    GLint max_tex_size;
+    int width;
+    int height;
+
+    max_tex_size = 0;
+    _glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_tex_size);
+
+    width = bisect_val(1, max_tex_size, is_valid_width);
+    if (width < 0)
+        return -1;
+
+    height = bisect_val(1, max_tex_size, is_valid_height);
+    if (height < 0)
+        return -1;
+
+    *width_ret = width;
+    *height_ret = height;
+
+    return 0;
+}
+
+/* XXX */
+static inline bool
+can_unpack_subimage(void) {
+    return false;
+}
+
+static void
+_eglCreateImageKHR_get_image_size(EGLImageKHR image, image_info *info)
+{
+    GLuint fbo = 0;
+    GLuint orig_fbo = 0;
+    GLuint texture = 0;
+    GLuint orig_texture;
+    GLenum status;
+
+    _glGetIntegerv(GL_FRAMEBUFFER_BINDING, (GLint *)&orig_fbo);
+    _glGenFramebuffers(1, &fbo);
+    _glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+    _glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&orig_texture);
+    _glGenTextures(1, &texture);
+    _glBindTexture(GL_TEXTURE_2D, texture);
+
+    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+
+    info->width = 0;
+    info->height = 0;
+
+    _glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0,
+                            GL_TEXTURE_2D, texture, 0);
+    status = _glCheckFramebufferStatus(GL_FRAMEBUFFER);
+    if (status == GL_FRAMEBUFFER_COMPLETE) {
+        if (detect_size(&info->width, &info->height) != 0)
+            os::log("%s: can't detect image size\n", __func__);
+    } else {
+        os::log("%s: error: %x\n", __func__, status);
+    }
+
+    /* Don't leak errors to the traced application. */
+    (void)_glGetError();
+
+    _glBindTexture(GL_TEXTURE_2D, orig_texture);
+    _glDeleteTextures(1, &texture);
+
+    _glBindFramebuffer(GL_FRAMEBUFFER, orig_fbo);
+    _glDeleteFramebuffers(1, &fbo);
+}
+
+static void
+get_texture_2d_image(image_info *info)
+{
+    GLuint fbo = 0;
+    GLint prev_fbo = 0;
+    GLint texture;
+    GLenum status;
+
+    _glGetIntegerv(GL_TEXTURE_BINDING_2D, &texture);
+    if (!texture)
+        return;
+
+    _glGetIntegerv(GL_FRAMEBUFFER_BINDING, &prev_fbo);
+    _glGenFramebuffers(1, &fbo);
+    _glBindFramebuffer(GL_FRAMEBUFFER, fbo);
+
+    _glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D,
+                            texture, 0);
+    status = _glCheckFramebufferStatus(GL_FRAMEBUFFER);
+    if (status != GL_FRAMEBUFFER_COMPLETE)
+        os::log("%s: error: %d\n", __func__, status);
+    _glReadPixels(0, 0, info->width, info->height, info->format, info->type, info->pixels);
+    /* Don't leak errors to the traced application. */
+    (void)_glGetError();
+
+    _glBindFramebuffer(GL_FRAMEBUFFER, prev_fbo);
+    _glDeleteFramebuffers(1, &fbo);
+}
+
+struct image_info *
+_EGLImageKHR_get_image_info(GLenum target, EGLImageKHR image)
+{
+    GLuint tex;
+    GLuint bound_tex;
+    struct image_info *info;
+
+    info = new image_info;
+
+    memset(info, 0, sizeof *info);
+
+    info->internalformat = GL_RGBA;
+    info->format = GL_RGBA;
+    info->type = GL_UNSIGNED_BYTE;
+
+    _eglCreateImageKHR_get_image_size(image, info);
+
+    _glGenTextures(1, &tex);
+    _glGetIntegerv(GL_TEXTURE_BINDING_2D, (GLint *)&bound_tex);
+    _glBindTexture(GL_TEXTURE_2D, tex);
+    _glEGLImageTargetTexture2DOES(GL_TEXTURE_2D, image);
+
+    info->size = _glTexImage2D_size(info->format, info->type, info->width, info->height);
+    info->pixels = malloc(info->size);
+
+    get_texture_2d_image(info);
+    _glBindTexture(GL_TEXTURE_2D, bound_tex);
+    _glDeleteBuffers(1, &tex);
+
+    return info;
+}
+
+void
+_EGLImageKHR_free_image_info(struct image_info *info)
+{
+    free(info->pixels);
+    delete info;
+}
+
+
diff --git a/helpers/eglsize.hpp b/helpers/eglsize.hpp
new file mode 100644 (file)
index 0000000..a2014f6
--- /dev/null
@@ -0,0 +1,57 @@
+
+/*********************************************************************
+ *
+ * Copyright 2012 Intel Corporation
+ * All Rights Reserved.
+ *
+ * Permission is hereby granted, free of charge, to any person
+ * obtaining a copy of this software and associated documentation
+ * files (the "Software"), to deal in the Software without
+ * restriction, including without limitation the rights to use, copy,
+ * modify, merge, publish, distribute, sublicense, and/or sell copies
+ * of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
+ * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS
+ * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN
+ * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+ * SOFTWARE.
+ *
+ *********************************************************************/
+
+/*
+ * Auxiliary functions to compute the size of array/blob arguments.
+ */
+#ifndef _EGLSIZE_HPP_
+#define _EGLSIZE_HPP_
+
+
+#include "glimports.hpp"
+
+
+struct image_info
+{
+    GLint internalformat;
+    GLsizei width;
+    GLsizei height;
+    GLenum format;
+    GLenum type;
+    GLsizei size;
+    GLvoid * pixels;
+};
+
+struct image_info *
+_EGLImageKHR_get_image_info(GLenum target, EGLImageKHR image);
+
+void
+_EGLImageKHR_free_image_info(struct image_info *info);
+
+
+#endif
index 5c646fdf10d510da8ff8b23571dc4d365972c249..e686140b3b44122e7624516c9e06429966d9c072 100644 (file)
@@ -37,6 +37,8 @@
 
 #include <string.h>
 
+#include <algorithm>
+
 #include "os.hpp"
 #include "glimports.hpp"
 
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 70fe3546835e704aa00ec1687025758a864fdf5d..43e8169836b257c73c08a75fc61f5a77b813b92f 100644 (file)
@@ -32,6 +32,7 @@
 #include "retrace.hpp"
 #include "glretrace.hpp"
 #include "os.hpp"
+#include "eglsize.hpp"
 
 #ifndef EGL_OPENGL_ES_API
 #define EGL_OPENGL_ES_API              0x30A0
@@ -259,5 +260,8 @@ const retrace::Entry glretrace::egl_callbacks[] = {
     {"eglSwapBuffers", &retrace_eglSwapBuffers},
     //{"eglCopyBuffers", &retrace::ignore},
     {"eglGetProcAddress", &retrace::ignore},
+    {"eglCreateImageKHR", &retrace::ignore},
+    {"eglDestroyImageKHR", &retrace::ignore},
+    {"glEGLImageTargetTexture2DOES", &retrace::ignore},
     {NULL, NULL},
 };
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 47bed8651d02e0856889319cf40bd29870776457..279d6d3c08f21bd715643724f49af2b0727a5992 100644 (file)
@@ -866,6 +866,9 @@ D3DUSAGE = Flags(DWORD, [
     "D3DUSAGE_RTPATCHES",
     "D3DUSAGE_NPATCHES",
     "D3DUSAGE_TEXTAPI",
+    "D3DUSAGE_RESTRICTED_CONTENT",
+    "D3DUSAGE_RESTRICT_SHARED_RESOURCE",
+    "D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER",
 ])
 
 D3DCUBEMAP_FACES = Enum("D3DCUBEMAP_FACES", [
index d2bdca3e58eee49602f1e6177ff993da536c7ee3..c27d0be12897ed5b05e2497c0c78a276cc8241ba 100644 (file)
@@ -51,6 +51,7 @@ BYTE = Alias("BYTE", UInt8)
 WORD = Alias("WORD", UInt16)
 DWORD = Alias("DWORD", UInt32)
 
+UCHAR = Alias("UCHAR", UChar)
 WCHAR = Alias("WCHAR", Short)
 
 BOOL = Enum("BOOL", [
index 17aff4c6e3a2e3e81b7dda4d4ba5e32761bab73e..a2bcfff14907adcb3ae8d52aef0a0df368f83634 100644 (file)
@@ -376,6 +376,7 @@ if (ENABLE_EGL AND NOT WIN32 AND NOT APPLE)
         egltrace.cpp
         glcaps.cpp
         gltrace_state.cpp
+        ${CMAKE_SOURCE_DIR}/helpers/eglsize.cpp
     )
 
     add_dependencies (egltrace glproc)
index 18058468049154acf0eb2d78d77a9d13368424ed..a6ff17f8eaa1f37509b6ad094f07e8e2306f02d4 100644 (file)
@@ -81,6 +81,34 @@ class EglTracer(GlTracer):
             print '        gltrace::releaseContext((uintptr_t)ctx);'
             print '    }'
 
+        if function.name == 'glEGLImageTargetTexture2DOES':
+            print '    image_info *info = _EGLImageKHR_get_image_info(target, image);'
+            print '    if (info) {'
+            print '        GLint level = 0;'
+            print '        GLint internalformat = info->internalformat;'
+            print '        GLsizei width = info->width;'
+            print '        GLsizei height = info->height;'
+            print '        GLint border = 0;'
+            print '        GLenum format = info->format;'
+            print '        GLenum type = info->type;'
+            print '        const GLvoid * pixels = info->pixels;'
+            self.emitFakeTexture2D()
+            print '        _EGLImageKHR_free_image_info(info);'
+            print '    }'
+
+    def emitFakeTexture2D(self):
+        function = glapi.getFunctionByName('glTexImage2D')
+        instances = function.argNames()
+        print '        unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
+        for arg in function.args:
+            assert not arg.output
+            self.serializeArg(function, arg)
+        print '        trace::localWriter.endEnter();'
+        print '        trace::localWriter.beginLeave(_fake_call);'
+        print '        trace::localWriter.endLeave();'
+
+
+
 if __name__ == '__main__':
     print '#include <stdlib.h>'
     print '#include <string.h>'
@@ -94,6 +122,7 @@ if __name__ == '__main__':
     print
     print '#include "glproc.hpp"'
     print '#include "glsize.hpp"'
+    print '#include "eglsize.hpp"'
     print
     
     api = API()
index 901e9d749c1d096ca749526b467b6afae17bd6f8..411a19b16a630c71deec2cc6581e94f9c6eebe4d 100644 (file)
@@ -1016,16 +1016,6 @@ class GlTracer(Tracer):
         function = api.getFunctionByName('glClientActiveTexture')
         self.fake_call(function, [texture])
 
-    def fake_call(self, function, args):
-        print '            unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
-        for arg, instance in zip(function.args, args):
-            assert not arg.output
-            print '            trace::localWriter.beginArg(%u);' % (arg.index,)
-            self.serializeValue(arg.type, instance)
-            print '            trace::localWriter.endArg();'
-        print '            trace::localWriter.endEnter();'
-        print '            trace::localWriter.beginLeave(_fake_call);'
-        print '            trace::localWriter.endLeave();'
 
 
 
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 958c07279a1bf55eab84d44d349ef6a3fded764f..2146f68b0e2bf3f9b410f451198cd9f634f964ac 100644 (file)
@@ -695,4 +695,15 @@ class Tracer:
         print '        trace::localWriter.endEnter();'
         print '        trace::localWriter.beginLeave(_call);'
         print '        trace::localWriter.endLeave();'
+    
+    def fake_call(self, function, args):
+        print '            unsigned _fake_call = trace::localWriter.beginEnter(&_%s_sig);' % (function.name,)
+        for arg, instance in zip(function.args, args):
+            assert not arg.output
+            print '            trace::localWriter.beginArg(%u);' % (arg.index,)
+            self.serializeValue(arg.type, instance)
+            print '            trace::localWriter.endArg();'
+        print '            trace::localWriter.endEnter();'
+        print '            trace::localWriter.beginLeave(_fake_call);'
+        print '            trace::localWriter.endLeave();'
        
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);'