<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<meta name="Generator" content="Microsoft Exchange Server">
<!-- converted from text --><style><!-- .EmailQuote { margin-left: 1pt; padding-left: 4pt; border-left: #800000 2px solid; } --></style>
</head>
<body>
<meta content="text/html; charset=UTF-8">
<style type="text/css" style="">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
</style>
<div dir="ltr">
<div id="x_divtagdefaultwrapper" dir="ltr" style="font-size:12pt; color:#000000; font-family:Calibri,Helvetica,sans-serif">
<p>Looks great!</p>
<p><br>
</p>
<p>Reviewed-by: Neha Bhende<bhenden@vmware.com></p>
<p><br>
</p>
<div id="x_Signature">
<div id="x_divtagdefaultwrapper" style="font-size:12pt; color:rgb(0,0,0); background-color:rgb(255,255,255); font-family:Calibri,Arial,Helvetica,sans-serif,Helvetica,EmojiFont,"Apple Color Emoji","Segoe UI Emoji",NotoColorEmoji,"Segoe UI Symbol","Android Emoji",EmojiSymbols">
<p>Regards,</p>
<p>Neha<br>
</p>
</div>
</div>
</div>
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="x_divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Brian Paul <brianp@vmware.com><br>
<b>Sent:</b> Tuesday, July 11, 2017 8:22:07 PM<br>
<b>To:</b> piglit@lists.freedesktop.org<br>
<b>Cc:</b> Charmaine Lee; Neha Bhende; Brian Paul<br>
<b>Subject:</b> [PATCH] wgl: add new multi-context, multi-window rendering tests</font>
<div> </div>
</div>
</div>
<font size="2"><span style="font-size:10pt;">
<div class="PlainText">Like the corresponding glx tests which I recently added.<br>
Both pass on native NVIDIA drivers.  The multi-context-single-window<br>
test fails with the VMware OpenGL driver.<br>
---<br>
 tests/all.py                                |   2 +<br>
 tests/wgl/CMakeLists.gl.txt                 |   2 +<br>
 tests/wgl/wgl-multi-context-single-window.c | 155 ++++++++++++++++++++++++++++<br>
 tests/wgl/wgl-multi-window-single-context.c | 130 +++++++++++++++++++++++<br>
 4 files changed, 289 insertions(+)<br>
 create mode 100644 tests/wgl/wgl-multi-context-single-window.c<br>
 create mode 100644 tests/wgl/wgl-multi-window-single-context.c<br>
<br>
diff --git a/tests/all.py b/tests/all.py<br>
index a7a0e20..e08cee9 100644<br>
--- a/tests/all.py<br>
+++ b/tests/all.py<br>
@@ -839,6 +839,8 @@ with profile.test_list.group_manager(<br>
         PiglitGLTest, 'wgl',<br>
         require_platforms=['wgl']) as g:<br>
     g(['wgl-sanity'])<br>
+    g(['wgl-multi-context-single-window'])<br>
+    g(['wgl-multi-window-single-context'])<br>
 <br>
 with profile.test_list.group_manager(<br>
         PiglitGLTest,<br>
diff --git a/tests/wgl/CMakeLists.gl.txt b/tests/wgl/CMakeLists.gl.txt<br>
index c631f85..0c8135f 100644<br>
--- a/tests/wgl/CMakeLists.gl.txt<br>
+++ b/tests/wgl/CMakeLists.gl.txt<br>
@@ -22,6 +22,8 @@ IF(PIGLIT_BUILD_WGL_TESTS)<br>
                 ${X11_X11_LIB}<br>
         )<br>
         piglit_add_executable (wgl-sanity wgl-sanity.c)<br>
+       piglit_add_executable (wgl-multi-context-single-window wgl-multi-context-single-window.c)<br>
+       piglit_add_executable (wgl-multi-window-single-context wgl-multi-window-single-context.c)<br>
 ENDIF(PIGLIT_BUILD_WGL_TESTS)<br>
 <br>
 # vim: ft=cmake:<br>
diff --git a/tests/wgl/wgl-multi-context-single-window.c b/tests/wgl/wgl-multi-context-single-window.c<br>
new file mode 100644<br>
index 0000000..a28a324<br>
--- /dev/null<br>
+++ b/tests/wgl/wgl-multi-context-single-window.c<br>
@@ -0,0 +1,155 @@<br>
+/*<br>
+ * Copyright © 2017 VMware, Inc.<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/*<br>
+ * Test rendering into one window with multiple contexts.<br>
+ *<br>
+ * Authors:<br>
+ *    Brian Paul<br>
+ */<br>
+<br>
+#include <assert.h><br>
+#include <stdio.h><br>
+#include "piglit-util-gl.h"<br>
+#include "piglit-wgl-util.h"<br>
+<br>
+<br>
+<br>
+#define MAX_CONTEXTS 8<br>
+<br>
+static HGLRC ctx[MAX_CONTEXTS];<br>
+static int num_contexts = MAX_CONTEXTS;<br>
+static HWND win;<br>
+<br>
+static const float colors[MAX_CONTEXTS][4] = {<br>
+       {1, 0, 0, 1},<br>
+       {0, 1, 0, 1},<br>
+       {0, 0, 1, 1},<br>
+       {0, 1, 1, 1},<br>
+       {1, 0, 1, 1},<br>
+       {1, 1, 0, 1},<br>
+       {1, 1, 1, 1},<br>
+       {.5, .5, .5, 1},<br>
+};<br>
+<br>
+<br>
+static int rect_size = 40;<br>
+<br>
+<br>
+static int<br>
+rect_pos(int i)<br>
+{<br>
+       return i * rect_size / 2;<br>
+}<br>
+<br>
+<br>
+enum piglit_result<br>
+draw(void)<br>
+{<br>
+       int i;<br>
+       bool pass = true;<br>
+<br>
+       /* draw a series of colored quads, one per context, at increasing<br>
+        * Z distance.<br>
+        */<br>
+       for (i = 0; i < num_contexts; i++) {<br>
+               if (!wglMakeCurrent(GetDC(win), ctx[i])) {<br>
+                       fprintf(stderr, "wglMakeCurrent failed\n");<br>
+                       return PIGLIT_FAIL;<br>
+               }<br>
+<br>
+               if (i == 0) {<br>
+                       glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);<br>
+               }<br>
+<br>
+               glEnable(GL_DEPTH_TEST);<br>
+               glMatrixMode(GL_PROJECTION);<br>
+               glLoadIdentity();<br>
+               glOrtho(0, piglit_width, 0, piglit_height, 0, 1);<br>
+<br>
+               glMatrixMode(GL_MODELVIEW);<br>
+               glLoadIdentity();<br>
+<br>
+               glPushMatrix();<br>
+               float p = rect_pos(i);<br>
+               float z = -i / 10.0;<br>
+               glTranslatef(p, p, z);<br>
+<br>
+               glColor4fv(colors[i]);<br>
+               piglit_draw_rect(0, 0, rect_size, rect_size);<br>
+<br>
+               glPopMatrix();<br>
+       }<br>
+<br>
+       /* probe rendering */<br>
+       wglMakeCurrent(GetDC(win), ctx[0]);<br>
+       for (i = 0; i < num_contexts; i++) {<br>
+               int x = rect_pos(i) + rect_size * 3 / 4;<br>
+               int p = piglit_probe_pixel_rgb(x, x, colors[i]);<br>
+<br>
+               if (!p) {<br>
+                       printf("Failed probe for rect/context %d\n", i);<br>
+                       pass = false;<br>
+               }<br>
+       }<br>
+<br>
+       SwapBuffers(GetDC(win));<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
+<br>
+<br>
+int<br>
+main(int argc, char **argv)<br>
+{<br>
+       int i;<br>
+<br>
+       piglit_width = 500;<br>
+       piglit_height = 500;<br>
+<br>
+       for (i = 1; i < argc; i++) {<br>
+               if (strcmp(argv[i], "-auto") == 0) {<br>
+                       piglit_automatic = 1;<br>
+                       break;<br>
+               }<br>
+       }<br>
+<br>
+       win = piglit_get_wgl_window();<br>
+       assert(win);<br>
+<br>
+       for (i = 0; i < num_contexts; i++) {<br>
+               ctx[i] = piglit_get_wgl_context(win);<br>
+               assert(ctx[i]);<br>
+       }<br>
+<br>
+       if (!wglMakeCurrent(GetDC(win), ctx[0])) {<br>
+               fprintf(stderr, "wglMakeCurrent failed\n");<br>
+               return 0;<br>
+       }<br>
+<br>
+       piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);<br>
+<br>
+       piglit_wgl_event_loop(draw);<br>
+<br>
+       return 0;<br>
+}<br>
diff --git a/tests/wgl/wgl-multi-window-single-context.c b/tests/wgl/wgl-multi-window-single-context.c<br>
new file mode 100644<br>
index 0000000..3c801be<br>
--- /dev/null<br>
+++ b/tests/wgl/wgl-multi-window-single-context.c<br>
@@ -0,0 +1,130 @@<br>
+/*<br>
+ * Copyright © 2017 VMware, Inc.<br>
+ *<br>
+ * Permission is hereby granted, free of charge, to any person obtaining a<br>
+ * copy of this software and associated documentation files (the "Software"),<br>
+ * to deal in the Software without restriction, including without limitation<br>
+ * the rights to use, copy, modify, merge, publish, distribute, sublicense,<br>
+ * and/or sell copies of the Software, and to permit persons to whom the<br>
+ * Software is furnished to do so, subject to the following conditions:<br>
+ *<br>
+ * The above copyright notice and this permission notice (including the next<br>
+ * paragraph) shall be included in all copies or substantial portions of the<br>
+ * Software.<br>
+ *<br>
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR<br>
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,<br>
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL<br>
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER<br>
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING<br>
+ * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS<br>
+ * IN THE SOFTWARE.<br>
+ */<br>
+<br>
+/*<br>
+ * Test rendering into multiple windows with one context.<br>
+ *<br>
+ * Authors:<br>
+ *    Brian Paul<br>
+ */<br>
+<br>
+#include <assert.h><br>
+#include <stdio.h><br>
+#include "piglit-util-gl.h"<br>
+#include "piglit-wgl-util.h"<br>
+<br>
+<br>
+#define MAX_WINDOWS 8<br>
+<br>
+static HWND win[MAX_WINDOWS];<br>
+static int num_windows = MAX_WINDOWS;<br>
+static HGLRC ctx;<br>
+<br>
+static const float colors[MAX_WINDOWS][4] = {<br>
+       {1, 0, 0, 1},<br>
+       {0, 1, 0, 1},<br>
+       {0, 0, 1, 1},<br>
+       {0, 1, 1, 1},<br>
+       {1, 0, 1, 1},<br>
+       {1, 1, 0, 1},<br>
+       {1, 1, 1, 1},<br>
+       {.5, .5, .5, 1},<br>
+};<br>
+<br>
+<br>
+enum piglit_result<br>
+draw(void)<br>
+{<br>
+       int i;<br>
+       bool pass = true;<br>
+<br>
+       /* draw colored quad in each window */<br>
+       for (i = 0; i < num_windows; i++) {<br>
+               wglMakeCurrent(GetDC(win[i]), ctx);<br>
+<br>
+               glClear(GL_COLOR_BUFFER_BIT);<br>
+               glColor4fv(colors[i]);<br>
+               piglit_draw_rect(-1, -1, 2, 2);<br>
+       }<br>
+<br>
+       /* probe windows */<br>
+       for (i = 0; i < num_windows; i++) {<br>
+               wglMakeCurrent(GetDC(win[i]), ctx);<br>
+<br>
+               glReadBuffer(GL_BACK);<br>
+               /* only read back 20x20 region instead of<br>
+                * piglit_width x piglit_height since Windows may<br>
+                * resize our windows.<br>
+                */<br>
+               int p = piglit_probe_rect_rgb(0, 0, 20, 20,<br>
+                                             colors[i]);<br>
+<br>
+               SwapBuffers(GetDC(win[i]));<br>
+<br>
+               if (!p) {<br>
+                       printf("Failed probe in window %d\n", i);<br>
+                       pass = false;<br>
+               }<br>
+       }<br>
+<br>
+       return pass ? PIGLIT_PASS : PIGLIT_FAIL;<br>
+}<br>
+<br>
+<br>
+int<br>
+main(int argc, char **argv)<br>
+{<br>
+       int i;<br>
+<br>
+       piglit_width = 100;<br>
+       piglit_height = 100;<br>
+<br>
+       for (i = 1; i < argc; i++) {<br>
+               if (strcmp(argv[i], "-auto") == 0) {<br>
+                       piglit_automatic = 1;<br>
+                       break;<br>
+               }<br>
+       }<br>
+<br>
+       /* Create windows */<br>
+       for (i = 0; i < num_windows; i++) {<br>
+               win[i] = piglit_get_wgl_window();<br>
+               MoveWindow(win[i], i*130, 0,<br>
+                          piglit_width, piglit_height, FALSE);<br>
+               assert(win[i]);<br>
+       }<br>
+<br>
+       ctx = piglit_get_wgl_context(win[0]);<br>
+       assert(ctx);<br>
+<br>
+       if (!wglMakeCurrent(GetDC(win[0]), ctx)) {<br>
+               fprintf(stderr, "wglMakeCurrent failed\n");<br>
+               return 0;<br>
+       }<br>
+<br>
+       piglit_dispatch_default_init(PIGLIT_DISPATCH_GL);<br>
+<br>
+       piglit_wgl_event_loop(draw);<br>
+<br>
+       return 0;<br>
+}<br>
-- <br>
1.9.1<br>
<br>
</div>
</span></font>
</body>
</html>