]> git.pld-linux.org Git - packages/Mesa.git/blame - Mesa-git.patch
- rel 7; branch diff updated
[packages/Mesa.git] / Mesa-git.patch
CommitLineData
c3c893c6
AM
1diff --git a/Makefile b/Makefile
2index b8069f9..b13ed33 100644
3--- a/Makefile
4+++ b/Makefile
5@@ -347,23 +347,19 @@ GALLIUM_FILES = \
6
7 DRI_FILES = \
8 $(DIRECTORY)/include/GL/internal/dri_interface.h \
9- $(DIRECTORY)/include/GL/internal/glcore.h \
10 $(DIRECTORY)/include/GL/internal/sarea.h \
11 $(DIRECTORY)/src/glx/Makefile \
12- $(DIRECTORY)/src/glx/Makefile \
13 $(DIRECTORY)/src/glx/*.[ch] \
14 $(DIRECTORY)/src/mesa/drivers/dri/Makefile \
15 $(DIRECTORY)/src/mesa/drivers/dri/Makefile.template \
16 $(DIRECTORY)/src/mesa/drivers/dri/dri.pc.in \
17- $(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.[ch] \
18 $(DIRECTORY)/src/mesa/drivers/dri/common/xmlpool/*.po \
19 $(DIRECTORY)/src/mesa/drivers/dri/*/*.[chS] \
20 $(DIRECTORY)/src/mesa/drivers/dri/*/*.cpp \
21 $(DIRECTORY)/src/mesa/drivers/dri/*/*/*.[chS] \
22 $(DIRECTORY)/src/mesa/drivers/dri/*/Makefile \
23 $(DIRECTORY)/src/mesa/drivers/dri/*/*/Makefile \
24- $(DIRECTORY)/src/mesa/drivers/dri/*/Doxyfile \
25- $(DIRECTORY)/src/mesa/drivers/dri/*/server/*.[ch]
26+ $(DIRECTORY)/src/mesa/drivers/dri/*/Doxyfile
27
28 SGI_GLU_FILES = \
29 $(DIRECTORY)/src/glu/Makefile \
9caf779f
AM
30diff --git a/docs/devinfo.html b/docs/devinfo.html
31index df0e726..2d1c125 100644
32--- a/docs/devinfo.html
33+++ b/docs/devinfo.html
34@@ -145,7 +145,7 @@ Make sure the values in src/mesa/main/version.h are correct.
35 </p>
36
37 <p>
38-Update the docs/news.html file and docs/download.html files.
39+Update docs/news.html.
40 </p>
41
42 <p>
43@@ -208,10 +208,11 @@ sftp USERNAME,mesa3d@web.sourceforge.net
44
45 <p>
46 Make an announcement on the mailing lists:
47-<em>m</em><em>e</em><em>s</em><em>a</em><em>3</em><em>d</em><em>-</em><em>d</em><em>e</em><em>v</em><em>@</em><em>l</em><em>i</em><em>s</em><em>t</em><em>s</em><em>.</em><em>s</em><em>f</em><em>.</em><em>n</em><em>e</em><em>t</em>,
48-<em>m</em><em>e</em><em>s</em><em>a</em><em>3</em><em>d</em><em>-</em><em>u</em><em>s</em><em>e</em><em>r</em><em>s</em><em>@</em><em>l</em><em>i</em><em>s</em><em>t</em><em>s</em><em>.</em><em>s</em><em>f</em><em>.</em><em>n</em><em>e</em><em>t</em>
49+
50+<em>m</em><em>e</em><em>s</em><em>a</em><em>-</em><em>d</em><em>e</em><em>v</em><em>@</em><em>l</em><em>i</em><em>s</em><em>t</em><em>s</em><em>.</em><em>f</em><em>r</em><em>e</em><em>e</em><em>d</em><em>e</em><em>s</em><em>k</em><em>t</em><em>o</em><em>p</em><em>.</em><em>o</em><em>r</em><em>g</em>,
51+<em>m</em><em>e</em><em>s</em><em>a</em><em>-</em><em>u</em><em>s</em><em>e</em><em>r</em><em>s</em><em>@</em><em>l</em><em>i</em><em>s</em><em>t</em><em>s</em><em>.</em><em>f</em><em>r</em><em>e</em><em>e</em><em>d</em><em>e</em><em>s</em><em>k</em><em>t</em><em>o</em><em>p</em><em>.</em><em>o</em><em>r</em><em>g</em>
52 and
53-<em>m</em><em>e</em><em>s</em><em>a</em><em>3</em><em>d</em><em>-</em><em>a</em><em>n</em><em>n</em><em>o</em><em>u</em><em>n</em><em>c</em><em>e</em><em>@</em><em>l</em><em>i</em><em>s</em><em>t</em><em>s</em><em>.</em><em>s</em><em>f</em><em>.</em><em>n</em><em>e</em><em>t</em>
54+<em>m</em><em>e</em><em>s</em><em>a</em><em>-</em><em>a</em><em>n</em><em>n</em><em>o</em><em>u</em><em>n</em><em>c</em><em>e</em><em>@</em><em>l</em><em>i</em><em>s</em><em>t</em><em>s</em><em>.</em><em>f</em><em>r</em><em>e</em><em>e</em><em>d</em><em>e</em><em>s</em><em>k</em><em>t</em><em>o</em><em>p</em><em>.</em><em>o</em><em>r</em><em>g</em>
55 </p>
56
57
58diff --git a/docs/news.html b/docs/news.html
59index b3fb8b5..72d38ee 100644
60--- a/docs/news.html
61+++ b/docs/news.html
62@@ -11,10 +11,18 @@
63 <H1>News</H1>
64
65
66+<h2>October 4, 2010</h2>
67+
68+<p>
69+<a href="relnotes-7.9.html">Mesa 7.9</a> (final) is released. This is a new
70+development release.
71+</p>
72+
73+
74 <h2>September 27, 2010</h2>
75
76 <p>
77-<a href="relnotes-7.9.0.html">Mesa 7.9.0-rc1</a> is released. This is a
78+<a href="relnotes-7.9.html">Mesa 7.9.0-rc1</a> is released. This is a
79 release candidate for the 7.9 development release.
80 </p>
81
82diff --git a/docs/relnotes-7.8.2.html b/docs/relnotes-7.8.2.html
83index e1b0f2d..1393b2e 100644
84--- a/docs/relnotes-7.8.2.html
85+++ b/docs/relnotes-7.8.2.html
86@@ -26,7 +26,15 @@ for DRI hardware acceleration.
87
88 <h2>MD5 checksums</h2>
89 <pre>
90-tbd
91+c89b63d253605ed40e8ac370d25a833c MesaLib-7.8.2.tar.gz
92+6be2d343a0089bfd395ce02aaf8adb57 MesaLib-7.8.2.tar.bz2
93+a04ad3b06ac5ff3969a003fa7bbf7d5b MesaLib-7.8.2.zip
94+7c213f92efeb471f0331670d5079d4c0 MesaDemos-7.8.2.tar.gz
95+757d9e2e06f48b1a52848be9b0307ced MesaDemos-7.8.2.tar.bz2
96+8d0e5cfe68b8ebf90265d350ae2c48b1 MesaDemos-7.8.2.zip
97+b74482e3f44f35ed395c4aada4fd8240 MesaGLUT-7.8.2.tar.gz
98+a471807b65e49c325808ba4551be93ed MesaGLUT-7.8.2.tar.bz2
99+9f190268c42be582ef66e47365ee61e3 MesaGLUT-7.8.2.zip
100 </pre>
101
102
103@@ -44,10 +52,95 @@ tbd
104 <ul>
105 <li>Fixed Gallium glDrawPixels(GL_DEPTH_COMPONENT).
106 <li>Fixed Gallium Cell driver to buildable, runable state
107+<li>Fixed bad error checking for glFramebufferRenderbuffer(attachment=GL_DEPTH_STENCIL_ATTACHMENT).
108+<li>Fixed incorrect Z coordinate handling in "meta" glDraw/CopyPixels.
109+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=23670">Bug
110+ #23670</a>.</li>
111+
112+<li>Assorted i965 driver fixes.
113+ Including but not limited to:
114+ <ul>
115+ <li>Fix scissoring when width or height is
116+ 0. <a href="https://bugs.freedesktop.org/show_bug.cgi?id=27643">Bug
117+ #27643</a>.
118+ <li>Fix bit allocation for number of color regions for
119+ ARB_draw_buffers.</li>
120+ <li>Set the correct provoking vertex for clipped first-mode
121+ trifans. <a href="https://bugs.freedesktop.org/show_bug.cgi?id=24470">Bug
122+ #24470</a>.</li>
123+ <li>Use <code>R16G16B16A16_FLOAT</code> for 3-component half-float.</li>
124+ <li>Fix assertion for surface tile offset usage on Ironlake.</li>
125+ <li>Fix cube map layouts on Ironlake.</li>
126+ <li>When an RB gets a new region, clear the old from the state
127+ cache. <a href="https://bugs.freedesktop.org/show_bug.cgi?id=24119">Bug
128+ #24119</a>.</li>
129+ <li>Reject shaders with uninlined function calls instead of hanging.</li>
130+ </ul>
131+</li>
132+
133+<li>Assorted i915 driver fixes. Including but not limited to:
134+ <ul>
135+ <li>Fixed texture LOD clamping in i915 driver.
136+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=24846">Bug
137+ #24846</a>.</li>
138+ <li>Fix off-by-one for drawing rectangle.
139+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=27408">Bug
140+ #27408</a>.</li>
141+ </ul>
142+</li>
143+
144+<li>Fixed hangs in etracer on 830 and 845
145+ chipsets. <a href="https://bugs.freedesktop.org/show_bug.cgi?id=26557">Bug
146+ #26557</a>.</li>
147+<li>Fixed tiling of small textures on all Intel drivers.</li>
148+<li>Fixed crash in Savage driver when using <code>_mesa_CopyTexImage2D</code>.
149+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=27652">Bug
150+ #27652</a>.</li>
151+
152+<li>Assorted GLX fixes. Including but not limited to:
153+ <ul>
154+ <li>Fixed <code>__glXInitializeVisualConfigFromTags</code>'s handling of
155+ unrecognized fbconfig tags.</li>
156+ <li>Fixed regression with <code>GLX_USE_GL</code>.
157+ <li>Fixed config chooser logic for 'mask' matching.</li>
158+ <li>Report swap events correctly in direct rendered case (DRI2)</li>
159+ <li>Fixed build with dri2proto which doesn't define
160+ <code>X_DRI2SwapInterval</code>.</li>
161+ <li>Get <code>GLX_SCREEN</code> first in <code>__glXQueryContextInfo</code>.
162+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=14245">Bug
163+ #14245</a>.</li>
164+ </ul>
165+</li>
166+
167+<li>Assorted GLSL fixes. Including but not limited to:
168+ <ul>
169+ <li>Change variable declared assertion into conditional in GLSL
170+ compiler. <a href="https://bugs.freedesktop.org/show_bug.cgi?id=27921">Bug
171+ #27921</a>.</li>
172+ <li>Fix instruction indexing
173+ bugs. <a href="https://bugs.freedesktop.org/show_bug.cgi?id=27566">Bug
174+ #27566</a>.</li>
175+ <li>Updated uniform location / offset encoding to be more like
176+ other implementations.</li>
177+ <li>Don't overwrite a driver's shader infolog with generic failure
178+ message.</li>
179+ </ul>
180+</li>
181+
182+<li>Fixed OSMesa build for 16 and 32-bit color channel depth.
183+<li>Fixed OSMesa build with hidden symbol visibility. libOSMesa no longer links to libGL.
184+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=28305">Bug
185+ #28305</a>.
186+<li>Fixed handling of multiple render targets in fixed-function
187+ texture envrionmnent programs.</li>
188+<li>Fixed conversion errors in <code>signed_rgba8888[rev]</code> texel
189+ fetch.</li>
190+<li>Don't set srcLevel on <code>GL_TEXTURE_RECTANGLE_ARB</code> targets.</li>
191+<li>Various build fixes for OpenBSD.</li>
192+<li>Various build fixes for OS X.</li>
193+<li>Various build fixes for GCC 3.3.</li>
194 </ul>
195
196
197-<h2>Changes</h2>
198-<p>None.</p>
199 </body>
200 </html>
201diff --git a/docs/relnotes-7.8.3.html b/docs/relnotes-7.8.3.html
202new file mode 100644
203index 0000000..1e9f433
204--- /dev/null
205+++ b/docs/relnotes-7.8.3.html
206@@ -0,0 +1,89 @@
207+<HTML>
208+
209+<TITLE>Mesa Release Notes</TITLE>
210+
211+<head><link rel="stylesheet" type="text/css" href="mesa.css"></head>
212+
213+<BODY>
214+
215+<body bgcolor="#eeeeee">
216+
217+<H1>Mesa 7.8.3 Release Notes / (date tbd)</H1>
218+
219+<p>
220+Mesa 7.8.3 is a bug fix release which fixes bugs found since the 7.8.2 release.
221+</p>
222+<p>
223+Mesa 7.8.3 implements the OpenGL 2.1 API, but the version reported by
224+glGetString(GL_VERSION) depends on the particular driver being used.
225+Some drivers don't support all the features required in OpenGL 2.1.
226+</p>
227+<p>
228+See the <a href="install.html">Compiling/Installing page</a> for prerequisites
229+for DRI hardware acceleration.
230+</p>
231+
232+
233+<h2>MD5 checksums</h2>
234+<pre>
235+x MesaLib-7.8.3.tar.gz
236+x MesaLib-7.8.3.tar.bz2
237+x MesaLib-7.8.3.zip
238+x MesaDemos-7.8.3.tar.gz
239+x MesaDemos-7.8.3.tar.bz2
240+x MesaDemos-7.8.3.zip
241+x MesaGLUT-7.8.3.tar.gz
242+x MesaGLUT-7.8.3.tar.bz2
243+x MesaGLUT-7.8.3.zip
244+</pre>
245+
246+
247+<h2>New features</h2>
248+<p>None.</p>
249+
250+
251+<h2>Changes</h2>
252+<ul>
253+<li>The radeon driver should use less memory when searching for a valid mip
254+image.</li>
255+</ul>
256+
257+
258+<h2>Bug fixes</h2>
259+<ul>
260+<li>Fix unsupported FB with D24S8 (bug
261+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=23670">29116</a>)</li>
262+<li>Fix ReadPixels crash when reading depth/stencil from an FBO</li>
263+<li>Fixed a bug rendering to 16-bit buffers using swrast.</li>
264+<li>Fixed a state tracker/TGSI bug that caused crashes when using Windows'
265+ memory debugging features.</li>
266+<li>Fixed an issue rendering to 32-bit channels with swrast (bug
267+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=29487">29487</a>)</li>
268+<li>GLSL: fix indirect <TT>gl_TextureMatrix</TT> addressing (bug
269+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=28967">28967</a>)</li>
270+<li>GLSL: fix for bug
271+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=27216">27216</a></li>
272+<li>GLSL: fix zw fragcoord entries in some cases (bug
273+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=29183">29183</a>)</li>
274+<li>Fix texture env generation in some cases (bug
275+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=28169">28169</a>)</li>
276+<li>osmesa: a fix for calling <TT>OSMesaMakeCurrent</TT> twice was applied (bug
277+ <a href="https://bugs.freedesktop.org/show_bug.cgi?id=10966">10966</a></li>
278+<li>A bug was fixed which could cause Mesa to ignore the
279+ <TT>MESA_EXTENSION_OVERRIDE</TT> environment variable.</li>
280+<li>A bug related to specular highlights on backfaces was fixed.</li>
281+<li>A radeon-specific issue with <TT>glCopyTex(Sub)Image</TT> was
282+ corrected.</li>
283+<li>radeon/wine: flush command stream in more cases, fixing wine d3d9
284+ tests.</li>
285+<li>r600: fix sin+cos normalization.</li>
286+<li>r600: (properly) ignore <TT>GL_COORD_REPLACE</TT> when point sprites are
287+ disabled.</li>
288+<li>radeon: avoid flushing when the context is not current.</li>
289+<li>r300c: a bug affecting unaligned BOs was fixed.</li>
290+<li>r300c: a hardlock caused by ARB_half_float_vertex incorrectly advertised on some chipsets.</li>
291+</ul>
292+
293+
294+</body>
295+</html>
296diff --git a/docs/relnotes-7.9.html b/docs/relnotes-7.9.html
297index b09fb1d..fe1fd5e 100644
298--- a/docs/relnotes-7.9.html
299+++ b/docs/relnotes-7.9.html
300@@ -28,12 +28,12 @@ for DRI hardware acceleration.
301
302 <h2>MD5 checksums</h2>
303 <pre>
304-f1f01a7baec255f13e9468fb4b05922a MesaLib-7.9-rc1.tar.gz
305-7ffbda3b7056c60b8f87e3082d853af1 MesaLib-7.9-rc1.tar.bz2
306-9d4650df4e5b530178d6fde840f76664 MesaLib-7.9-rc1.zip
307-a81c2e7a0c7832e67c768d6f209f2c8f MesaGLUT-7.9-rc1.tar.gz
308-b4c1c2f0b47a07be10fa2dd42e6a63d7 MesaGLUT-7.9-rc1.tar.bz2
309-c9dd7419a19bcb24a1fe556ec2e78451 MesaGLUT-7.9-rc1.zip
310+ed65ab425b25895c7f473d0a5e6e64f8 MesaLib-7.9.tar.gz
311+82c740c49d572baa6da2b1a1eee90bca MesaLib-7.9.tar.bz2
312+cd2b6ecec759b0457475e94bbb38fedb MesaLib-7.9.zip
313+7b54af9fb9b1f6a1a65db2520f50848f MesaGLUT-7.9.tar.gz
314+20d07419d1929f833fdb36bced290ad5 MesaGLUT-7.9.tar.bz2
315+62a7edecd7c92675cd6029b05217eb0a MesaGLUT-7.9.zip
316 </pre>
317
318
319diff --git a/docs/relnotes.html b/docs/relnotes.html
320index 47e7f80..4487af9 100644
321--- a/docs/relnotes.html
322+++ b/docs/relnotes.html
323@@ -14,6 +14,7 @@ The release notes summarize what's new or changed in each Mesa release.
324
325 <UL>
326 <LI><A HREF="relnotes-7.9.html">7.9 release notes</A>
327+<LI><A HREF="relnotes-7.8.3.html">7.8.3 release notes</A>
328 <LI><A HREF="relnotes-7.8.2.html">7.8.2 release notes</A>
329 <LI><A HREF="relnotes-7.8.1.html">7.8.1 release notes</A>
330 <LI><A HREF="relnotes-7.8.html">7.8 release notes</A>
c3c893c6
AM
331diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
332index 9c4ff56..4a6506c 100644
333--- a/src/egl/drivers/dri2/egl_dri2.c
334+++ b/src/egl/drivers/dri2/egl_dri2.c
335@@ -741,7 +741,7 @@ dri2_create_screen(_EGLDisplay *disp)
336 if (dri2_dpy->dri2->base.version >= 2)
337 api_mask = dri2_dpy->dri2->getAPIMask(dri2_dpy->dri_screen);
338 else
339- api_mask = __DRI_API_OPENGL;
340+ api_mask = 1 << __DRI_API_OPENGL;
341
342 disp->ClientAPIsMask = 0;
343 if (api_mask & (1 <<__DRI_API_OPENGL))
344diff --git a/src/egl/main/eglcontext.c b/src/egl/main/eglcontext.c
345index bc22913..763b1b3 100644
346--- a/src/egl/main/eglcontext.c
347+++ b/src/egl/main/eglcontext.c
348@@ -272,10 +272,6 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
349 if (!surfaceless && (draw == NULL || read == NULL))
350 return _eglError(EGL_BAD_MATCH, "eglMakeCurrent");
351
352- /* context stealing from another thread is not allowed */
353- if (ctx->Binding && ctx->Binding != t)
354- return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
355-
356 /*
357 * The spec says
358 *
359@@ -283,16 +279,23 @@ _eglCheckMakeCurrent(_EGLContext *ctx, _EGLSurface *draw, _EGLSurface *read)
360 * bound to contexts in another thread, an EGL_BAD_ACCESS error is
361 * generated."
362 *
363- * But it also says
364+ * and
365 *
366 * "at most one context may be bound to a particular surface at a given
367 * time"
368- *
369- * The latter is more restrictive so we can check only the latter case.
370 */
371- if ((draw && draw->CurrentContext && draw->CurrentContext != ctx) ||
372- (read && read->CurrentContext && read->CurrentContext != ctx))
373+ if (ctx->Binding && ctx->Binding != t)
374 return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
375+ if (draw && draw->CurrentContext && draw->CurrentContext != ctx) {
376+ if (draw->CurrentContext->Binding != t ||
377+ draw->CurrentContext->ClientAPI != ctx->ClientAPI)
378+ return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
379+ }
380+ if (read && read->CurrentContext && read->CurrentContext != ctx) {
381+ if (read->CurrentContext->Binding != t ||
382+ read->CurrentContext->ClientAPI != ctx->ClientAPI)
383+ return _eglError(EGL_BAD_ACCESS, "eglMakeCurrent");
384+ }
385
386 /* simply require the configs to be equal */
387 if ((draw && draw->Config != ctx->Config) ||
25bb03e4
AM
388diff --git a/src/egl/main/egldriver.h b/src/egl/main/egldriver.h
389index c618feb..950774f 100644
390--- a/src/egl/main/egldriver.h
391+++ b/src/egl/main/egldriver.h
392@@ -4,7 +4,7 @@
393
394 #include "egltypedefs.h"
395 #include "eglapi.h"
396-
397+#include <stddef.h>
398
399 /**
400 * Define an inline driver typecast function.
aba744d1
AM
401diff --git a/src/gallium/drivers/llvmpipe/lp_bld_depth.c b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
402index 99a768a..749ae66 100644
403--- a/src/gallium/drivers/llvmpipe/lp_bld_depth.c
404+++ b/src/gallium/drivers/llvmpipe/lp_bld_depth.c
405@@ -262,7 +262,7 @@ lp_build_stencil_op_single(struct lp_build_context *bld,
406 LLVMValueRef writemask = lp_build_const_int_vec(type, stencil->writemask);
407 mask = LLVMBuildAnd(bld->builder, mask, writemask, "");
408 /* res = (res & mask) | (stencilVals & ~mask) */
409- res = lp_build_select_bitwise(bld, writemask, res, stencilVals);
410+ res = lp_build_select_bitwise(bld, mask, res, stencilVals);
411 }
412 else {
413 /* res = mask ? res : stencilVals */
414diff --git a/src/gallium/drivers/r300/r300_chipset.c b/src/gallium/drivers/r300/r300_chipset.c
415index 48c2409..583e981 100644
416--- a/src/gallium/drivers/r300/r300_chipset.c
417+++ b/src/gallium/drivers/r300/r300_chipset.c
418@@ -424,4 +424,5 @@ void r300_parse_chipset(struct r300_capabilities* caps)
419 }
420
421 caps->is_rv350 = caps->family >= CHIP_FAMILY_RV350;
422+ caps->dxtc_swizzle = caps->is_r400 || caps->is_r500;
423 }
424diff --git a/src/gallium/drivers/r300/r300_chipset.h b/src/gallium/drivers/r300/r300_chipset.h
425index e7ca642..7ea4175 100644
426--- a/src/gallium/drivers/r300/r300_chipset.h
427+++ b/src/gallium/drivers/r300/r300_chipset.h
428@@ -79,6 +79,8 @@ struct r300_capabilities {
429 boolean is_r500;
430 /* Whether or not the second pixel pipe is accessed with the high bit */
431 boolean high_second_pipe;
432+ /* DXTC texture swizzling. */
433+ boolean dxtc_swizzle;
434 };
435
436 /* Enumerations for legibility and telling which card we're running on. */
437diff --git a/src/gallium/drivers/r300/r300_context.c b/src/gallium/drivers/r300/r300_context.c
438index 624dadd..46504f5 100644
439--- a/src/gallium/drivers/r300/r300_context.c
440+++ b/src/gallium/drivers/r300/r300_context.c
441@@ -79,6 +79,9 @@ static void r300_release_referenced_objects(struct r300_context *r300)
442 NULL);
443 }
444
445+ /* The dummy VBO. */
446+ pipe_resource_reference(&r300->dummy_vb, NULL);
447+
448 /* The SWTCL VBO. */
449 pipe_resource_reference(&r300->vbo, NULL);
450
451@@ -488,6 +491,7 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
452 rtempl.target = PIPE_TEXTURE_2D;
453 rtempl.format = PIPE_FORMAT_I8_UNORM;
454 rtempl.bind = PIPE_BIND_SAMPLER_VIEW;
455+ rtempl.usage = PIPE_USAGE_IMMUTABLE;
456 rtempl.width0 = 1;
457 rtempl.height0 = 1;
458 rtempl.depth0 = 1;
459@@ -501,6 +505,19 @@ struct pipe_context* r300_create_context(struct pipe_screen* screen,
460 pipe_resource_reference(&tex, NULL);
461 }
462
463+ {
464+ struct pipe_resource vb = {};
465+ vb.target = PIPE_BUFFER;
466+ vb.format = PIPE_FORMAT_R8_UNORM;
467+ vb.bind = PIPE_BIND_VERTEX_BUFFER;
468+ vb.usage = PIPE_USAGE_IMMUTABLE;
469+ vb.width0 = sizeof(float) * 16;
470+ vb.height0 = 1;
471+ vb.depth0 = 1;
472+
473+ r300->dummy_vb = screen->resource_create(screen, &vb);
474+ }
475+
476 return &r300->context;
477
478 fail:
479diff --git a/src/gallium/drivers/r300/r300_context.h b/src/gallium/drivers/r300/r300_context.h
480index 8f4e2de..743e9da 100644
481--- a/src/gallium/drivers/r300/r300_context.h
482+++ b/src/gallium/drivers/r300/r300_context.h
483@@ -470,6 +470,10 @@ struct r300_context {
484 * dummy texture there. */
485 struct r300_sampler_view *texkill_sampler;
486
487+ /* When no vertex buffer is set, this one is used instead to prevent
488+ * hardlocks. */
489+ struct pipe_resource *dummy_vb;
490+
491 /* The currently active query. */
492 struct r300_query *query_current;
493 /* The saved query for blitter operations. */
494diff --git a/src/gallium/drivers/r300/r300_reg.h b/src/gallium/drivers/r300/r300_reg.h
495index 6bea783..788c513 100644
496--- a/src/gallium/drivers/r300/r300_reg.h
497+++ b/src/gallium/drivers/r300/r300_reg.h
498@@ -1520,11 +1520,11 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
499 # define R300_TX_TRI_PERF_3_8 (3<<15)
500 # define R300_ANISO_THRESHOLD_MASK (7<<17)
501
502+# define R400_DXTC_SWIZZLE_ENABLE (1<<21)
503 # define R500_MACRO_SWITCH (1<<22)
504 # define R500_TX_MAX_ANISO(x) ((x) << 23)
505 # define R500_TX_MAX_ANISO_MASK (63 << 23)
506 # define R500_TX_ANISO_HIGH_QUALITY (1 << 30)
507-
508 # define R500_BORDER_FIX (1<<31)
509
510 #define R300_TX_FORMAT0_0 0x4480
511diff --git a/src/gallium/drivers/r300/r300_render.c b/src/gallium/drivers/r300/r300_render.c
512index 2f00c87..7a3eb09 100644
513--- a/src/gallium/drivers/r300/r300_render.c
514+++ b/src/gallium/drivers/r300/r300_render.c
515@@ -676,9 +676,6 @@ static void r300_draw_vbo(struct pipe_context* pipe,
516 {
517 struct r300_context* r300 = r300_context(pipe);
518
519- if (!r300->velems->count || !r300->vertex_buffer_count)
520- return;
521-
522 if (info->indexed && r300->index_buffer.buffer) {
523 unsigned offset;
524
525diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c
526index 7f41ff0..c349e7f 100644
527--- a/src/gallium/drivers/r300/r300_screen.c
528+++ b/src/gallium/drivers/r300/r300_screen.c
529@@ -114,8 +114,9 @@ static int r300_get_param(struct pipe_screen* pscreen, enum pipe_cap param)
530 case PIPE_CAP_TEXTURE_MIRROR_CLAMP:
531 case PIPE_CAP_TEXTURE_MIRROR_REPEAT:
532 case PIPE_CAP_BLEND_EQUATION_SEPARATE:
533- case PIPE_CAP_TEXTURE_SWIZZLE:
534 return 1;
535+ case PIPE_CAP_TEXTURE_SWIZZLE:
536+ return util_format_s3tc_enabled ? r300screen->caps.dxtc_swizzle : 1;
537
538 /* Unsupported features (boolean caps). */
539 case PIPE_CAP_TIMER_QUERY:
540diff --git a/src/gallium/drivers/r300/r300_state.c b/src/gallium/drivers/r300/r300_state.c
541index 53c1657..7779766 100644
542--- a/src/gallium/drivers/r300/r300_state.c
543+++ b/src/gallium/drivers/r300/r300_state.c
544@@ -1363,6 +1363,7 @@ r300_create_sampler_view(struct pipe_context *pipe,
545 struct r300_sampler_view *view = CALLOC_STRUCT(r300_sampler_view);
546 struct r300_texture *tex = r300_texture(texture);
547 boolean is_r500 = r300_screen(pipe->screen)->caps.is_r500;
548+ boolean dxtc_swizzle = r300_screen(pipe->screen)->caps.dxtc_swizzle;
549
550 if (view) {
551 view->base = *templ;
552@@ -1379,7 +1380,8 @@ r300_create_sampler_view(struct pipe_context *pipe,
553 view->format = tex->tx_format;
554 view->format.format1 |= r300_translate_texformat(templ->format,
555 view->swizzle,
556- is_r500);
557+ is_r500,
558+ dxtc_swizzle);
559 if (is_r500) {
560 view->format.format2 |= r500_tx_format_msb_bit(templ->format);
561 }
562@@ -1464,6 +1466,15 @@ static void r300_set_vertex_buffers(struct pipe_context* pipe,
563 struct pipe_vertex_buffer *vbo;
564 unsigned i, max_index = (1 << 24) - 1;
565 boolean any_user_buffer = FALSE;
566+ struct pipe_vertex_buffer dummy_vb = {0};
567+
568+ /* There must be at least one vertex buffer set, otherwise it locks up. */
569+ if (!count) {
570+ dummy_vb.buffer = r300->dummy_vb;
571+ dummy_vb.max_index = r300->dummy_vb->width0 / 4;
572+ buffers = &dummy_vb;
573+ count = 1;
574+ }
575
576 if (count == r300->vertex_buffer_count &&
577 memcmp(r300->vertex_buffer, buffers,
578@@ -1617,6 +1628,14 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
579 struct r300_vertex_element_state *velems;
580 unsigned i;
581 enum pipe_format *format;
582+ struct pipe_vertex_element dummy_attrib = {0};
583+
584+ /* R300 Programmable Stream Control (PSC) doesn't support 0 vertex elements. */
585+ if (!count) {
586+ dummy_attrib.src_format = PIPE_FORMAT_R8G8B8A8_UNORM;
587+ attribs = &dummy_attrib;
588+ count = 1;
589+ }
590
591 assert(count <= PIPE_MAX_ATTRIBS);
592 velems = CALLOC_STRUCT(r300_vertex_element_state);
593@@ -1683,7 +1702,8 @@ static void* r300_create_vertex_elements_state(struct pipe_context* pipe,
594 * swizzles are already set up.
595 * Also compute the vertex size. */
596 for (i = 0; i < count; i++) {
597- /* This is OK because we check for aligned strides too. */
598+ /* This is OK because we check for aligned strides too
599+ * elsewhere. */
600 velems->hw_format_size[i] =
601 align(util_format_get_blocksize(velems->hw_format[i]), 4);
602 velems->vertex_size_dwords += velems->hw_format_size[i] / 4;
603diff --git a/src/gallium/drivers/r300/r300_state_derived.c b/src/gallium/drivers/r300/r300_state_derived.c
604index 2613e70..9d8b6da 100644
605--- a/src/gallium/drivers/r300/r300_state_derived.c
606+++ b/src/gallium/drivers/r300/r300_state_derived.c
607@@ -25,6 +25,7 @@
608
609 #include "util/u_math.h"
610 #include "util/u_memory.h"
611+#include "util/u_pack_color.h"
612
613 #include "r300_context.h"
614 #include "r300_fs.h"
615@@ -568,55 +569,93 @@ static void r300_update_rs_block(struct r300_context *r300)
616 }
617
618 static uint32_t r300_get_border_color(enum pipe_format format,
619- const float border[4])
620+ const float border[4],
621+ boolean is_r500)
622 {
623 const struct util_format_description *desc;
624- float border_swizzled[4] = {
625- border[2],
626- border[1],
627- border[0],
628- border[3]
629- };
630- uint32_t r;
631+ float border_swizzled[4] = {0};
632+ unsigned i;
633+ union util_color uc = {0};
634
635 desc = util_format_description(format);
636
637- /* We don't use util_pack_format because it does not handle the formats
638- * we want, e.g. R4G4B4A4 is non-existent in Gallium. */
639+ /* Do depth formats first. */
640+ if (util_format_is_depth_or_stencil(format)) {
641+ switch (format) {
642+ case PIPE_FORMAT_Z16_UNORM:
643+ return util_pack_z(PIPE_FORMAT_Z16_UNORM, border[0]);
644+ case PIPE_FORMAT_X8Z24_UNORM:
645+ case PIPE_FORMAT_S8_USCALED_Z24_UNORM:
646+ if (is_r500) {
647+ return util_pack_z(PIPE_FORMAT_X8Z24_UNORM, border[0]);
648+ } else {
649+ return util_pack_z(PIPE_FORMAT_Z16_UNORM, border[0]) << 16;
650+ }
651+ default:
652+ assert(0);
653+ return 0;
654+ }
655+ }
656+
657+ /* Apply inverse swizzle of the format. */
658+ for (i = 0; i < 4; i++) {
659+ switch (desc->swizzle[i]) {
660+ case UTIL_FORMAT_SWIZZLE_X:
661+ border_swizzled[2] = border[i];
662+ break;
663+ case UTIL_FORMAT_SWIZZLE_Y:
664+ border_swizzled[1] = border[i];
665+ break;
666+ case UTIL_FORMAT_SWIZZLE_Z:
667+ border_swizzled[0] = border[i];
668+ break;
669+ case UTIL_FORMAT_SWIZZLE_W:
670+ border_swizzled[3] = border[i];
671+ break;
672+ }
673+ }
674+
675+ /* Compressed formats. */
676+ if (util_format_is_compressed(format)) {
677+ util_pack_color(border_swizzled, PIPE_FORMAT_R8G8B8A8_UNORM, &uc);
678+ return uc.ui;
679+ }
680+
681 switch (desc->channel[0].size) {
682 case 4:
683- r = ((float_to_ubyte(border_swizzled[0]) & 0xf0) >> 4) |
684- ((float_to_ubyte(border_swizzled[1]) & 0xf0) << 0) |
685- ((float_to_ubyte(border_swizzled[2]) & 0xf0) << 4) |
686- ((float_to_ubyte(border_swizzled[3]) & 0xf0) << 8);
687+ util_pack_color(border_swizzled, PIPE_FORMAT_B4G4R4A4_UNORM, &uc);
688 break;
689
690 case 5:
691 if (desc->channel[1].size == 5) {
692- r = ((float_to_ubyte(border_swizzled[0]) & 0xf8) >> 3) |
693- ((float_to_ubyte(border_swizzled[1]) & 0xf8) << 2) |
694- ((float_to_ubyte(border_swizzled[2]) & 0xf8) << 7) |
695- ((float_to_ubyte(border_swizzled[3]) & 0x80) << 8);
696+ util_pack_color(border_swizzled, PIPE_FORMAT_B5G5R5A1_UNORM, &uc);
697 } else if (desc->channel[1].size == 6) {
698- r = ((float_to_ubyte(border_swizzled[0]) & 0xf8) >> 3) |
699- ((float_to_ubyte(border_swizzled[1]) & 0xfc) << 3) |
700- ((float_to_ubyte(border_swizzled[2]) & 0xf8) << 8);
701+ util_pack_color(border_swizzled, PIPE_FORMAT_B5G6R5_UNORM, &uc);
702 } else {
703 assert(0);
704 }
705 break;
706
707 default:
708- /* I think the fat formats (16, 32) are specified
709- * as the 8-bit ones. I am not sure how compressed formats
710- * work here. */
711- r = ((float_to_ubyte(border_swizzled[0]) & 0xff) << 0) |
712- ((float_to_ubyte(border_swizzled[1]) & 0xff) << 8) |
713- ((float_to_ubyte(border_swizzled[2]) & 0xff) << 16) |
714- ((float_to_ubyte(border_swizzled[3]) & 0xff) << 24);
715+ case 8:
716+ util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
717+ break;
718+
719+ case 10:
720+ util_pack_color(border_swizzled, PIPE_FORMAT_B10G10R10A2_UNORM, &uc);
721+ break;
722+
723+ case 16:
724+ if (desc->nr_channels <= 2) {
725+ border_swizzled[0] = border_swizzled[2];
726+ util_pack_color(border_swizzled, PIPE_FORMAT_R16G16_UNORM, &uc);
727+ } else {
728+ util_pack_color(border_swizzled, PIPE_FORMAT_B8G8R8A8_UNORM, &uc);
729+ }
730+ break;
731 }
732
733- return r;
734+ return uc.ui;
735 }
736
737 static void r300_merge_textures_and_samplers(struct r300_context* r300)
738@@ -655,7 +694,8 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
739 /* Set the border color. */
740 texstate->border_color =
741 r300_get_border_color(view->base.format,
742- sampler->state.border_color);
743+ sampler->state.border_color,
744+ r300->screen->caps.is_r500);
745
746 /* determine min/max levels */
747 max_level = MIN3(sampler->max_lod + view->base.first_level,
748@@ -701,13 +741,18 @@ static void r300_merge_textures_and_samplers(struct r300_context* r300)
749 if (sampler->state.compare_mode == PIPE_TEX_COMPARE_NONE) {
750 texstate->format.format1 |=
751 r300_get_swizzle_combined(depth_swizzle,
752- view->swizzle);
753+ view->swizzle, FALSE);
754 } else {
755 texstate->format.format1 |=
756- r300_get_swizzle_combined(depth_swizzle, 0);
757+ r300_get_swizzle_combined(depth_swizzle, 0, FALSE);
758 }
759 }
760
761+ if (r300->screen->caps.dxtc_swizzle &&
762+ util_format_is_compressed(tex->desc.b.b.format)) {
763+ texstate->filter1 |= R400_DXTC_SWIZZLE_ENABLE;
764+ }
765+
766 /* to emulate 1D textures through 2D ones correctly */
767 if (tex->desc.b.b.target == PIPE_TEXTURE_1D) {
768 texstate->filter0 &= ~R300_TX_WRAP_T_MASK;
769diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
770index 34105aa..7e2f69a 100644
771--- a/src/gallium/drivers/r300/r300_texture.c
772+++ b/src/gallium/drivers/r300/r300_texture.c
773@@ -40,7 +40,8 @@
774 #include "pipe/p_screen.h"
775
776 unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format,
777- const unsigned char *swizzle_view)
778+ const unsigned char *swizzle_view,
779+ boolean dxtc_swizzle)
780 {
781 unsigned i;
782 unsigned char swizzle[4];
783@@ -51,10 +52,10 @@ unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format,
784 R300_TX_FORMAT_B_SHIFT,
785 R300_TX_FORMAT_A_SHIFT
786 };
787- const uint32_t swizzle_bit[4] = {
788- R300_TX_FORMAT_X,
789+ uint32_t swizzle_bit[4] = {
790+ dxtc_swizzle ? R300_TX_FORMAT_Z : R300_TX_FORMAT_X,
791 R300_TX_FORMAT_Y,
792- R300_TX_FORMAT_Z,
793+ dxtc_swizzle ? R300_TX_FORMAT_X : R300_TX_FORMAT_Z,
794 R300_TX_FORMAT_W
795 };
796
797@@ -107,7 +108,8 @@ unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format,
798 * makes available X, Y, Z, W, ZERO, and ONE for swizzling. */
799 uint32_t r300_translate_texformat(enum pipe_format format,
800 const unsigned char *swizzle_view,
801- boolean is_r500)
802+ boolean is_r500,
803+ boolean dxtc_swizzle)
804 {
805 uint32_t result = 0;
806 const struct util_format_description *desc;
807@@ -169,7 +171,8 @@ uint32_t r300_translate_texformat(enum pipe_format format,
808 }
809 }
810
811- result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view);
812+ result |= r300_get_swizzle_combined(desc->swizzle, swizzle_view,
813+ util_format_is_compressed(format) && dxtc_swizzle);
814
815 /* S3TC formats. */
816 if (desc->layout == UTIL_FORMAT_LAYOUT_S3TC) {
817@@ -538,7 +541,7 @@ boolean r300_is_zs_format_supported(enum pipe_format format)
818
819 boolean r300_is_sampler_format_supported(enum pipe_format format)
820 {
821- return r300_translate_texformat(format, 0, TRUE) != ~0;
822+ return r300_translate_texformat(format, 0, TRUE, FALSE) != ~0;
823 }
824
825 void r300_texture_setup_format_state(struct r300_screen *screen,
826diff --git a/src/gallium/drivers/r300/r300_texture.h b/src/gallium/drivers/r300/r300_texture.h
827index c4588a0..fe9d351 100644
828--- a/src/gallium/drivers/r300/r300_texture.h
829+++ b/src/gallium/drivers/r300/r300_texture.h
830@@ -35,11 +35,13 @@ struct r300_texture;
831 struct r300_screen;
832
833 unsigned r300_get_swizzle_combined(const unsigned char *swizzle_format,
834- const unsigned char *swizzle_view);
835+ const unsigned char *swizzle_view,
836+ boolean dxtc_swizzle);
837
838 uint32_t r300_translate_texformat(enum pipe_format format,
839 const unsigned char *swizzle_view,
840- boolean is_r500);
841+ boolean is_r500,
842+ boolean dxtc_swizzle);
843
844 uint32_t r500_tx_format_msb_bit(enum pipe_format format);
845
846diff --git a/src/gallium/drivers/r300/r300_texture_desc.c b/src/gallium/drivers/r300/r300_texture_desc.c
847index e2d01cd..ff6d2b2 100644
848--- a/src/gallium/drivers/r300/r300_texture_desc.c
849+++ b/src/gallium/drivers/r300/r300_texture_desc.c
850@@ -44,7 +44,7 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
851 {{ 32, 1}, { 8, 4}, { 0, 0}}, /* 8 bits per pixel */
852 {{ 16, 1}, { 8, 2}, { 4, 4}}, /* 16 bits per pixel */
853 {{ 8, 1}, { 4, 2}, { 0, 0}}, /* 32 bits per pixel */
854- {{ 4, 1}, { 0, 0}, { 2, 2}}, /* 64 bits per pixel */
855+ {{ 4, 1}, { 2, 2}, { 0, 0}}, /* 64 bits per pixel */
856 {{ 2, 1}, { 0, 0}, { 0, 0}} /* 128 bits per pixel */
857 },
858 {
859@@ -53,7 +53,7 @@ unsigned r300_get_pixel_alignment(enum pipe_format format,
860 {{256, 8}, {64, 32}, { 0, 0}}, /* 8 bits per pixel */
861 {{128, 8}, {64, 16}, {32, 32}}, /* 16 bits per pixel */
862 {{ 64, 8}, {32, 16}, { 0, 0}}, /* 32 bits per pixel */
863- {{ 32, 8}, { 0, 0}, {16, 16}}, /* 64 bits per pixel */
864+ {{ 32, 8}, {16, 16}, { 0, 0}}, /* 64 bits per pixel */
865 {{ 16, 8}, { 0, 0}, { 0, 0}} /* 128 bits per pixel */
866 }
867 };
868@@ -368,11 +368,11 @@ static void r300_setup_tiling(struct r300_screen *screen,
869 switch (util_format_get_blocksize(format)) {
870 case 1:
871 case 4:
872+ case 8:
873 desc->microtile = R300_BUFFER_TILED;
874 break;
875
876 case 2:
877- case 8:
878 if (rws->get_value(rws, R300_VID_SQUARE_TILING_SUPPORT)) {
879 desc->microtile = R300_BUFFER_SQUARETILED;
880 }
25bb03e4
AM
881diff --git a/src/gallium/state_trackers/egl/Makefile b/src/gallium/state_trackers/egl/Makefile
882index 8dbfc5b..8cfcef9 100644
883--- a/src/gallium/state_trackers/egl/Makefile
884+++ b/src/gallium/state_trackers/egl/Makefile
885@@ -17,7 +17,7 @@ x11_INCLUDES = \
886 -I$(TOP)/src/mapi \
887 -I$(TOP)/src/mesa \
888 $(X11_CFLAGS) \
889- $(shell pkg-config --cflags-only-I libdrm)
890+ $(shell pkg-config --cflags-only-I libdrm dri2proto)
891
892 x11_SOURCES = $(wildcard x11/*.c) \
893 $(TOP)/src/glx/dri2.c
9caf779f
AM
894diff --git a/src/gallium/state_trackers/egl/common/egl_g3d_api.c b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
895index c0164da..3bde397 100644
896--- a/src/gallium/state_trackers/egl/common/egl_g3d_api.c
897+++ b/src/gallium/state_trackers/egl/common/egl_g3d_api.c
898@@ -609,8 +609,10 @@ egl_g3d_wait_client(_EGLDriver *drv, _EGLDisplay *dpy, _EGLContext *ctx)
899
900 gctx->stctxi->flush(gctx->stctxi,
901 PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
902- screen->fence_finish(screen, fence, 0);
903- screen->fence_reference(screen, &fence, NULL);
904+ if (fence) {
905+ screen->fence_finish(screen, fence, 0);
906+ screen->fence_reference(screen, &fence, NULL);
907+ }
908
909 return EGL_TRUE;
910 }
25bb03e4
AM
911diff --git a/src/gallium/state_trackers/egl/x11/native_x11.h b/src/gallium/state_trackers/egl/x11/native_x11.h
912index 0b47837..8945117 100644
913--- a/src/gallium/state_trackers/egl/x11/native_x11.h
914+++ b/src/gallium/state_trackers/egl/x11/native_x11.h
915@@ -27,6 +27,7 @@
916 #define _NATIVE_X11_H_
917
918 #include "common/native.h"
919+#include <X11/Xlib.h>
920
921 struct native_display *
922 x11_create_ximage_display(Display *dpy,
c3c893c6
AM
923diff --git a/src/gallium/state_trackers/vega/api_context.c b/src/gallium/state_trackers/vega/api_context.c
924index 0d04d8e..d6bbda5 100644
925--- a/src/gallium/state_trackers/vega/api_context.c
926+++ b/src/gallium/state_trackers/vega/api_context.c
927@@ -73,7 +73,8 @@ void vegaFinish(void)
928 pipe = ctx->pipe;
929
930 pipe->flush(pipe, PIPE_FLUSH_RENDER_CACHE | PIPE_FLUSH_FRAME, &fence);
931-
932- pipe->screen->fence_finish(pipe->screen, fence, 0);
933- pipe->screen->fence_reference(pipe->screen, &fence, NULL);
934+ if (fence) {
935+ pipe->screen->fence_finish(pipe->screen, fence, 0);
936+ pipe->screen->fence_reference(pipe->screen, &fence, NULL);
937+ }
938 }
9caf779f
AM
939diff --git a/src/gallium/state_trackers/vega/vg_manager.c b/src/gallium/state_trackers/vega/vg_manager.c
940index e799674..232deef 100644
941--- a/src/gallium/state_trackers/vega/vg_manager.c
942+++ b/src/gallium/state_trackers/vega/vg_manager.c
943@@ -352,7 +352,7 @@ vg_api_create_context(struct st_api *stapi, struct st_manager *smapi,
944 return NULL;
945
946 /* only 1.0 is supported */
947- if (attribs->major != 1 || attribs->minor > 0)
948+ if (attribs->major > 1 || (attribs->major == 1 && attribs->minor > 0))
949 return NULL;
950
951 pipe = smapi->screen->context_create(smapi->screen, NULL);
7959a51a
AM
952diff --git a/src/gallium/state_trackers/xorg/Makefile b/src/gallium/state_trackers/xorg/Makefile
953index cb2c3ae..7a44d28 100644
954--- a/src/gallium/state_trackers/xorg/Makefile
955+++ b/src/gallium/state_trackers/xorg/Makefile
956@@ -10,7 +10,7 @@ LIBRARY_INCLUDES = \
957 $(shell pkg-config libkms --atleast-version=1.0 \
958 && echo "-DHAVE_LIBKMS") \
959 $(shell pkg-config libkms --silence-errors --cflags-only-I) \
960- $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto) \
961+ $(shell pkg-config --cflags-only-I pixman-1 xorg-server libdrm xproto dri2proto) \
962 -I$(TOP)/src/gallium/include \
963 -I$(TOP)/src/gallium/auxiliary \
964 -I$(TOP)/include \
9caf779f 965diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c
7959a51a 966index 26a907f..80af82d 100644
9caf779f
AM
967--- a/src/gallium/state_trackers/xorg/xorg_crtc.c
968+++ b/src/gallium/state_trackers/xorg/xorg_crtc.c
969@@ -234,6 +234,10 @@ crtc_load_cursor_argb_ga3d(xf86CrtcPtr crtc, CARD32 * image)
970 64, 64, (void*)image, 64 * 4, 0, 0);
971 ms->ctx->transfer_unmap(ms->ctx, transfer);
972 ms->ctx->transfer_destroy(ms->ctx, transfer);
973+
974+ if (crtc->cursor_shown)
975+ drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id,
976+ crtcp->cursor_handle, 64, 64);
977 }
978
979 #if HAVE_LIBKMS
980@@ -271,6 +275,10 @@ crtc_load_cursor_argb_kms(xf86CrtcPtr crtc, CARD32 * image)
981 memcpy(ptr, image, 64*64*4);
982 kms_bo_unmap(crtcp->cursor_bo);
983
984+ if (crtc->cursor_shown)
985+ drmModeSetCursor(ms->fd, crtcp->drm_crtc->crtc_id,
986+ crtcp->cursor_handle, 64, 64);
987+
988 return;
989
990 err_bo_destroy:
7959a51a
AM
991@@ -353,7 +361,7 @@ crtc_destroy(xf86CrtcPtr crtc)
992
993 drmModeFreeCrtc(crtcp->drm_crtc);
994
995- xfree(crtcp);
996+ free(crtcp);
997 crtc->driver_private = NULL;
998 }
999
1000@@ -401,7 +409,7 @@ xorg_crtc_init(ScrnInfoPtr pScrn)
1001 if (crtc == NULL)
1002 goto out;
1003
1004- crtcp = xcalloc(1, sizeof(struct crtc_private));
1005+ crtcp = calloc(1, sizeof(struct crtc_private));
1006 if (!crtcp) {
1007 xf86CrtcDestroy(crtc);
1008 goto out;
1009diff --git a/src/gallium/state_trackers/xorg/xorg_dri2.c b/src/gallium/state_trackers/xorg/xorg_dri2.c
1010index 704aed6..b723a8e 100644
1011--- a/src/gallium/state_trackers/xorg/xorg_dri2.c
1012+++ b/src/gallium/state_trackers/xorg/xorg_dri2.c
1013@@ -201,11 +201,11 @@ dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment, unsigned int form
1014 DRI2Buffer2Ptr buffer;
1015 BufferPrivatePtr private;
1016
1017- buffer = xcalloc(1, sizeof *buffer);
1018+ buffer = calloc(1, sizeof *buffer);
1019 if (!buffer)
1020 return NULL;
1021
1022- private = xcalloc(1, sizeof *private);
1023+ private = calloc(1, sizeof *private);
1024 if (!private) {
1025 goto fail;
1026 }
1027@@ -217,9 +217,9 @@ dri2_create_buffer(DrawablePtr pDraw, unsigned int attachment, unsigned int form
1028 if (dri2_do_create_buffer(pDraw, (DRI2BufferPtr)buffer, format))
1029 return buffer;
1030
1031- xfree(private);
1032+ free(private);
1033 fail:
1034- xfree(buffer);
1035+ free(buffer);
1036 return NULL;
1037 }
1038
1039@@ -229,8 +229,8 @@ dri2_destroy_buffer(DrawablePtr pDraw, DRI2Buffer2Ptr buffer)
1040 /* So far it is safe to downcast a DRI2Buffer2Ptr to DRI2BufferPtr */
1041 dri2_do_destroy_buffer(pDraw, (DRI2BufferPtr)buffer);
1042
1043- xfree(buffer->driverPrivate);
1044- xfree(buffer);
1045+ free(buffer->driverPrivate);
1046+ free(buffer);
1047 }
1048
1049 #endif /* DRI2INFOREC_VERSION >= 2 */
1050@@ -244,11 +244,11 @@ dri2_create_buffers(DrawablePtr pDraw, unsigned int *attachments, int count)
1051 DRI2BufferPtr buffers;
1052 int i;
1053
1054- buffers = xcalloc(count, sizeof *buffers);
1055+ buffers = calloc(count, sizeof *buffers);
1056 if (!buffers)
1057 goto fail_buffers;
1058
1059- privates = xcalloc(count, sizeof *privates);
1060+ privates = calloc(count, sizeof *privates);
1061 if (!privates)
1062 goto fail_privates;
1063
1064@@ -263,9 +263,9 @@ dri2_create_buffers(DrawablePtr pDraw, unsigned int *attachments, int count)
1065 return buffers;
1066
1067 fail:
1068- xfree(privates);
1069+ free(privates);
1070 fail_privates:
1071- xfree(buffers);
1072+ free(buffers);
1073 fail_buffers:
1074 return NULL;
1075 }
1076@@ -280,8 +280,8 @@ dri2_destroy_buffers(DrawablePtr pDraw, DRI2BufferPtr buffers, int count)
1077 }
1078
1079 if (buffers) {
1080- xfree(buffers[0].driverPrivate);
1081- xfree(buffers);
1082+ free(buffers[0].driverPrivate);
1083+ free(buffers);
1084 }
1085 }
1086
9caf779f 1087diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c
7959a51a 1088index e10ff2f..1ec772d 100644
9caf779f
AM
1089--- a/src/gallium/state_trackers/xorg/xorg_driver.c
1090+++ b/src/gallium/state_trackers/xorg/xorg_driver.c
7959a51a
AM
1091@@ -45,6 +45,7 @@
1092 #include "miscstruct.h"
1093 #include "dixstruct.h"
1094 #include "xf86xv.h"
1095+#include "xorgVersion.h"
1096 #ifndef XSERVER_LIBPCIACCESS
1097 #error "libpciaccess needed"
1098 #endif
1099@@ -122,7 +123,7 @@ xorg_tracker_set_functions(ScrnInfoPtr scrn)
1100 Bool
1101 xorg_tracker_have_modesetting(ScrnInfoPtr pScrn, struct pci_device *device)
1102 {
1103- char *BusID = xalloc(64);
1104+ char *BusID = malloc(64);
1105 sprintf(BusID, "pci:%04x:%02x:%02x.%d",
1106 device->domain, device->bus,
1107 device->dev, device->func);
1108@@ -130,14 +131,14 @@ xorg_tracker_have_modesetting(ScrnInfoPtr pScrn, struct pci_device *device)
1109 if (drmCheckModesettingSupported(BusID)) {
1110 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
1111 "Drm modesetting not supported %s\n", BusID);
1112- xfree(BusID);
1113+ free(BusID);
1114 return FALSE;
1115 }
1116
1117 xf86DrvMsgVerb(pScrn->scrnIndex, X_INFO, 0,
1118 "Drm modesetting supported on %s\n", BusID);
1119
1120- xfree(BusID);
1121+ free(BusID);
1122 return TRUE;
1123 }
1124
1125@@ -174,7 +175,7 @@ drv_free_rec(ScrnInfoPtr pScrn)
1126 if (!pScrn->driverPrivate)
1127 return;
1128
1129- xfree(pScrn->driverPrivate);
1130+ free(pScrn->driverPrivate);
1131
1132 pScrn->driverPrivate = NULL;
1133 }
1134@@ -274,7 +275,7 @@ drv_init_drm(ScrnInfoPtr pScrn)
1135 if (ms->fd < 0) {
1136 char *BusID;
1137
1138- BusID = xalloc(64);
1139+ BusID = malloc(64);
1140 sprintf(BusID, "PCI:%d:%d:%d",
1141 ((ms->PciInfo->domain << 8) | ms->PciInfo->bus),
1142 ms->PciInfo->dev, ms->PciInfo->func
1143@@ -283,7 +284,7 @@ drv_init_drm(ScrnInfoPtr pScrn)
1144
1145 ms->fd = drmOpen(driver_descriptor.driver_name, BusID);
1146 ms->isMaster = TRUE;
1147- xfree(BusID);
1148+ free(BusID);
1149
1150 if (ms->fd >= 0)
1151 return TRUE;
1152@@ -369,6 +370,7 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags)
9caf779f
AM
1153 ms = modesettingPTR(pScrn);
1154 ms->pEnt = pEnt;
1155 ms->cust = cust;
1156+ ms->fb_id = -1;
1157
1158 pScrn->displayWidth = 640; /* default it */
1159
7959a51a 1160@@ -402,19 +404,6 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags)
9caf779f
AM
1161 if (!drv_init_drm(pScrn))
1162 return FALSE;
1163
1164- use3D = cust ? !cust->no_3d : TRUE;
1165- ms->from_3D = xf86GetOptValBool(ms->Options, OPTION_3D_ACCEL,
1166- &use3D) ?
1167- X_CONFIG : X_PROBED;
1168-
1169- ms->no3D = !use3D;
1170-
1171- if (!drv_init_resource_management(pScrn)) {
1172- xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Could not init "
1173- "Gallium3D or libKMS.");
1174- return FALSE;
1175- }
1176-
1177 pScrn->monitor = pScrn->confScreen->monitor;
1178 pScrn->progClock = TRUE;
1179 pScrn->rgbBits = 8;
7959a51a
AM
1180@@ -444,11 +433,24 @@ drv_pre_init(ScrnInfoPtr pScrn, int flags)
1181
1182 /* Process the options */
1183 xf86CollectOptions(pScrn, NULL);
1184- if (!(ms->Options = xalloc(sizeof(drv_options))))
1185+ if (!(ms->Options = malloc(sizeof(drv_options))))
1186 return FALSE;
9caf779f
AM
1187 memcpy(ms->Options, drv_options, sizeof(drv_options));
1188 xf86ProcessOptions(pScrn->scrnIndex, pScrn->options, ms->Options);
1189
1190+ use3D = cust ? !cust->no_3d : TRUE;
1191+ ms->from_3D = xf86GetOptValBool(ms->Options, OPTION_3D_ACCEL,
1192+ &use3D) ?
1193+ X_CONFIG : X_PROBED;
1194+
1195+ ms->no3D = !use3D;
1196+
1197+ if (!drv_init_resource_management(pScrn)) {
1198+ xf86DrvMsg(pScrn->scrnIndex, X_ERROR, "Could not init "
1199+ "Gallium3D or libKMS.");
1200+ return FALSE;
1201+ }
1202+
1203 /* Allocate an xf86CrtcConfig */
1204 xf86CrtcConfigInit(pScrn, &crtc_config_funcs);
1205 xf86_config = XF86_CRTC_CONFIG_PTR(pScrn);
7959a51a 1206@@ -791,7 +793,9 @@ drv_screen_init(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
9caf779f
AM
1207 if (!ms->SWCursor)
1208 xf86_cursors_init(pScreen, 64, 64,
1209 HARDWARE_CURSOR_SOURCE_MASK_INTERLEAVE_64 |
1210- HARDWARE_CURSOR_ARGB);
1211+ HARDWARE_CURSOR_ARGB |
1212+ ((cust && cust->unhidden_hw_cursor_update) ?
1213+ HARDWARE_CURSOR_UPDATE_UNHIDDEN : 0));
1214
1215 /* Must force it before EnterVT, so we are in control of VT and
1216 * later memory should be bound when allocating, e.g rotate_mem */
7959a51a 1217@@ -862,8 +866,10 @@ drv_leave_vt(int scrnIndex, int flags)
9caf779f
AM
1218 }
1219 }
1220
1221- drmModeRmFB(ms->fd, ms->fb_id);
1222- ms->fb_id = -1;
1223+ if (ms->fb_id != -1) {
1224+ drmModeRmFB(ms->fd, ms->fb_id);
1225+ ms->fb_id = -1;
1226+ }
1227
1228 /* idle hardware */
1229 if (!ms->kms)
7959a51a 1230@@ -944,7 +950,6 @@ drv_close_screen(int scrnIndex, ScreenPtr pScreen)
9caf779f
AM
1231 }
1232 #endif
1233
1234- drmModeRmFB(ms->fd, ms->fb_id);
1235 ms->destroy_front_buffer(pScrn);
1236
1237 if (ms->exa)
7959a51a
AM
1238@@ -1178,6 +1183,8 @@ drv_bind_front_buffer_kms(ScrnInfoPtr pScrn)
1239 stride,
1240 ptr);
1241
1242+#if (XORG_VERSION_CURRENT < XORG_VERSION_NUMERIC(1, 9, 99, 1, 0))
1243+
1244 /* This a hack to work around EnableDisableFBAccess setting the pointer
1245 * the real fix would be to replace pScrn->EnableDisableFBAccess hook
1246 * and set the rootPixmap->devPrivate.ptr to something valid before that.
1247@@ -1187,6 +1194,8 @@ drv_bind_front_buffer_kms(ScrnInfoPtr pScrn)
1248 */
1249 pScrn->pixmapPrivate.ptr = ptr;
1250
1251+#endif
1252+
1253 return TRUE;
1254
1255 err_destroy:
1256diff --git a/src/gallium/state_trackers/xorg/xorg_exa.c b/src/gallium/state_trackers/xorg/xorg_exa.c
1257index 6b2c80f..0e5693d 100644
1258--- a/src/gallium/state_trackers/xorg/xorg_exa.c
1259+++ b/src/gallium/state_trackers/xorg/xorg_exa.c
1260@@ -720,7 +720,7 @@ ExaCreatePixmap(ScreenPtr pScreen, int size, int align)
1261 {
1262 struct exa_pixmap_priv *priv;
1263
1264- priv = xcalloc(1, sizeof(struct exa_pixmap_priv));
1265+ priv = calloc(1, sizeof(struct exa_pixmap_priv));
1266 if (!priv)
1267 return NULL;
1268
1269@@ -737,7 +737,7 @@ ExaDestroyPixmap(ScreenPtr pScreen, void *dPriv)
1270
1271 pipe_resource_reference(&priv->tex, NULL);
1272
1273- xfree(priv);
1274+ free(priv);
1275 }
1276
1277 static Bool
1278@@ -975,7 +975,7 @@ xorg_exa_close(ScrnInfoPtr pScrn)
1279 ms->ctx = NULL;
1280
1281 exaDriverFini(pScrn->pScreen);
1282- xfree(exa);
1283+ free(exa);
1284 ms->exa = NULL;
1285 }
1286
1287@@ -987,7 +987,7 @@ xorg_exa_init(ScrnInfoPtr pScrn, Bool accel)
1288 ExaDriverPtr pExa;
1289 CustomizerPtr cust = ms->cust;
1290
1291- exa = xcalloc(1, sizeof(struct exa_context));
1292+ exa = calloc(1, sizeof(struct exa_context));
1293 if (!exa)
1294 return NULL;
1295
1296diff --git a/src/gallium/state_trackers/xorg/xorg_output.c b/src/gallium/state_trackers/xorg/xorg_output.c
1297index 61206ed..5555b51 100644
1298--- a/src/gallium/state_trackers/xorg/xorg_output.c
1299+++ b/src/gallium/state_trackers/xorg/xorg_output.c
1300@@ -128,7 +128,7 @@ output_get_modes(xf86OutputPtr output)
1301 for (i = 0; i < drm_connector->count_modes; i++) {
1302 drm_mode = &drm_connector->modes[i];
1303 if (drm_mode) {
1304- mode = xcalloc(1, sizeof(DisplayModeRec));
1305+ mode = calloc(1, sizeof(DisplayModeRec));
1306 if (!mode)
1307 continue;
1308 mode->Clock = drm_mode->clock;
1309@@ -195,7 +195,7 @@ output_destroy(xf86OutputPtr output)
1310 {
1311 struct output_private *priv = output->driver_private;
1312 drmModeFreeConnector(priv->drm_connector);
1313- xfree(priv);
1314+ free(priv);
1315 output->driver_private = NULL;
1316 }
1317
1318@@ -262,14 +262,14 @@ xorg_output_init(ScrnInfoPtr pScrn)
1319 drm_connector->connector_type_id);
1320
1321
1322- priv = xcalloc(sizeof(*priv), 1);
1323+ priv = calloc(sizeof(*priv), 1);
1324 if (!priv) {
1325 continue;
1326 }
1327
1328 output = xf86OutputCreate(pScrn, &output_funcs, name);
1329 if (!output) {
1330- xfree(priv);
1331+ free(priv);
1332 continue;
1333 }
1334
9caf779f
AM
1335diff --git a/src/gallium/state_trackers/xorg/xorg_tracker.h b/src/gallium/state_trackers/xorg/xorg_tracker.h
1336index be1a9fd..a3fb5e5 100644
1337--- a/src/gallium/state_trackers/xorg/xorg_tracker.h
1338+++ b/src/gallium/state_trackers/xorg/xorg_tracker.h
1339@@ -76,6 +76,7 @@ typedef struct _CustomizerRec
1340 Bool dirty_throttling;
1341 Bool swap_throttling;
1342 Bool no_3d;
1343+ Bool unhidden_hw_cursor_update;
1344 Bool (*winsys_pre_init) (struct _CustomizerRec *cust, int fd);
1345 Bool (*winsys_screen_init)(struct _CustomizerRec *cust);
1346 Bool (*winsys_screen_close)(struct _CustomizerRec *cust);
7959a51a
AM
1347diff --git a/src/gallium/state_trackers/xorg/xorg_xv.c b/src/gallium/state_trackers/xorg/xorg_xv.c
1348index f98bd93..f64959f 100644
1349--- a/src/gallium/state_trackers/xorg/xorg_xv.c
1350+++ b/src/gallium/state_trackers/xorg/xorg_xv.c
1351@@ -536,8 +536,10 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
1352 dst_surf = xorg_gpu_surface(pPriv->r->pipe->screen, dst);
1353 hdtv = ((src_w >= RES_720P_X) && (src_h >= RES_720P_Y));
1354
1355+#ifdef COMPOSITE
1356 REGION_TRANSLATE(pScrn->pScreen, dstRegion, -pPixmap->screen_x,
1357 -pPixmap->screen_y);
1358+#endif
1359
1360 dxo = dstRegion->extents.x1;
1361 dyo = dstRegion->extents.y1;
1362@@ -562,11 +564,16 @@ display_video(ScrnInfoPtr pScrn, struct xorg_xv_port_priv *pPriv, int id,
1363 int box_y2 = pbox->y2;
1364 float diff_x = (float)src_w / (float)dst_w;
1365 float diff_y = (float)src_h / (float)dst_h;
1366- float offset_x = box_x1 - dstX + pPixmap->screen_x;
1367- float offset_y = box_y1 - dstY + pPixmap->screen_y;
1368+ float offset_x = box_x1 - dstX;
1369+ float offset_y = box_y1 - dstY;
1370 float offset_w;
1371 float offset_h;
1372
1373+#ifdef COMPOSITE
1374+ offset_x += pPixmap->screen_x;
1375+ offset_y += pPixmap->screen_y;
1376+#endif
1377+
1378 x = box_x1;
1379 y = box_y1;
1380 w = box_x2 - box_x1;
25bb03e4
AM
1381diff --git a/src/gallium/targets/Makefile.dri b/src/gallium/targets/Makefile.dri
1382index 59961e9..3fb4cc6 100644
1383--- a/src/gallium/targets/Makefile.dri
1384+++ b/src/gallium/targets/Makefile.dri
1385@@ -80,7 +80,7 @@ $(LIBNAME): $(OBJECTS) $(MESA_MODULES) $(PIPE_DRIVERS) Makefile \
1386 $(OBJECTS) $(PIPE_DRIVERS) \
1387 -Wl,--start-group $(MESA_MODULES) -Wl,--end-group \
1388 $(DRI_LIB_DEPS) $(DRIVER_EXTRAS)
1389- $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS);
1390+ $(CXX) $(CFLAGS) -o $@.test $(TOP)/src/mesa/drivers/dri/common/dri_test.o $@.tmp $(DRI_LIB_DEPS) $(LDFLAGS);
1391 @rm -f $@.test
1392 mv -f $@.tmp $@
1393
7959a51a
AM
1394diff --git a/src/gallium/targets/Makefile.xorg b/src/gallium/targets/Makefile.xorg
1395index 762c905..87eedd7 100644
1396--- a/src/gallium/targets/Makefile.xorg
1397+++ b/src/gallium/targets/Makefile.xorg
1398@@ -29,7 +29,7 @@ INCLUDES = \
1399 LIBNAME_STAGING = $(TOP)/$(LIB_DIR)/gallium/$(TARGET)
1400
1401 ifeq ($(MESA_LLVM),1)
1402-LD = g++
1403+LD = $(CXX)
1404 LDFLAGS += $(LLVM_LDFLAGS)
1405 USE_CXX=1
1406 DRIVER_PIPES += $(TOP)/src/gallium/drivers/llvmpipe/libllvmpipe.a
1407@@ -42,7 +42,7 @@ endif
1408 default: depend $(TOP)/$(LIB_DIR)/gallium $(LIBNAME) $(LIBNAME_STAGING)
1409
1410 $(LIBNAME): $(OBJECTS) Makefile ../Makefile.xorg $(LIBS) $(DRIVER_PIPES)
1411- $(MKLIB) -noprefix -o $@ $(LDFLAGS) $(OBJECTS) $(DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $(DRIVER_LINKS)
1412+ $(MKLIB) -linker $(CC) -noprefix -o $@ $(LDFLAGS) $(OBJECTS) $(DRIVER_PIPES) $(GALLIUM_AUXILIARIES) $(DRIVER_LINKS)
1413
1414 depend: $(C_SOURCES) $(CPP_SOURCES) $(ASM_SOURCES) $(SYMLINKS) $(GENERATED_SOURCES)
1415 rm -f depend
25bb03e4
AM
1416diff --git a/src/gallium/targets/dri-vmwgfx/Makefile b/src/gallium/targets/dri-vmwgfx/Makefile
1417index 97c703b..38f7893 100644
1418--- a/src/gallium/targets/dri-vmwgfx/Makefile
1419+++ b/src/gallium/targets/dri-vmwgfx/Makefile
1420@@ -12,6 +12,7 @@ PIPE_DRIVERS = \
1421
1422 C_SOURCES = \
1423 target.c \
1424+ vmw_powf.c \
1425 $(COMMON_GALLIUM_SOURCES)
1426
1427 DRIVER_DEFINES = \
1428diff --git a/src/gallium/targets/dri-vmwgfx/vmw_powf.c b/src/gallium/targets/dri-vmwgfx/vmw_powf.c
1429new file mode 100644
1430index 0000000..ca5e39b
1431--- /dev/null
1432+++ b/src/gallium/targets/dri-vmwgfx/vmw_powf.c
1433@@ -0,0 +1,17 @@
1434+/**
1435+ * Powf may leave an unresolved symbol pointing to a libstdc++.so powf.
1436+ * However, not all libstdc++.so include this function, so optionally
1437+ * replace the powf function with calls to expf and logf.
1438+ */
1439+
1440+#ifdef VMW_RESOLVE_POWF
1441+
1442+extern float expf(float x);
1443+extern float logf(float x);
1444+extern float powf(float x, float y);
1445+
1446+float powf(float x, float y) {
1447+ return expf(logf(x)*y);
1448+}
1449+
1450+#endif
9caf779f
AM
1451diff --git a/src/gallium/targets/egl/Makefile b/src/gallium/targets/egl/Makefile
1452index 47c24ce..38e60db 100644
1453--- a/src/gallium/targets/egl/Makefile
1454+++ b/src/gallium/targets/egl/Makefile
1455@@ -24,7 +24,9 @@ common_CPPFLAGS := \
1456 -I$(TOP)/src/gallium/auxiliary \
1457 -I$(TOP)/src/gallium/drivers \
1458 -I$(TOP)/src/gallium/include \
1459- -I$(TOP)/src/gallium/winsys
1460+ -I$(TOP)/src/gallium/winsys \
1461+ $(LIBDRM_CFLAGS)
1462+
1463 common_SYS :=
1464 common_LIBS := \
1465 $(TOP)/src/gallium/drivers/identity/libidentity.a \
1466@@ -41,11 +43,11 @@ egl_SYS := -lm $(DLOPEN_LIBS) -L$(TOP)/$(LIB_DIR) -lEGL
1467 egl_LIBS := $(TOP)/src/gallium/state_trackers/egl/libegl.a
1468
1469 ifneq ($(findstring x11, $(EGL_PLATFORMS)),)
1470-egl_SYS += -lX11 -lXext -lXfixes
1471+egl_SYS += -lX11 -lXext -lXfixes $(LIBDRM_LIB)
1472 egl_LIBS += $(TOP)/src/gallium/winsys/sw/xlib/libws_xlib.a
1473 endif
1474-ifneq ($(findstring kms, $(EGL_PLATFORMS)),)
1475-egl_SYS += -ldrm
1476+ifneq ($(findstring drm, $(EGL_PLATFORMS)),)
1477+egl_SYS += $(LIBDRM_LIB)
1478 endif
1479 ifneq ($(findstring fbdev, $(EGL_PLATFORMS)),)
1480 egl_LIBS += $(TOP)/src/gallium/winsys/sw/fbdev/libfbdev.a
7959a51a
AM
1481diff --git a/src/gallium/targets/egl/pipe_i965.c b/src/gallium/targets/egl/pipe_i965.c
1482index 43bf646..36b03b3 100644
1483--- a/src/gallium/targets/egl/pipe_i965.c
1484+++ b/src/gallium/targets/egl/pipe_i965.c
1485@@ -1,6 +1,7 @@
1486
1487 #include "target-helpers/inline_wrapper_sw_helper.h"
1488 #include "target-helpers/inline_debug_helper.h"
1489+#include "target-helpers/inline_wrapper_sw_helper.h"
1490 #include "state_tracker/drm_driver.h"
1491 #include "i965/drm/i965_drm_public.h"
1492 #include "i965/brw_public.h"
9caf779f 1493diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_ctrl.c b/src/gallium/targets/xorg-vmwgfx/vmw_ctrl.c
7959a51a 1494index 237b308..9b422e6 100644
9caf779f
AM
1495--- a/src/gallium/targets/xorg-vmwgfx/vmw_ctrl.c
1496+++ b/src/gallium/targets/xorg-vmwgfx/vmw_ctrl.c
1497@@ -32,6 +32,7 @@
1498 * allows X clients to communicate with the driver.
1499 */
1500
1501+#include <xorg-server.h>
1502 #include "dixstruct.h"
1503 #include "extnsionst.h"
1504 #include <X11/X.h>
7959a51a
AM
1505@@ -211,7 +212,7 @@ VMwareCtrlDoSetTopology(ScrnInfoPtr pScrn,
1506 struct vmw_customizer *vmw = vmw_customizer(xorg_customizer(pScrn));
1507 int i;
1508
1509- rects = xcalloc(number, sizeof(*rects));
1510+ rects = calloc(number, sizeof(*rects));
1511 if (!rects)
1512 return FALSE;
1513
1514@@ -224,7 +225,7 @@ VMwareCtrlDoSetTopology(ScrnInfoPtr pScrn,
1515
1516 vmw_ioctl_update_layout(vmw, number, rects);
1517
1518- xfree(rects);
1519+ free(rects);
1520 return TRUE;
1521 }
1522
1523diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c b/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c
1524index 7c799b5..7625d2f 100644
1525--- a/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c
1526+++ b/src/gallium/targets/xorg-vmwgfx/vmw_ioctl.c
1527@@ -165,7 +165,7 @@ vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *han
1528 struct drm_vmw_dmabuf_rep *rep = &arg.rep;
1529 int ret;
1530
1531- buf = xcalloc(1, sizeof(*buf));
1532+ buf = calloc(1, sizeof(*buf));
1533 if (!buf)
1534 goto err;
1535
1536@@ -192,7 +192,7 @@ vmw_ioctl_buffer_create(struct vmw_customizer *vmw, uint32_t size, unsigned *han
1537 return buf;
1538
1539 err_free:
1540- xfree(buf);
1541+ free(buf);
1542 err:
1543 return NULL;
1544 }
1545@@ -211,7 +211,7 @@ vmw_ioctl_buffer_destroy(struct vmw_customizer *vmw, struct vmw_dma_buffer *buf)
1546 arg.handle = buf->handle;
1547 drmCommandWrite(vmw->fd, DRM_VMW_UNREF_DMABUF, &arg, sizeof(arg));
1548
1549- xfree(buf);
1550+ free(buf);
1551 }
1552
1553 void *
9caf779f
AM
1554diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_screen.c b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
1555index 8173908..7662203 100644
1556--- a/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
1557+++ b/src/gallium/targets/xorg-vmwgfx/vmw_screen.c
1558@@ -245,6 +245,7 @@ vmw_screen_pre_init(ScrnInfoPtr pScrn, int flags)
1559 cust->winsys_enter_vt = vmw_screen_enter_vt;
1560 cust->winsys_leave_vt = vmw_screen_leave_vt;
1561 cust->no_3d = TRUE;
1562+ cust->unhidden_hw_cursor_update = TRUE;
1563 vmw->pScrn = pScrn;
1564
1565 pScrn->driverPrivate = cust;
7959a51a
AM
1566diff --git a/src/gallium/targets/xorg-vmwgfx/vmw_video.c b/src/gallium/targets/xorg-vmwgfx/vmw_video.c
1567index eced60d..94465e5 100644
1568--- a/src/gallium/targets/xorg-vmwgfx/vmw_video.c
1569+++ b/src/gallium/targets/xorg-vmwgfx/vmw_video.c
1570@@ -300,7 +300,7 @@ vmw_video_init(struct vmw_customizer *vmw)
1571 numAdaptors = 1;
1572 overlayAdaptors = &newAdaptor;
1573 } else {
1574- newAdaptors = xalloc((numAdaptors + 1) *
1575+ newAdaptors = malloc((numAdaptors + 1) *
1576 sizeof(XF86VideoAdaptorPtr*));
1577 if (!newAdaptors) {
1578 xf86XVFreeVideoAdaptorRec(newAdaptor);
1579@@ -320,7 +320,7 @@ vmw_video_init(struct vmw_customizer *vmw)
1580 }
1581
1582 if (newAdaptors) {
1583- xfree(newAdaptors);
1584+ free(newAdaptors);
1585 }
1586
1587 debug_printf("Initialized VMware Xv extension successfully\n");
1588@@ -438,7 +438,7 @@ vmw_video_init_adaptor(ScrnInfoPtr pScrn, struct vmw_customizer *vmw)
1589 return NULL;
1590 }
1591
1592- video = xcalloc(1, sizeof(*video));
1593+ video = calloc(1, sizeof(*video));
1594 if (!video) {
1595 debug_printf("Not enough memory.\n");
1596 xf86XVFreeVideoAdaptorRec(adaptor);
1597@@ -742,7 +742,7 @@ vmw_video_buffer_alloc(struct vmw_customizer *vmw, int size,
1598 }
1599
1600 out->size = size;
1601- out->extra_data = xcalloc(1, size);
1602+ out->extra_data = calloc(1, size);
1603
1604 debug_printf("\t\t%s: allocated buffer %p of size %i\n", __func__, out, size);
1605
1606@@ -773,7 +773,7 @@ vmw_video_buffer_free(struct vmw_customizer *vmw,
1607 if (out->size == 0)
1608 return Success;
1609
1610- xfree(out->extra_data);
1611+ free(out->extra_data);
1612 vmw_ioctl_buffer_unmap(vmw, out->buf);
1613 vmw_ioctl_buffer_destroy(vmw, out->buf);
1614
aba744d1
AM
1615diff --git a/src/gallium/winsys/radeon/drm/radeon_drm.h b/src/gallium/winsys/radeon/drm/radeon_drm.h
1616index df6dd91..061229f 100644
1617--- a/src/gallium/winsys/radeon/drm/radeon_drm.h
1618+++ b/src/gallium/winsys/radeon/drm/radeon_drm.h
1619@@ -37,7 +37,214 @@
1620 * I believe that this check is valid, but I haven't been exhaustive. */
1621 static INLINE boolean is_r3xx(int pciid)
1622 {
1623- return (pciid > 0x3150) && (pciid < 0x796f);
1624+ switch (pciid) {
1625+ case 0x4144: /* PCI_CHIP_R300_AD */
1626+ case 0x4145: /* PCI_CHIP_R300_AE */
1627+ case 0x4146: /* PCI_CHIP_R300_AF */
1628+ case 0x4147: /* PCI_CHIP_R300_AG */
1629+ case 0x4E44: /* PCI_CHIP_R300_ND */
1630+ case 0x4E45: /* PCI_CHIP_R300_NE */
1631+ case 0x4E46: /* PCI_CHIP_R300_NF */
1632+ case 0x4E47: /* PCI_CHIP_R300_NG */
1633+ case 0x4E48: /* PCI_CHIP_R350_NH */
1634+ case 0x4E49: /* PCI_CHIP_R350_NI */
1635+ case 0x4E4B: /* PCI_CHIP_R350_NK */
1636+ case 0x4148: /* PCI_CHIP_R350_AH */
1637+ case 0x4149: /* PCI_CHIP_R350_AI */
1638+ case 0x414A: /* PCI_CHIP_R350_AJ */
1639+ case 0x414B: /* PCI_CHIP_R350_AK */
1640+ case 0x4E4A: /* PCI_CHIP_R360_NJ */
1641+ case 0x4150: /* PCI_CHIP_RV350_AP */
1642+ case 0x4151: /* PCI_CHIP_RV350_AQ */
1643+ case 0x4152: /* PCI_CHIP_RV350_AR */
1644+ case 0x4153: /* PCI_CHIP_RV350_AS */
1645+ case 0x4154: /* PCI_CHIP_RV350_AT */
1646+ case 0x4155: /* PCI_CHIP_RV350_AU */
1647+ case 0x4156: /* PCI_CHIP_RV350_AV */
1648+ case 0x4E50: /* PCI_CHIP_RV350_NP */
1649+ case 0x4E51: /* PCI_CHIP_RV350_NQ */
1650+ case 0x4E52: /* PCI_CHIP_RV350_NR */
1651+ case 0x4E53: /* PCI_CHIP_RV350_NS */
1652+ case 0x4E54: /* PCI_CHIP_RV350_NT */
1653+ case 0x4E56: /* PCI_CHIP_RV350_NV */
1654+ case 0x5460: /* PCI_CHIP_RV370_5460 */
1655+ case 0x5462: /* PCI_CHIP_RV370_5462 */
1656+ case 0x5464: /* PCI_CHIP_RV370_5464 */
1657+ case 0x5B60: /* PCI_CHIP_RV370_5B60 */
1658+ case 0x5B62: /* PCI_CHIP_RV370_5B62 */
1659+ case 0x5B63: /* PCI_CHIP_RV370_5B63 */
1660+ case 0x5B64: /* PCI_CHIP_RV370_5B64 */
1661+ case 0x5B65: /* PCI_CHIP_RV370_5B65 */
1662+ case 0x3150: /* PCI_CHIP_RV380_3150 */
1663+ case 0x3152: /* PCI_CHIP_RV380_3152 */
1664+ case 0x3154: /* PCI_CHIP_RV380_3154 */
1665+ case 0x3155: /* PCI_CHIP_RV380_3155 */
1666+ case 0x3E50: /* PCI_CHIP_RV380_3E50 */
1667+ case 0x3E54: /* PCI_CHIP_RV380_3E54 */
1668+ case 0x4A48: /* PCI_CHIP_R420_JH */
1669+ case 0x4A49: /* PCI_CHIP_R420_JI */
1670+ case 0x4A4A: /* PCI_CHIP_R420_JJ */
1671+ case 0x4A4B: /* PCI_CHIP_R420_JK */
1672+ case 0x4A4C: /* PCI_CHIP_R420_JL */
1673+ case 0x4A4D: /* PCI_CHIP_R420_JM */
1674+ case 0x4A4E: /* PCI_CHIP_R420_JN */
1675+ case 0x4A4F: /* PCI_CHIP_R420_JO */
1676+ case 0x4A50: /* PCI_CHIP_R420_JP */
1677+ case 0x4A54: /* PCI_CHIP_R420_JT */
1678+ case 0x5548: /* PCI_CHIP_R423_UH */
1679+ case 0x5549: /* PCI_CHIP_R423_UI */
1680+ case 0x554A: /* PCI_CHIP_R423_UJ */
1681+ case 0x554B: /* PCI_CHIP_R423_UK */
1682+ case 0x5550: /* PCI_CHIP_R423_5550 */
1683+ case 0x5551: /* PCI_CHIP_R423_UQ */
1684+ case 0x5552: /* PCI_CHIP_R423_UR */
1685+ case 0x5554: /* PCI_CHIP_R423_UT */
1686+ case 0x5D57: /* PCI_CHIP_R423_5D57 */
1687+ case 0x554C: /* PCI_CHIP_R430_554C */
1688+ case 0x554D: /* PCI_CHIP_R430_554D */
1689+ case 0x554E: /* PCI_CHIP_R430_554E */
1690+ case 0x554F: /* PCI_CHIP_R430_554F */
1691+ case 0x5D48: /* PCI_CHIP_R430_5D48 */
1692+ case 0x5D49: /* PCI_CHIP_R430_5D49 */
1693+ case 0x5D4A: /* PCI_CHIP_R430_5D4A */
1694+ case 0x5D4C: /* PCI_CHIP_R480_5D4C */
1695+ case 0x5D4D: /* PCI_CHIP_R480_5D4D */
1696+ case 0x5D4E: /* PCI_CHIP_R480_5D4E */
1697+ case 0x5D4F: /* PCI_CHIP_R480_5D4F */
1698+ case 0x5D50: /* PCI_CHIP_R480_5D50 */
1699+ case 0x5D52: /* PCI_CHIP_R480_5D52 */
1700+ case 0x4B49: /* PCI_CHIP_R481_4B49 */
1701+ case 0x4B4A: /* PCI_CHIP_R481_4B4A */
1702+ case 0x4B4B: /* PCI_CHIP_R481_4B4B */
1703+ case 0x4B4C: /* PCI_CHIP_R481_4B4C */
1704+ case 0x564A: /* PCI_CHIP_RV410_564A */
1705+ case 0x564B: /* PCI_CHIP_RV410_564B */
1706+ case 0x564F: /* PCI_CHIP_RV410_564F */
1707+ case 0x5652: /* PCI_CHIP_RV410_5652 */
1708+ case 0x5653: /* PCI_CHIP_RV410_5653 */
1709+ case 0x5657: /* PCI_CHIP_RV410_5657 */
1710+ case 0x5E48: /* PCI_CHIP_RV410_5E48 */
1711+ case 0x5E4A: /* PCI_CHIP_RV410_5E4A */
1712+ case 0x5E4B: /* PCI_CHIP_RV410_5E4B */
1713+ case 0x5E4C: /* PCI_CHIP_RV410_5E4C */
1714+ case 0x5E4D: /* PCI_CHIP_RV410_5E4D */
1715+ case 0x5E4F: /* PCI_CHIP_RV410_5E4F */
1716+ case 0x5A41: /* PCI_CHIP_RS400_5A41 */
1717+ case 0x5A42: /* PCI_CHIP_RS400_5A42 */
1718+ case 0x5A61: /* PCI_CHIP_RC410_5A61 */
1719+ case 0x5A62: /* PCI_CHIP_RC410_5A62 */
1720+ case 0x5954: /* PCI_CHIP_RS480_5954 */
1721+ case 0x5955: /* PCI_CHIP_RS480_5955 */
1722+ case 0x5974: /* PCI_CHIP_RS482_5974 */
1723+ case 0x5975: /* PCI_CHIP_RS482_5975 */
1724+ case 0x7100: /* PCI_CHIP_R520_7100 */
1725+ case 0x7101: /* PCI_CHIP_R520_7101 */
1726+ case 0x7102: /* PCI_CHIP_R520_7102 */
1727+ case 0x7103: /* PCI_CHIP_R520_7103 */
1728+ case 0x7104: /* PCI_CHIP_R520_7104 */
1729+ case 0x7105: /* PCI_CHIP_R520_7105 */
1730+ case 0x7106: /* PCI_CHIP_R520_7106 */
1731+ case 0x7108: /* PCI_CHIP_R520_7108 */
1732+ case 0x7109: /* PCI_CHIP_R520_7109 */
1733+ case 0x710A: /* PCI_CHIP_R520_710A */
1734+ case 0x710B: /* PCI_CHIP_R520_710B */
1735+ case 0x710C: /* PCI_CHIP_R520_710C */
1736+ case 0x710E: /* PCI_CHIP_R520_710E */
1737+ case 0x710F: /* PCI_CHIP_R520_710F */
1738+ case 0x7140: /* PCI_CHIP_RV515_7140 */
1739+ case 0x7141: /* PCI_CHIP_RV515_7141 */
1740+ case 0x7142: /* PCI_CHIP_RV515_7142 */
1741+ case 0x7143: /* PCI_CHIP_RV515_7143 */
1742+ case 0x7144: /* PCI_CHIP_RV515_7144 */
1743+ case 0x7145: /* PCI_CHIP_RV515_7145 */
1744+ case 0x7146: /* PCI_CHIP_RV515_7146 */
1745+ case 0x7147: /* PCI_CHIP_RV515_7147 */
1746+ case 0x7149: /* PCI_CHIP_RV515_7149 */
1747+ case 0x714A: /* PCI_CHIP_RV515_714A */
1748+ case 0x714B: /* PCI_CHIP_RV515_714B */
1749+ case 0x714C: /* PCI_CHIP_RV515_714C */
1750+ case 0x714D: /* PCI_CHIP_RV515_714D */
1751+ case 0x714E: /* PCI_CHIP_RV515_714E */
1752+ case 0x714F: /* PCI_CHIP_RV515_714F */
1753+ case 0x7151: /* PCI_CHIP_RV515_7151 */
1754+ case 0x7152: /* PCI_CHIP_RV515_7152 */
1755+ case 0x7153: /* PCI_CHIP_RV515_7153 */
1756+ case 0x715E: /* PCI_CHIP_RV515_715E */
1757+ case 0x715F: /* PCI_CHIP_RV515_715F */
1758+ case 0x7180: /* PCI_CHIP_RV515_7180 */
1759+ case 0x7181: /* PCI_CHIP_RV515_7181 */
1760+ case 0x7183: /* PCI_CHIP_RV515_7183 */
1761+ case 0x7186: /* PCI_CHIP_RV515_7186 */
1762+ case 0x7187: /* PCI_CHIP_RV515_7187 */
1763+ case 0x7188: /* PCI_CHIP_RV515_7188 */
1764+ case 0x718A: /* PCI_CHIP_RV515_718A */
1765+ case 0x718B: /* PCI_CHIP_RV515_718B */
1766+ case 0x718C: /* PCI_CHIP_RV515_718C */
1767+ case 0x718D: /* PCI_CHIP_RV515_718D */
1768+ case 0x718F: /* PCI_CHIP_RV515_718F */
1769+ case 0x7193: /* PCI_CHIP_RV515_7193 */
1770+ case 0x7196: /* PCI_CHIP_RV515_7196 */
1771+ case 0x719B: /* PCI_CHIP_RV515_719B */
1772+ case 0x719F: /* PCI_CHIP_RV515_719F */
1773+ case 0x7200: /* PCI_CHIP_RV515_7200 */
1774+ case 0x7210: /* PCI_CHIP_RV515_7210 */
1775+ case 0x7211: /* PCI_CHIP_RV515_7211 */
1776+ case 0x71C0: /* PCI_CHIP_RV530_71C0 */
1777+ case 0x71C1: /* PCI_CHIP_RV530_71C1 */
1778+ case 0x71C2: /* PCI_CHIP_RV530_71C2 */
1779+ case 0x71C3: /* PCI_CHIP_RV530_71C3 */
1780+ case 0x71C4: /* PCI_CHIP_RV530_71C4 */
1781+ case 0x71C5: /* PCI_CHIP_RV530_71C5 */
1782+ case 0x71C6: /* PCI_CHIP_RV530_71C6 */
1783+ case 0x71C7: /* PCI_CHIP_RV530_71C7 */
1784+ case 0x71CD: /* PCI_CHIP_RV530_71CD */
1785+ case 0x71CE: /* PCI_CHIP_RV530_71CE */
1786+ case 0x71D2: /* PCI_CHIP_RV530_71D2 */
1787+ case 0x71D4: /* PCI_CHIP_RV530_71D4 */
1788+ case 0x71D5: /* PCI_CHIP_RV530_71D5 */
1789+ case 0x71D6: /* PCI_CHIP_RV530_71D6 */
1790+ case 0x71DA: /* PCI_CHIP_RV530_71DA */
1791+ case 0x71DE: /* PCI_CHIP_RV530_71DE */
1792+ case 0x7281: /* PCI_CHIP_RV560_7281 */
1793+ case 0x7283: /* PCI_CHIP_RV560_7283 */
1794+ case 0x7287: /* PCI_CHIP_RV560_7287 */
1795+ case 0x7290: /* PCI_CHIP_RV560_7290 */
1796+ case 0x7291: /* PCI_CHIP_RV560_7291 */
1797+ case 0x7293: /* PCI_CHIP_RV560_7293 */
1798+ case 0x7297: /* PCI_CHIP_RV560_7297 */
1799+ case 0x7280: /* PCI_CHIP_RV570_7280 */
1800+ case 0x7288: /* PCI_CHIP_RV570_7288 */
1801+ case 0x7289: /* PCI_CHIP_RV570_7289 */
1802+ case 0x728B: /* PCI_CHIP_RV570_728B */
1803+ case 0x728C: /* PCI_CHIP_RV570_728C */
1804+ case 0x7240: /* PCI_CHIP_R580_7240 */
1805+ case 0x7243: /* PCI_CHIP_R580_7243 */
1806+ case 0x7244: /* PCI_CHIP_R580_7244 */
1807+ case 0x7245: /* PCI_CHIP_R580_7245 */
1808+ case 0x7246: /* PCI_CHIP_R580_7246 */
1809+ case 0x7247: /* PCI_CHIP_R580_7247 */
1810+ case 0x7248: /* PCI_CHIP_R580_7248 */
1811+ case 0x7249: /* PCI_CHIP_R580_7249 */
1812+ case 0x724A: /* PCI_CHIP_R580_724A */
1813+ case 0x724B: /* PCI_CHIP_R580_724B */
1814+ case 0x724C: /* PCI_CHIP_R580_724C */
1815+ case 0x724D: /* PCI_CHIP_R580_724D */
1816+ case 0x724E: /* PCI_CHIP_R580_724E */
1817+ case 0x724F: /* PCI_CHIP_R580_724F */
1818+ case 0x7284: /* PCI_CHIP_R580_7284 */
1819+ case 0x793F: /* PCI_CHIP_RS600_793F */
1820+ case 0x7941: /* PCI_CHIP_RS600_7941 */
1821+ case 0x7942: /* PCI_CHIP_RS600_7942 */
1822+ case 0x791E: /* PCI_CHIP_RS690_791E */
1823+ case 0x791F: /* PCI_CHIP_RS690_791F */
1824+ case 0x796C: /* PCI_CHIP_RS740_796C */
1825+ case 0x796D: /* PCI_CHIP_RS740_796D */
1826+ case 0x796E: /* PCI_CHIP_RS740_796E */
1827+ case 0x796F: /* PCI_CHIP_RS740_796F */
1828+ return TRUE;
1829+ default:
1830+ return FALSE;
1831+ }
1832 }
1833
1834 #endif
25bb03e4
AM
1835diff --git a/src/glsl/glsl_parser.cpp b/src/glsl/glsl_parser.cpp
1836index 301c221..ad99eee 100644
1837--- a/src/glsl/glsl_parser.cpp
1838+++ b/src/glsl/glsl_parser.cpp
1839@@ -1,9 +1,9 @@
1840-/* A Bison parser, made by GNU Bison 2.4.3. */
1841+/* A Bison parser, made by GNU Bison 2.4.2. */
1842
1843 /* Skeleton implementation for Bison's Yacc-like parsers in C
1844
1845- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
1846- 2009, 2010 Free Software Foundation, Inc.
1847+ Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
1848+ Foundation, Inc.
1849
1850 This program is free software: you can redistribute it and/or modify
1851 it under the terms of the GNU General Public License as published by
1852@@ -45,7 +45,7 @@
1853 #define YYBISON 1
1854
1855 /* Bison version. */
1856-#define YYBISON_VERSION "2.4.3"
1857+#define YYBISON_VERSION "2.4.2"
1858
1859 /* Skeleton name. */
1860 #define YYSKELETON_NAME "yacc.c"
1861@@ -2621,7 +2621,7 @@ YYLTYPE yylloc;
1862 YYLTYPE *yylsp;
1863
1864 /* The locations where the error started and ended. */
1865- YYLTYPE yyerror_range[3];
1866+ YYLTYPE yyerror_range[2];
1867
1868 YYSIZE_T yystacksize;
1869
1870@@ -5084,7 +5084,7 @@ yyerrlab:
1871 #endif
1872 }
1873
1874- yyerror_range[1] = yylloc;
1875+ yyerror_range[0] = yylloc;
1876
1877 if (yyerrstatus == 3)
1878 {
1879@@ -5121,7 +5121,7 @@ yyerrorlab:
1880 if (/*CONSTCOND*/ 0)
1881 goto yyerrorlab;
1882
1883- yyerror_range[1] = yylsp[1-yylen];
1884+ yyerror_range[0] = yylsp[1-yylen];
1885 /* Do not reclaim the symbols of the rule which action triggered
1886 this YYERROR. */
1887 YYPOPSTACK (yylen);
1888@@ -5155,7 +5155,7 @@ yyerrlab1:
1889 if (yyssp == yyss)
1890 YYABORT;
1891
1892- yyerror_range[1] = *yylsp;
1893+ yyerror_range[0] = *yylsp;
1894 yydestruct ("Error: popping",
1895 yystos[yystate], yyvsp, yylsp, state);
1896 YYPOPSTACK (1);
1897@@ -5165,10 +5165,10 @@ yyerrlab1:
1898
1899 *++yyvsp = yylval;
1900
1901- yyerror_range[2] = yylloc;
1902+ yyerror_range[1] = yylloc;
1903 /* Using YYLLOC is tempting, but would change the location of
1904 the lookahead. YYLOC is available though. */
1905- YYLLOC_DEFAULT (yyloc, yyerror_range, 2);
1906+ YYLLOC_DEFAULT (yyloc, (yyerror_range - 1), 2);
1907 *++yylsp = yyloc;
1908
1909 /* Shift the error token. */
1910diff --git a/src/glsl/glsl_parser.h b/src/glsl/glsl_parser.h
1911index 4a78037..266a4a2 100644
1912--- a/src/glsl/glsl_parser.h
1913+++ b/src/glsl/glsl_parser.h
1914@@ -1,9 +1,9 @@
1915-/* A Bison parser, made by GNU Bison 2.4.3. */
1916+/* A Bison parser, made by GNU Bison 2.4.2. */
1917
1918 /* Skeleton interface for Bison's Yacc-like parsers in C
1919
1920- Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002, 2003, 2004, 2005, 2006,
1921- 2009, 2010 Free Software Foundation, Inc.
1922+ Copyright (C) 1984, 1989-1990, 2000-2006, 2009-2010 Free Software
1923+ Foundation, Inc.
1924
1925 This program is free software: you can redistribute it and/or modify
1926 it under the terms of the GNU General Public License as published by
7959a51a 1927diff --git a/src/mesa/Makefile b/src/mesa/Makefile
25bb03e4 1928index c41c38c..8b0756b 100644
7959a51a
AM
1929--- a/src/mesa/Makefile
1930+++ b/src/mesa/Makefile
25bb03e4 1931@@ -34,9 +34,9 @@ ES1_CPPFLAGS := -DFEATURE_ES1=1 $(DEFINES)
7959a51a
AM
1932 ES2_CPPFLAGS := -DFEATURE_ES2=1 $(DEFINES)
1933
1934 # append include dirs
1935-MESA_CPPFLAGS += $(INCLUDE_DIRS)
25bb03e4
AM
1936-ES1_CPPFLAGS += -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS)
1937-ES2_CPPFLAGS += -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS)
7959a51a 1938+MESA_CPPFLAGS += $(INCLUDE_DIRS) $(TALLOC_CFLAGS)
25bb03e4
AM
1939+ES1_CPPFLAGS += -I$(TOP)/src/mapi/es1api $(INCLUDE_DIRS) $(TALLOC_CFLAGS)
1940+ES2_CPPFLAGS += -I$(TOP)/src/mapi/es2api $(INCLUDE_DIRS) $(TALLOC_CFLAGS)
1941
1942 # tidy compiler flags
1943 CFLAGS := $(filter-out $(DEFINES), $(CFLAGS))
1944diff --git a/src/mesa/drivers/common/meta.c b/src/mesa/drivers/common/meta.c
1945index a03cb68..20dda5f 100644
1946--- a/src/mesa/drivers/common/meta.c
1947+++ b/src/mesa/drivers/common/meta.c
1948@@ -1385,6 +1385,7 @@ _mesa_meta_Clear(GLcontext *ctx, GLbitfield buffers)
1949 struct vertex verts[4];
1950 /* save all state but scissor, pixel pack/unpack */
1951 GLbitfield metaSave = META_ALL - META_SCISSOR - META_PIXEL_STORE;
1952+ const GLuint stencilMax = (1 << ctx->DrawBuffer->Visual.stencilBits) - 1;
1953
1954 if (buffers & BUFFER_BITS_COLOR) {
1955 /* if clearing color buffers, don't save/restore colormask */
1956@@ -1440,7 +1441,7 @@ _mesa_meta_Clear(GLcontext *ctx, GLbitfield buffers)
1957 _mesa_StencilOpSeparate(GL_FRONT_AND_BACK,
1958 GL_REPLACE, GL_REPLACE, GL_REPLACE);
1959 _mesa_StencilFuncSeparate(GL_FRONT_AND_BACK, GL_ALWAYS,
1960- ctx->Stencil.Clear & 0x7fffffff,
1961+ ctx->Stencil.Clear & stencilMax,
1962 ctx->Stencil.WriteMask[0]);
1963 }
1964 else {
9caf779f 1965diff --git a/src/mesa/drivers/dri/r200/r200_swtcl.c b/src/mesa/drivers/dri/r200/r200_swtcl.c
7959a51a 1966index dbf4ad4..160e7e7 100644
9caf779f
AM
1967--- a/src/mesa/drivers/dri/r200/r200_swtcl.c
1968+++ b/src/mesa/drivers/dri/r200/r200_swtcl.c
7959a51a
AM
1969@@ -319,10 +319,9 @@ static INLINE GLuint reduced_hw_prim( GLcontext *ctx, GLuint prim)
1970 {
1971 switch (prim) {
1972 case GL_POINTS:
1973- return (ctx->Point.PointSprite ||
1974- ((ctx->_TriangleCaps & (DD_POINT_SIZE | DD_POINT_ATTEN)) &&
1975- !(ctx->_TriangleCaps & (DD_POINT_SMOOTH)))) ?
1976- R200_VF_PRIM_POINT_SPRITES : R200_VF_PRIM_POINTS;
1977+ return (((R200_CONTEXT(ctx))->radeon.radeonScreen->drmSupportsPointSprites &&
1978+ !(ctx->_TriangleCaps & DD_POINT_SMOOTH)) ?
1979+ R200_VF_PRIM_POINT_SPRITES : R200_VF_PRIM_POINTS);
1980 case GL_LINES:
1981 /* fallthrough */
1982 case GL_LINE_LOOP:
1983@@ -613,6 +612,9 @@ static void r200RasterPrimitive( GLcontext *ctx, GLuint hwprim )
9caf779f
AM
1984 r200ContextPtr rmesa = R200_CONTEXT(ctx);
1985
1986 radeon_prepare_render(&rmesa->radeon);
1987+ if (rmesa->radeon.NewGLState)
1988+ r200ValidateState( ctx );
1989+
1990
1991 if (rmesa->radeon.swtcl.hw_primitive != hwprim) {
1992 /* need to disable perspective-correct texturing for point sprites */
1993diff --git a/src/mesa/drivers/dri/r200/r200_tcl.c b/src/mesa/drivers/dri/r200/r200_tcl.c
7959a51a 1994index 4ae0f30..2743997 100644
9caf779f
AM
1995--- a/src/mesa/drivers/dri/r200/r200_tcl.c
1996+++ b/src/mesa/drivers/dri/r200/r200_tcl.c
7959a51a
AM
1997@@ -68,9 +68,8 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1998 #define HAVE_ELTS 1
1999
2000
2001-#define HW_POINTS ((ctx->Point.PointSprite || \
2002- ((ctx->_TriangleCaps & (DD_POINT_SIZE | DD_POINT_ATTEN)) && \
2003- !(ctx->_TriangleCaps & (DD_POINT_SMOOTH)))) ? \
2004+#define HW_POINTS (((R200_CONTEXT(ctx))->radeon.radeonScreen->drmSupportsPointSprites && \
2005+ !(ctx->_TriangleCaps & DD_POINT_SMOOTH)) ? \
2006 R200_VF_PRIM_POINT_SPRITES : R200_VF_PRIM_POINTS)
2007 #define HW_LINES R200_VF_PRIM_LINES
2008 #define HW_LINE_LOOP 0
2009@@ -265,6 +264,8 @@ void r200TclPrimitive( GLcontext *ctx,
9caf779f
AM
2010 GLuint newprim = hw_prim | R200_VF_TCL_OUTPUT_VTX_ENABLE;
2011
2012 radeon_prepare_render(&rmesa->radeon);
2013+ if (rmesa->radeon.NewGLState)
2014+ r200ValidateState( ctx );
2015
2016 if (newprim != rmesa->tcl.hw_primitive ||
2017 !discrete_prim[hw_prim&0xf]) {
25bb03e4
AM
2018diff --git a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
2019index 3b2b06f..9f19f8f 100644
2020--- a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
2021+++ b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_emit.c
2022@@ -76,6 +76,9 @@ static void use_temporary(struct r300_fragment_program_code *code, unsigned int
2023
2024 static unsigned int use_source(struct r300_fragment_program_code* code, struct radeon_pair_instruction_source src)
2025 {
2026+ if (!src.Used)
2027+ return 0;
2028+
2029 if (src.File == RC_FILE_CONSTANT) {
2030 return src.Index | (1 << 5);
2031 } else if (src.File == RC_FILE_TEMPORARY) {
2032diff --git a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c
2033index caa48fe..1aa40c7 100644
2034--- a/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c
2035+++ b/src/mesa/drivers/dri/r300/compiler/r300_fragprog_swizzle.c
2036@@ -94,6 +94,10 @@ static const struct swizzle_data* lookup_native_swizzle(unsigned int swizzle)
2037 */
2038 static int r300_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
2039 {
2040+ const struct swizzle_data* sd;
2041+ unsigned int relevant;
2042+ int j;
2043+
2044 if (reg.Abs)
2045 reg.Negate = RC_MASK_NONE;
2046
2047@@ -117,8 +121,7 @@ static int r300_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
2048 return 1;
2049 }
2050
2051- unsigned int relevant = 0;
2052- int j;
2053+ relevant = 0;
2054
2055 for(j = 0; j < 3; ++j)
2056 if (GET_SWZ(reg.Swizzle, j) != RC_SWIZZLE_UNUSED)
2057@@ -127,7 +130,8 @@ static int r300_swizzle_is_native(rc_opcode opcode, struct rc_src_register reg)
2058 if ((reg.Negate & relevant) && ((reg.Negate & relevant) != relevant))
2059 return 0;
2060
2061- if (!lookup_native_swizzle(reg.Swizzle))
2062+ sd = lookup_native_swizzle(reg.Swizzle);
2063+ if (!sd || (reg.File == RC_FILE_PRESUB && sd->srcp_stride == 0))
2064 return 0;
2065
2066 return 1;
2067@@ -200,7 +204,7 @@ unsigned int r300FPTranslateRGBSwizzle(unsigned int src, unsigned int swizzle)
2068 {
2069 const struct swizzle_data* sd = lookup_native_swizzle(swizzle);
2070
2071- if (!sd) {
2072+ if (!sd || (src == RC_PAIR_PRESUB_SRC && sd->srcp_stride == 0)) {
2073 fprintf(stderr, "Not a native swizzle: %08x\n", swizzle);
2074 return 0;
2075 }
aba744d1
AM
2076diff --git a/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c b/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c
2077index 4793f33..d9a398d 100644
2078--- a/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c
2079+++ b/src/mesa/drivers/dri/r300/compiler/r3xx_fragprog.c
2080@@ -54,6 +54,8 @@ static void rc_rewrite_depth_out(struct radeon_compiler *cc, void *user)
2081
2082 for (rci = c->Base.Program.Instructions.Next; rci != &c->Base.Program.Instructions; rci = rci->Next) {
2083 struct rc_sub_instruction * inst = &rci->U.I;
2084+ unsigned i;
2085+ const struct rc_opcode_info *info = rc_get_opcode_info(inst->Opcode);
2086
2087 if (inst->DstReg.File != RC_FILE_OUTPUT || inst->DstReg.Index != c->OutputDepth)
2088 continue;
2089@@ -65,27 +67,12 @@ static void rc_rewrite_depth_out(struct radeon_compiler *cc, void *user)
2090 continue;
2091 }
2092
2093- switch (inst->Opcode) {
2094- case RC_OPCODE_FRC:
2095- case RC_OPCODE_MOV:
2096- inst->SrcReg[0] = lmul_swizzle(RC_SWIZZLE_ZZZZ, inst->SrcReg[0]);
2097- break;
2098- case RC_OPCODE_ADD:
2099- case RC_OPCODE_MAX:
2100- case RC_OPCODE_MIN:
2101- case RC_OPCODE_MUL:
2102- inst->SrcReg[0] = lmul_swizzle(RC_SWIZZLE_ZZZZ, inst->SrcReg[0]);
2103- inst->SrcReg[1] = lmul_swizzle(RC_SWIZZLE_ZZZZ, inst->SrcReg[1]);
2104- break;
2105- case RC_OPCODE_CMP:
2106- case RC_OPCODE_MAD:
2107- inst->SrcReg[0] = lmul_swizzle(RC_SWIZZLE_ZZZZ, inst->SrcReg[0]);
2108- inst->SrcReg[1] = lmul_swizzle(RC_SWIZZLE_ZZZZ, inst->SrcReg[1]);
2109- inst->SrcReg[2] = lmul_swizzle(RC_SWIZZLE_ZZZZ, inst->SrcReg[2]);
2110- break;
2111- default:
2112- // Scalar instructions needn't be reswizzled
2113- break;
2114+ if (!info->IsComponentwise) {
2115+ continue;
2116+ }
2117+
2118+ for (i = 0; i < info->NumSrcRegs; i++) {
2119+ inst->SrcReg[i] = lmul_swizzle(RC_SWIZZLE_ZZZZ, inst->SrcReg[i]);
2120 }
2121 }
2122 }
25bb03e4
AM
2123diff --git a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
2124index efa3bb5..abbf704 100644
2125--- a/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
2126+++ b/src/mesa/drivers/dri/r300/compiler/r500_fragprog_emit.c
2127@@ -200,6 +200,9 @@ static void use_temporary(struct r500_fragment_program_code* code, unsigned int
2128
2129 static unsigned int use_source(struct r500_fragment_program_code* code, struct radeon_pair_instruction_source src)
2130 {
2131+ if (!src.Used)
2132+ return 0;
2133+
2134 if (src.File == RC_FILE_CONSTANT) {
2135 return src.Index | 0x100;
2136 } else if (src.File == RC_FILE_TEMPORARY) {
2137diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
2138index 3be50b9..bebe806 100644
2139--- a/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
2140+++ b/src/mesa/drivers/dri/r300/compiler/radeon_optimize.c
2141@@ -566,6 +566,7 @@ static int presub_helper(
2142 for(i = 0; i < info->NumSrcRegs; i++) {
2143 unsigned int mask = src_reads_dst_mask(
2144 inst->U.I.SrcReg[i], s->Inst->U.I.DstReg);
2145+ struct rc_src_register src = inst->U.I.SrcReg[i];
2146 /* XXX We could be more aggressive here using
2147 * presubtract. It is okay if SrcReg[i] only reads
2148 * from some of the mask components. */
2149@@ -577,6 +578,11 @@ static int presub_helper(
2150 continue;
2151 }
2152 }
2153+ src.File = RC_FILE_PRESUB;
2154+ if (!c->SwizzleCaps->IsNative(inst->U.I.Opcode, src)){
2155+ can_remove = 0;
2156+ break;
2157+ }
2158 if (cant_sub || !can_use_presub) {
2159 can_remove = 0;
2160 break;
2161@@ -635,7 +641,9 @@ static void presub_replace_add(struct peephole_state *s,
2162 inst->U.I.SrcReg[src_index].Index = presub_opcode;
2163 }
2164
2165-static int is_presub_candidate(struct rc_instruction * inst)
2166+static int is_presub_candidate(
2167+ struct radeon_compiler * c,
2168+ struct rc_instruction * inst)
2169 {
2170 const struct rc_opcode_info * info = rc_get_opcode_info(inst->U.I.Opcode);
2171 unsigned int i;
2172@@ -644,7 +652,12 @@ static int is_presub_candidate(struct rc_instruction * inst)
2173 return 0;
2174
2175 for(i = 0; i < info->NumSrcRegs; i++) {
2176- if (src_reads_dst_mask(inst->U.I.SrcReg[i], inst->U.I.DstReg))
2177+ struct rc_src_register src = inst->U.I.SrcReg[i];
2178+ if (src_reads_dst_mask(src, inst->U.I.DstReg))
2179+ return 0;
2180+
2181+ src.File = RC_FILE_PRESUB;
2182+ if (!c->SwizzleCaps->IsNative(inst->U.I.Opcode, src))
2183 return 0;
2184 }
2185 return 1;
2186@@ -659,7 +672,7 @@ static int peephole_add_presub_add(
2187 unsigned int i;
2188 struct peephole_state s;
2189
2190- if (!is_presub_candidate(inst_add))
2191+ if (!is_presub_candidate(c, inst_add))
2192 return 0;
2193
2194 if (inst_add->U.I.SrcReg[0].Swizzle != inst_add->U.I.SrcReg[1].Swizzle)
2195@@ -726,7 +739,7 @@ static int peephole_add_presub_inv(
2196 unsigned int i, swz, mask;
2197 struct peephole_state s;
2198
2199- if (!is_presub_candidate(inst_add))
2200+ if (!is_presub_candidate(c, inst_add))
2201 return 0;
2202
2203 mask = inst_add->U.I.DstReg.WriteMask;
2204diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c
2205index c738455..126b50b 100644
2206--- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c
2207+++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_regalloc.c
2208@@ -66,10 +66,13 @@ struct regalloc_state {
2209 struct hardware_register * HwTemporary;
2210 unsigned int NumHwTemporaries;
2211 /**
2212- * If an instruction is inside of a loop, end_loop will be the
2213- * IP of the ENDLOOP instruction, otherwise end_loop will be 0
2214+ * If an instruction is inside of a loop, EndLoop will be the
2215+ * IP of the ENDLOOP instruction, and BeginLoop will be the IP
2216+ * of the BGNLOOP instruction. Otherwise, EndLoop and BeginLoop
2217+ * will be -1.
2218 */
2219- int end_loop;
2220+ int EndLoop;
2221+ int BeginLoop;
2222 };
2223
2224 static void print_live_intervals(struct live_intervals * src)
2225@@ -180,11 +183,13 @@ static void scan_callback(void * data, struct rc_instruction * inst,
2226 reg->Used = 1;
2227 if (file == RC_FILE_INPUT)
2228 reg->Live.Start = -1;
2229+ else if (s->BeginLoop >= 0)
2230+ reg->Live.Start = s->BeginLoop;
2231 else
2232 reg->Live.Start = inst->IP;
2233 reg->Live.End = inst->IP;
2234- } else if (s->end_loop)
2235- reg->Live.End = s->end_loop;
2236+ } else if (s->EndLoop >= 0)
2237+ reg->Live.End = s->EndLoop;
2238 else if (inst->IP > reg->Live.End)
2239 reg->Live.End = inst->IP;
2240 }
2241@@ -195,6 +200,8 @@ static void compute_live_intervals(struct radeon_compiler *c,
2242 memset(s, 0, sizeof(*s));
2243 s->C = c;
2244 s->NumHwTemporaries = c->max_temp_regs;
2245+ s->BeginLoop = -1;
2246+ s->EndLoop = -1;
2247 s->HwTemporary =
2248 memory_pool_malloc(&c->Pool,
2249 s->NumHwTemporaries * sizeof(struct hardware_register));
2250@@ -207,8 +214,10 @@ static void compute_live_intervals(struct radeon_compiler *c,
2251 inst = inst->Next) {
2252
2253 /* For all instructions inside of a loop, the ENDLOOP
2254- * instruction is used as the end of the live interval. */
2255- if (inst->U.I.Opcode == RC_OPCODE_BGNLOOP && !s->end_loop) {
2256+ * instruction is used as the end of the live interval and
2257+ * the BGNLOOP instruction is used as the beginning. */
2258+ if (inst->U.I.Opcode == RC_OPCODE_BGNLOOP && s->EndLoop < 0) {
2259+ s->BeginLoop = inst->IP;
2260 int loops = 1;
2261 struct rc_instruction * tmp;
2262 for(tmp = inst->Next;
2263@@ -219,15 +228,17 @@ static void compute_live_intervals(struct radeon_compiler *c,
2264 } else if (tmp->U.I.Opcode
2265 == RC_OPCODE_ENDLOOP) {
2266 if(!--loops) {
2267- s->end_loop = tmp->IP;
2268+ s->EndLoop = tmp->IP;
2269 break;
2270 }
2271 }
2272 }
2273 }
2274
2275- if (inst->IP == s->end_loop)
2276- s->end_loop = 0;
2277+ if (inst->IP == s->EndLoop) {
2278+ s->EndLoop = -1;
2279+ s->BeginLoop = -1;
2280+ }
2281
2282 rc_for_all_reads_mask(inst, scan_callback, s);
2283 rc_for_all_writes_mask(inst, scan_callback, s);
2284diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c
2285index 7ab2df3..0b003d7 100644
2286--- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c
2287+++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_schedule.c
2288@@ -126,15 +126,6 @@ static struct reg_value ** get_reg_valuep(struct schedule_state * s,
2289 return &s->Temporary[index].Values[chan];
2290 }
2291
2292-static struct reg_value * get_reg_value(struct schedule_state * s,
2293- rc_register_file file, unsigned int index, unsigned int chan)
2294-{
2295- struct reg_value ** pv = get_reg_valuep(s, file, index, chan);
2296- if (!pv)
2297- return 0;
2298- return *pv;
2299-}
2300-
2301 static void add_inst_to_list(struct schedule_instruction ** list, struct schedule_instruction * inst)
2302 {
2303 inst->NextReady = *list;
2304@@ -602,12 +593,13 @@ static void scan_read(void * data, struct rc_instruction * inst,
2305 rc_register_file file, unsigned int index, unsigned int chan)
2306 {
2307 struct schedule_state * s = data;
2308- struct reg_value * v = get_reg_value(s, file, index, chan);
2309+ struct reg_value ** v = get_reg_valuep(s, file, index, chan);
2310+ struct reg_value_reader * reader;
2311
2312 if (!v)
2313 return;
2314
2315- if (v->Writer == s->Current) {
2316+ if (*v && (*v)->Writer == s->Current) {
2317 /* The instruction reads and writes to a register component.
2318 * In this case, we only want to increment dependencies by one.
2319 */
2320@@ -616,18 +608,30 @@ static void scan_read(void * data, struct rc_instruction * inst,
2321
2322 DBG("%i: read %i[%i] chan %i\n", s->Current->Instruction->IP, file, index, chan);
2323
2324- struct reg_value_reader * reader = memory_pool_malloc(&s->C->Pool, sizeof(*reader));
2325+ reader = memory_pool_malloc(&s->C->Pool, sizeof(*reader));
2326 reader->Reader = s->Current;
2327- reader->Next = v->Readers;
2328- v->Readers = reader;
2329- v->NumReaders++;
2330-
2331- s->Current->NumDependencies++;
2332+ if (!*v) {
2333+ /* In this situation, the instruction reads from a register
2334+ * that hasn't been written to or read from in the current
2335+ * block. */
2336+ *v = memory_pool_malloc(&s->C->Pool, sizeof(struct reg_value));
2337+ memset(*v, 0, sizeof(struct reg_value));
2338+ (*v)->Readers = reader;
2339+ } else {
2340+ reader->Next = (*v)->Readers;
2341+ (*v)->Readers = reader;
2342+ /* Only update the current instruction's dependencies if the
2343+ * register it reads from has been written to in this block. */
2344+ if ((*v)->Writer) {
2345+ s->Current->NumDependencies++;
2346+ }
2347+ }
2348+ (*v)->NumReaders++;
2349
2350 if (s->Current->NumReadValues >= 12) {
2351 rc_error(s->C, "%s: NumReadValues overflow\n", __FUNCTION__);
2352 } else {
2353- s->Current->ReadValues[s->Current->NumReadValues++] = v;
2354+ s->Current->ReadValues[s->Current->NumReadValues++] = *v;
2355 }
2356 }
2357
2358diff --git a/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c b/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
2359index ff82584..840c7a5 100644
2360--- a/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
2361+++ b/src/mesa/drivers/dri/r300/compiler/radeon_pair_translate.c
2362@@ -278,9 +278,12 @@ static void set_pair_instruction(struct r300_fragment_program_compiler *c,
2363 pair->RGB.DestIndex = inst->DstReg.Index;
2364 pair->RGB.WriteMask |= inst->DstReg.WriteMask & RC_MASK_XYZ;
2365 }
2366+
2367 if (needalpha) {
2368- pair->Alpha.DestIndex = inst->DstReg.Index;
2369 pair->Alpha.WriteMask |= GET_BIT(inst->DstReg.WriteMask, 3);
2370+ if (pair->Alpha.WriteMask) {
2371+ pair->Alpha.DestIndex = inst->DstReg.Index;
2372+ }
2373 }
2374 }
2375
7959a51a
AM
2376diff --git a/src/mesa/drivers/dri/r300/r300_draw.c b/src/mesa/drivers/dri/r300/r300_draw.c
2377index 5ae9f49..767778b 100644
2378--- a/src/mesa/drivers/dri/r300/r300_draw.c
2379+++ b/src/mesa/drivers/dri/r300/r300_draw.c
2380@@ -717,6 +717,10 @@ static void r300DrawPrims(GLcontext *ctx,
2381 GLuint max_index)
2382 {
2383 GLboolean retval;
2384+ struct r300_context *r300 = R300_CONTEXT(ctx);
2385+ radeonContextPtr radeon = &r300->radeon;
2386+
2387+ radeon_prepare_render(radeon);
2388
2389 /* This check should get folded into just the places that
2390 * min/max index are really needed.
2391diff --git a/src/mesa/drivers/dri/r300/r300_render.c b/src/mesa/drivers/dri/r300/r300_render.c
2392index cf89ab7..bb8f914 100644
2393--- a/src/mesa/drivers/dri/r300/r300_render.c
2394+++ b/src/mesa/drivers/dri/r300/r300_render.c
2395@@ -327,8 +327,6 @@ void r300RunRenderPrimitive(GLcontext * ctx, int start, int end, int prim)
2396 BATCH_LOCALS(&rmesa->radeon);
2397 int type, num_verts;
2398
2399- radeon_prepare_render(&rmesa->radeon);
2400-
2401 type = r300PrimitiveType(rmesa, prim);
2402 num_verts = r300NumVerts(rmesa, end - start, prim);
2403
2404diff --git a/src/mesa/drivers/dri/r600/evergreen_render.c b/src/mesa/drivers/dri/r600/evergreen_render.c
2405index 27089bf..1fa53d7 100644
2406--- a/src/mesa/drivers/dri/r600/evergreen_render.c
2407+++ b/src/mesa/drivers/dri/r600/evergreen_render.c
2408@@ -909,6 +909,10 @@ static void evergreenDrawPrims(GLcontext *ctx,
2409 {
2410 GLboolean retval = GL_FALSE;
2411
2412+ context_t *context = EVERGREEN_CONTEXT(ctx);
2413+ radeonContextPtr radeon = &context->radeon;
2414+ radeon_prepare_render(radeon);
2415+
2416 /* This check should get folded into just the places that
2417 * min/max index are really needed.
2418 */
9caf779f 2419diff --git a/src/mesa/drivers/dri/radeon/radeon_common_context.c b/src/mesa/drivers/dri/radeon/radeon_common_context.c
7959a51a 2420index 85e4988..d4c7864 100644
9caf779f
AM
2421--- a/src/mesa/drivers/dri/radeon/radeon_common_context.c
2422+++ b/src/mesa/drivers/dri/radeon/radeon_common_context.c
7959a51a
AM
2423@@ -251,9 +251,9 @@ GLboolean radeonInitContext(radeonContextPtr radeon,
2424 radeon->texture_rect_row_align = 512;
2425 radeon->texture_compressed_row_align = 512;
2426 } else {
2427- radeon->texture_row_align = 256;
2428- radeon->texture_rect_row_align = 256;
2429- radeon->texture_compressed_row_align = 256;
2430+ radeon->texture_row_align = radeon->radeonScreen->group_bytes;
2431+ radeon->texture_rect_row_align = radeon->radeonScreen->group_bytes;
2432+ radeon->texture_compressed_row_align = radeon->radeonScreen->group_bytes;
2433 }
2434 } else if (IS_R200_CLASS(radeon->radeonScreen) ||
2435 IS_R100_CLASS(radeon->radeonScreen)) {
9caf779f
AM
2436@@ -521,6 +521,7 @@ void radeon_prepare_render(radeonContextPtr radeon)
2437 __DRIcontext *driContext = radeon->dri.context;
2438 __DRIdrawable *drawable;
2439 __DRIscreen *screen;
2440+ struct radeon_framebuffer *draw;
2441
2442 screen = driContext->driScreenPriv;
2443 if (!screen->dri2.loader)
2444@@ -531,9 +532,10 @@ void radeon_prepare_render(radeonContextPtr radeon)
2445 if (drawable->lastStamp != drawable->dri2.stamp)
2446 radeon_update_renderbuffers(driContext, drawable, GL_FALSE);
2447
2448- /* Intel driver does the equivalent of this, no clue if it is needed:
2449- * radeon_draw_buffer(radeon->glCtx, &(drawable->driverPrivate)->base);
2450- */
2451+ /* Intel driver does the equivalent of this, no clue if it is needed:*/
2452+ draw = drawable->driverPrivate;
2453+ radeon_draw_buffer(radeon->glCtx, &draw->base);
2454+
2455 driContext->dri2.draw_stamp = drawable->dri2.stamp;
2456 }
2457
7959a51a
AM
2458@@ -738,10 +740,9 @@ radeon_update_renderbuffers(__DRIcontext *context, __DRIdrawable *drawable,
2459 buffers[i].flags);
2460
2461 if (bo == NULL) {
2462-
2463 fprintf(stderr, "failed to attach %s %d\n",
2464 regname, buffers[i].name);
2465-
2466+ continue;
2467 }
2468
2469 ret = radeon_bo_get_tiling(bo, &tiling_flags, &pitch);
2470diff --git a/src/mesa/drivers/dri/radeon/radeon_screen.c b/src/mesa/drivers/dri/radeon/radeon_screen.c
2471index 2ea77e5..0ca052d 100644
2472--- a/src/mesa/drivers/dri/radeon/radeon_screen.c
2473+++ b/src/mesa/drivers/dri/radeon/radeon_screen.c
2474@@ -1138,6 +1138,8 @@ radeonCreateScreen( __DRIscreen *sPriv )
2475 else
2476 screen->chip_flags |= RADEON_CLASS_R600;
2477
2478+ /* set group bytes for r6xx+ */
2479+ screen->group_bytes = 256;
2480 screen->cpp = dri_priv->bpp / 8;
2481 screen->AGPMode = dri_priv->AGPMode;
2482
2483@@ -1382,7 +1384,8 @@ radeonCreateScreen2(__DRIscreen *sPriv)
2484 else
2485 screen->chip_flags |= RADEON_CLASS_R600;
2486
2487- /* r6xx+ tiling */
2488+ /* r6xx+ tiling, default to 256 group bytes */
2489+ screen->group_bytes = 256;
2490 if (IS_R600_CLASS(screen) && (sPriv->drm_version.minor >= 6)) {
2491 ret = radeonGetParam(sPriv, RADEON_INFO_TILE_CONFIG, &temp);
2492 if (ret)
2493diff --git a/src/mesa/drivers/dri/radeon/radeon_swtcl.c b/src/mesa/drivers/dri/radeon/radeon_swtcl.c
2494index 29defe7..0a81843 100644
2495--- a/src/mesa/drivers/dri/radeon/radeon_swtcl.c
2496+++ b/src/mesa/drivers/dri/radeon/radeon_swtcl.c
2497@@ -412,6 +412,8 @@ static GLboolean radeon_run_render( GLcontext *ctx,
2498 return GL_TRUE;
2499
2500 radeon_prepare_render(&rmesa->radeon);
2501+ if (rmesa->radeon.NewGLState)
2502+ radeonValidateState( ctx );
2503
2504 tnl->Driver.Render.Start( ctx );
2505
2506diff --git a/src/mesa/drivers/dri/radeon/radeon_tcl.c b/src/mesa/drivers/dri/radeon/radeon_tcl.c
2507index 5e1718f..ded3ebe 100644
2508--- a/src/mesa/drivers/dri/radeon/radeon_tcl.c
2509+++ b/src/mesa/drivers/dri/radeon/radeon_tcl.c
2510@@ -253,6 +253,8 @@ void radeonTclPrimitive( GLcontext *ctx,
2511 GLuint newprim = hw_prim | RADEON_CP_VC_CNTL_TCL_ENABLE;
2512
2513 radeon_prepare_render(&rmesa->radeon);
2514+ if (rmesa->radeon.NewGLState)
2515+ radeonValidateState( ctx );
2516
2517 if (newprim != rmesa->tcl.hw_primitive ||
2518 !discrete_prim[hw_prim&0xf]) {
c3c893c6
AM
2519diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c
2520index 4797f29..d9eaada 100644
2521--- a/src/mesa/main/bufferobj.c
2522+++ b/src/mesa/main/bufferobj.c
2523@@ -55,6 +55,13 @@
2524
2525
2526 /**
2527+ * Used as a placeholder for buffer objects between glGenBuffers() and
2528+ * glBindBuffer() so that glIsBuffer() can work correctly.
2529+ */
2530+static struct gl_buffer_object DummyBufferObject;
2531+
2532+
2533+/**
2534 * Return pointer to address of a buffer object target.
2535 * \param ctx the GL context
2536 * \param target the buffer object target to be retrieved.
2537@@ -554,6 +561,9 @@ _mesa_copy_buffer_subdata(GLcontext *ctx,
2538 void
2539 _mesa_init_buffer_objects( GLcontext *ctx )
2540 {
2541+ memset(&DummyBufferObject, 0, sizeof(DummyBufferObject));
2542+ DummyBufferObject.RefCount = 1000*1000*1000; /* never delete */
2543+
2544 _mesa_reference_buffer_object(ctx, &ctx->Array.ArrayBufferObj,
2545 ctx->Shared->NullBufferObj);
2546 _mesa_reference_buffer_object(ctx, &ctx->Array.ElementArrayBufferObj,
2547@@ -611,8 +621,10 @@ bind_buffer_object(GLcontext *ctx, GLenum target, GLuint buffer)
2548 else {
2549 /* non-default buffer object */
2550 newBufObj = _mesa_lookup_bufferobj(ctx, buffer);
2551- if (!newBufObj) {
2552- /* if this is a new buffer object id, allocate a buffer object now */
2553+ if (!newBufObj || newBufObj == &DummyBufferObject) {
2554+ /* If this is a new buffer object id, or one which was generated but
2555+ * never used before, allocate a buffer object now.
2556+ */
2557 ASSERT(ctx->Driver.NewBufferObject);
2558 newBufObj = ctx->Driver.NewBufferObject(ctx, buffer, target);
2559 if (!newBufObj) {
2560@@ -992,7 +1004,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
2561 struct gl_array_object *arrayObj = ctx->Array.ArrayObj;
2562 GLuint j;
2563
2564- ASSERT(bufObj->Name == ids[i]);
2565+ ASSERT(bufObj->Name == ids[i] || bufObj == &DummyBufferObject);
2566
2567 if (_mesa_bufferobj_mapped(bufObj)) {
2568 /* if mapped, unmap it now */
2569@@ -1033,7 +1045,7 @@ _mesa_DeleteBuffersARB(GLsizei n, const GLuint *ids)
2570 }
2571
2572 /* The ID is immediately freed for re-use */
2573- _mesa_HashRemove(ctx->Shared->BufferObjects, bufObj->Name);
2574+ _mesa_HashRemove(ctx->Shared->BufferObjects, ids[i]);
2575 _mesa_reference_buffer_object(ctx, &bufObj, NULL);
2576 }
2577 }
2578@@ -1072,18 +1084,10 @@ _mesa_GenBuffersARB(GLsizei n, GLuint *buffer)
2579
2580 first = _mesa_HashFindFreeKeyBlock(ctx->Shared->BufferObjects, n);
2581
2582- /* Allocate new, empty buffer objects and return identifiers */
2583+ /* Insert the ID and pointer to dummy buffer object into hash table */
2584 for (i = 0; i < n; i++) {
2585- struct gl_buffer_object *bufObj;
2586- GLuint name = first + i;
2587- GLenum target = 0;
2588- bufObj = ctx->Driver.NewBufferObject( ctx, name, target );
2589- if (!bufObj) {
2590- _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
2591- _mesa_error(ctx, GL_OUT_OF_MEMORY, "glGenBuffersARB");
2592- return;
2593- }
2594- _mesa_HashInsert(ctx->Shared->BufferObjects, first + i, bufObj);
2595+ _mesa_HashInsert(ctx->Shared->BufferObjects, first + i,
2596+ &DummyBufferObject);
2597 buffer[i] = first + i;
2598 }
2599
2600@@ -1109,7 +1113,7 @@ _mesa_IsBufferARB(GLuint id)
2601 bufObj = _mesa_lookup_bufferobj(ctx, id);
2602 _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex);
2603
2604- return bufObj ? GL_TRUE : GL_FALSE;
2605+ return bufObj && bufObj != &DummyBufferObject;
2606 }
2607
2608
2609diff --git a/src/mesa/main/formats.c b/src/mesa/main/formats.c
2610index 9db9f1c..c3fe8a3 100644
2611--- a/src/mesa/main/formats.c
2612+++ b/src/mesa/main/formats.c
2613@@ -1109,6 +1109,7 @@ _mesa_format_to_type_and_comps(gl_format format,
2614 case MESA_FORMAT_ARGB8888:
2615 case MESA_FORMAT_ARGB8888_REV:
2616 case MESA_FORMAT_XRGB8888:
2617+ case MESA_FORMAT_XRGB8888_REV:
2618 *datatype = GL_UNSIGNED_BYTE;
2619 *comps = 4;
2620 return;
2621@@ -1135,6 +1136,11 @@ _mesa_format_to_type_and_comps(gl_format format,
2622 *comps = 4;
2623 return;
2624
2625+ case MESA_FORMAT_RGBA5551:
2626+ *datatype = GL_UNSIGNED_SHORT_5_5_5_1;
2627+ *comps = 4;
2628+ return;
2629+
2630 case MESA_FORMAT_AL88:
2631 case MESA_FORMAT_AL88_REV:
2632 *datatype = GL_UNSIGNED_BYTE;
2633@@ -1156,6 +1162,7 @@ _mesa_format_to_type_and_comps(gl_format format,
2634 case MESA_FORMAT_L8:
2635 case MESA_FORMAT_I8:
2636 case MESA_FORMAT_CI8:
2637+ case MESA_FORMAT_S8:
2638 *datatype = GL_UNSIGNED_BYTE;
2639 *comps = 1;
2640 return;
2641@@ -1201,12 +1208,26 @@ _mesa_format_to_type_and_comps(gl_format format,
2642 *comps = 2;
2643 return;
2644
2645+ case MESA_FORMAT_SIGNED_R8:
2646+ *datatype = GL_BYTE;
2647+ *comps = 1;
2648+ return;
2649+ case MESA_FORMAT_SIGNED_RG88:
2650+ *datatype = GL_BYTE;
2651+ *comps = 2;
2652+ return;
2653 case MESA_FORMAT_SIGNED_RGBA8888:
2654 case MESA_FORMAT_SIGNED_RGBA8888_REV:
2655+ case MESA_FORMAT_SIGNED_RGBX8888:
2656 *datatype = GL_BYTE;
2657 *comps = 4;
2658 return;
2659
2660+ case MESA_FORMAT_RGBA_16:
2661+ *datatype = GL_UNSIGNED_SHORT;
2662+ *comps = 4;
2663+ return;
2664+
2665 case MESA_FORMAT_SIGNED_R_16:
2666 *datatype = GL_SHORT;
2667 *comps = 1;
2668@@ -1331,9 +1352,14 @@ _mesa_format_to_type_and_comps(gl_format format,
2669 *comps = 4;
2670 return;
2671
2672-
2673+ case MESA_FORMAT_NONE:
2674+ case MESA_FORMAT_COUNT:
2675+ /* For debug builds, warn if any formats are not handled */
2676+#ifndef DEBUG
2677 default:
2678- _mesa_problem(NULL, "bad format in _mesa_format_to_type_and_comps");
2679+#endif
2680+ _mesa_problem(NULL, "bad format %s in _mesa_format_to_type_and_comps",
2681+ _mesa_get_format_name(format));
2682 *datatype = 0;
2683 *comps = 1;
2684 }
25bb03e4
AM
2685diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c
2686index 46e5c93..13dabde 100644
2687--- a/src/mesa/main/imports.c
2688+++ b/src/mesa/main/imports.c
2689@@ -88,7 +88,8 @@ _mesa_align_malloc(size_t bytes, unsigned long alignment)
2690 #if defined(HAVE_POSIX_MEMALIGN)
2691 void *mem;
2692 int err = posix_memalign(& mem, alignment, bytes);
2693- (void) err;
2694+ if (err)
2695+ return NULL;
2696 return mem;
2697 #elif defined(_WIN32) && defined(_MSC_VER)
2698 return _aligned_malloc(bytes, alignment);
7959a51a 2699diff --git a/src/mesa/main/mipmap.c b/src/mesa/main/mipmap.c
c3c893c6 2700index 3d1a4c4..71aa8c2 100644
7959a51a
AM
2701--- a/src/mesa/main/mipmap.c
2702+++ b/src/mesa/main/mipmap.c
c3c893c6
AM
2703@@ -288,6 +288,54 @@ do_row(GLenum datatype, GLuint comps, GLint srcWidth,
2704 dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4;
2705 }
2706 }
2707+
2708+ else if (datatype == GL_SHORT && comps == 4) {
2709+ GLuint i, j, k;
2710+ const GLshort(*rowA)[4] = (const GLshort(*)[4]) srcRowA;
2711+ const GLshort(*rowB)[4] = (const GLshort(*)[4]) srcRowB;
2712+ GLshort(*dst)[4] = (GLshort(*)[4]) dstRow;
2713+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2714+ i++, j += colStride, k += colStride) {
2715+ dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4;
2716+ dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4;
2717+ dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4;
2718+ dst[i][3] = (rowA[j][3] + rowA[k][3] + rowB[j][3] + rowB[k][3]) / 4;
2719+ }
2720+ }
2721+ else if (datatype == GL_SHORT && comps == 3) {
2722+ GLuint i, j, k;
2723+ const GLshort(*rowA)[3] = (const GLshort(*)[3]) srcRowA;
2724+ const GLshort(*rowB)[3] = (const GLshort(*)[3]) srcRowB;
2725+ GLshort(*dst)[3] = (GLshort(*)[3]) dstRow;
2726+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2727+ i++, j += colStride, k += colStride) {
2728+ dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4;
2729+ dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4;
2730+ dst[i][2] = (rowA[j][2] + rowA[k][2] + rowB[j][2] + rowB[k][2]) / 4;
2731+ }
2732+ }
2733+ else if (datatype == GL_SHORT && comps == 2) {
2734+ GLuint i, j, k;
2735+ const GLshort(*rowA)[2] = (const GLshort(*)[2]) srcRowA;
2736+ const GLshort(*rowB)[2] = (const GLshort(*)[2]) srcRowB;
2737+ GLshort(*dst)[2] = (GLshort(*)[2]) dstRow;
2738+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2739+ i++, j += colStride, k += colStride) {
2740+ dst[i][0] = (rowA[j][0] + rowA[k][0] + rowB[j][0] + rowB[k][0]) / 4;
2741+ dst[i][1] = (rowA[j][1] + rowA[k][1] + rowB[j][1] + rowB[k][1]) / 4;
2742+ }
2743+ }
2744+ else if (datatype == GL_SHORT && comps == 1) {
2745+ GLuint i, j, k;
2746+ const GLshort *rowA = (const GLshort *) srcRowA;
2747+ const GLshort *rowB = (const GLshort *) srcRowB;
2748+ GLshort *dst = (GLshort *) dstRow;
2749+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2750+ i++, j += colStride, k += colStride) {
2751+ dst[i] = (rowA[j] + rowA[k] + rowB[j] + rowB[k]) / 4;
2752+ }
2753+ }
2754+
2755 else if (datatype == GL_FLOAT && comps == 4) {
2756 GLuint i, j, k;
2757 const GLfloat(*rowA)[4] = (const GLfloat(*)[4]) srcRowA;
2758@@ -507,6 +555,37 @@ do_row(GLenum datatype, GLuint comps, GLint srcWidth,
2759 dst[i] = (alpha << 15) | (blue << 10) | (green << 5) | red;
2760 }
2761 }
2762+ else if (datatype == GL_UNSIGNED_SHORT_5_5_5_1 && comps == 4) {
2763+ GLuint i, j, k;
2764+ const GLushort *rowA = (const GLushort *) srcRowA;
2765+ const GLushort *rowB = (const GLushort *) srcRowB;
2766+ GLushort *dst = (GLushort *) dstRow;
2767+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2768+ i++, j += colStride, k += colStride) {
2769+ const GLint rowAr0 = (rowA[j] >> 11) & 0x1f;
2770+ const GLint rowAr1 = (rowA[k] >> 11) & 0x1f;
2771+ const GLint rowBr0 = (rowB[j] >> 11) & 0x1f;
2772+ const GLint rowBr1 = (rowB[k] >> 11) & 0x1f;
2773+ const GLint rowAg0 = (rowA[j] >> 6) & 0x1f;
2774+ const GLint rowAg1 = (rowA[k] >> 6) & 0x1f;
2775+ const GLint rowBg0 = (rowB[j] >> 6) & 0x1f;
2776+ const GLint rowBg1 = (rowB[k] >> 6) & 0x1f;
2777+ const GLint rowAb0 = (rowA[j] >> 1) & 0x1f;
2778+ const GLint rowAb1 = (rowA[k] >> 1) & 0x1f;
2779+ const GLint rowBb0 = (rowB[j] >> 1) & 0x1f;
2780+ const GLint rowBb1 = (rowB[k] >> 1) & 0x1f;
2781+ const GLint rowAa0 = (rowA[j] & 0x1);
2782+ const GLint rowAa1 = (rowA[k] & 0x1);
2783+ const GLint rowBa0 = (rowB[j] & 0x1);
2784+ const GLint rowBa1 = (rowB[k] & 0x1);
2785+ const GLint red = (rowAr0 + rowAr1 + rowBr0 + rowBr1) >> 2;
2786+ const GLint green = (rowAg0 + rowAg1 + rowBg0 + rowBg1) >> 2;
2787+ const GLint blue = (rowAb0 + rowAb1 + rowBb0 + rowBb1) >> 2;
2788+ const GLint alpha = (rowAa0 + rowAa1 + rowBa0 + rowBa1) >> 2;
2789+ dst[i] = (red << 11) | (green << 6) | (blue << 1) | alpha;
2790+ }
2791+ }
2792+
2793 else if (datatype == GL_UNSIGNED_BYTE_3_3_2 && comps == 3) {
2794 GLuint i, j, k;
2795 const GLubyte *rowA = (const GLubyte *) srcRowA;
2796@@ -606,7 +685,7 @@ do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth,
7959a51a
AM
2797 FILTER_3D(0);
2798 }
2799 }
2800- if ((datatype == GL_BYTE) && (comps == 4)) {
2801+ else if ((datatype == GL_BYTE) && (comps == 4)) {
2802 DECLARE_ROW_POINTERS(GLbyte, 4);
2803
2804 for (i = j = 0, k = k0; i < (GLuint) dstWidth;
c3c893c6
AM
2805@@ -682,6 +761,44 @@ do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth,
2806 FILTER_3D(0);
2807 }
2808 }
2809+ else if ((datatype == GL_SHORT) && (comps == 4)) {
2810+ DECLARE_ROW_POINTERS(GLshort, 4);
2811+
2812+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2813+ i++, j += colStride, k += colStride) {
2814+ FILTER_3D(0);
2815+ FILTER_3D(1);
2816+ FILTER_3D(2);
2817+ FILTER_3D(3);
2818+ }
2819+ }
2820+ else if ((datatype == GL_SHORT) && (comps == 3)) {
2821+ DECLARE_ROW_POINTERS(GLshort, 3);
2822+
2823+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2824+ i++, j += colStride, k += colStride) {
2825+ FILTER_3D(0);
2826+ FILTER_3D(1);
2827+ FILTER_3D(2);
2828+ }
2829+ }
2830+ else if ((datatype == GL_SHORT) && (comps == 2)) {
2831+ DECLARE_ROW_POINTERS(GLshort, 2);
2832+
2833+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2834+ i++, j += colStride, k += colStride) {
2835+ FILTER_3D(0);
2836+ FILTER_3D(1);
2837+ }
2838+ }
2839+ else if ((datatype == GL_SHORT) && (comps == 1)) {
2840+ DECLARE_ROW_POINTERS(GLshort, 1);
2841+
2842+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2843+ i++, j += colStride, k += colStride) {
2844+ FILTER_3D(0);
2845+ }
2846+ }
2847 else if ((datatype == GL_FLOAT) && (comps == 4)) {
2848 DECLARE_ROW_POINTERS(GLfloat, 4);
2849
2850@@ -910,6 +1027,55 @@ do_row_3D(GLenum datatype, GLuint comps, GLint srcWidth,
2851 dst[i] = (a << 15) | (b << 10) | (g << 5) | r;
2852 }
2853 }
2854+ else if ((datatype == GL_UNSIGNED_SHORT_5_5_5_1) && (comps == 4)) {
2855+ DECLARE_ROW_POINTERS0(GLushort);
2856+
2857+ for (i = j = 0, k = k0; i < (GLuint) dstWidth;
2858+ i++, j += colStride, k += colStride) {
2859+ const GLint rowAr0 = (rowA[j] >> 11) & 0x1f;
2860+ const GLint rowAr1 = (rowA[k] >> 11) & 0x1f;
2861+ const GLint rowBr0 = (rowB[j] >> 11) & 0x1f;
2862+ const GLint rowBr1 = (rowB[k] >> 11) & 0x1f;
2863+ const GLint rowCr0 = (rowC[j] >> 11) & 0x1f;
2864+ const GLint rowCr1 = (rowC[k] >> 11) & 0x1f;
2865+ const GLint rowDr0 = (rowD[j] >> 11) & 0x1f;
2866+ const GLint rowDr1 = (rowD[k] >> 11) & 0x1f;
2867+ const GLint rowAg0 = (rowA[j] >> 6) & 0x1f;
2868+ const GLint rowAg1 = (rowA[k] >> 6) & 0x1f;
2869+ const GLint rowBg0 = (rowB[j] >> 6) & 0x1f;
2870+ const GLint rowBg1 = (rowB[k] >> 6) & 0x1f;
2871+ const GLint rowCg0 = (rowC[j] >> 6) & 0x1f;
2872+ const GLint rowCg1 = (rowC[k] >> 6) & 0x1f;
2873+ const GLint rowDg0 = (rowD[j] >> 6) & 0x1f;
2874+ const GLint rowDg1 = (rowD[k] >> 6) & 0x1f;
2875+ const GLint rowAb0 = (rowA[j] >> 1) & 0x1f;
2876+ const GLint rowAb1 = (rowA[k] >> 1) & 0x1f;
2877+ const GLint rowBb0 = (rowB[j] >> 1) & 0x1f;
2878+ const GLint rowBb1 = (rowB[k] >> 1) & 0x1f;
2879+ const GLint rowCb0 = (rowC[j] >> 1) & 0x1f;
2880+ const GLint rowCb1 = (rowC[k] >> 1) & 0x1f;
2881+ const GLint rowDb0 = (rowD[j] >> 1) & 0x1f;
2882+ const GLint rowDb1 = (rowD[k] >> 1) & 0x1f;
2883+ const GLint rowAa0 = (rowA[j] & 0x1);
2884+ const GLint rowAa1 = (rowA[k] & 0x1);
2885+ const GLint rowBa0 = (rowB[j] & 0x1);
2886+ const GLint rowBa1 = (rowB[k] & 0x1);
2887+ const GLint rowCa0 = (rowC[j] & 0x1);
2888+ const GLint rowCa1 = (rowC[k] & 0x1);
2889+ const GLint rowDa0 = (rowD[j] & 0x1);
2890+ const GLint rowDa1 = (rowD[k] & 0x1);
2891+ const GLint r = FILTER_SUM_3D(rowAr0, rowAr1, rowBr0, rowBr1,
2892+ rowCr0, rowCr1, rowDr0, rowDr1);
2893+ const GLint g = FILTER_SUM_3D(rowAg0, rowAg1, rowBg0, rowBg1,
2894+ rowCg0, rowCg1, rowDg0, rowDg1);
2895+ const GLint b = FILTER_SUM_3D(rowAb0, rowAb1, rowBb0, rowBb1,
2896+ rowCb0, rowCb1, rowDb0, rowDb1);
2897+ const GLint a = FILTER_SUM_3D(rowAa0, rowAa1, rowBa0, rowBa1,
2898+ rowCa0, rowCa1, rowDa0, rowDa1);
2899+
2900+ dst[i] = (r << 11) | (g << 6) | (b << 1) | a;
2901+ }
2902+ }
2903 else if ((datatype == GL_UNSIGNED_BYTE_3_3_2) && (comps == 3)) {
2904 DECLARE_ROW_POINTERS0(GLushort);
2905
aba744d1
AM
2906diff --git a/src/mesa/program/prog_statevars.c b/src/mesa/program/prog_statevars.c
2907index 2687f8a..778447d 100644
2908--- a/src/mesa/program/prog_statevars.c
2909+++ b/src/mesa/program/prog_statevars.c
2910@@ -584,6 +584,24 @@ _mesa_fetch_state(GLcontext *ctx, const gl_state_index state[],
2911 value[3] = 0.0F;
2912 return;
2913
2914+ case STATE_FB_WPOS_Y_TRANSFORM:
2915+ /* A driver may negate this conditional by using ZW swizzle
2916+ * instead of XY (based on e.g. some other state). */
2917+ if (ctx->DrawBuffer->Name != 0) {
2918+ /* Identity (XY) followed by flipping Y upside down (ZW). */
2919+ value[0] = 1.0F;
2920+ value[1] = 0.0F;
2921+ value[2] = -1.0F;
2922+ value[3] = (GLfloat) (ctx->DrawBuffer->Height - 1);
2923+ } else {
2924+ /* Flipping Y upside down (XY) followed by identity (ZW). */
2925+ value[0] = -1.0F;
2926+ value[1] = (GLfloat) (ctx->DrawBuffer->Height - 1);
2927+ value[2] = 1.0F;
2928+ value[3] = 0.0F;
2929+ }
2930+ return;
2931+
2932 case STATE_ROT_MATRIX_0:
2933 {
2934 const int unit = (int) state[2];
2935@@ -711,6 +729,7 @@ _mesa_program_state_flags(const gl_state_index state[STATE_LENGTH])
2936 return _NEW_PIXEL;
2937
2938 case STATE_FB_SIZE:
2939+ case STATE_FB_WPOS_Y_TRANSFORM:
2940 return _NEW_BUFFERS;
2941
2942 default:
2943@@ -925,6 +944,9 @@ append_token(char *dst, gl_state_index k)
2944 case STATE_FB_SIZE:
2945 append(dst, "FbSize");
2946 break;
2947+ case STATE_FB_WPOS_Y_TRANSFORM:
2948+ append(dst, "FbWposYTransform");
2949+ break;
2950 case STATE_ROT_MATRIX_0:
2951 append(dst, "rotMatrixRow0");
2952 break;
2953diff --git a/src/mesa/program/prog_statevars.h b/src/mesa/program/prog_statevars.h
2954index 1753471..82712c5 100644
2955--- a/src/mesa/program/prog_statevars.h
2956+++ b/src/mesa/program/prog_statevars.h
2957@@ -120,6 +120,7 @@ typedef enum gl_state_index_ {
2958 STATE_PCM_BIAS, /**< Post color matrix RGBA bias */
2959 STATE_SHADOW_AMBIENT, /**< ARB_shadow_ambient fail value; token[2] is texture unit index */
2960 STATE_FB_SIZE, /**< (width-1, height-1, 0, 0) */
2961+ STATE_FB_WPOS_Y_TRANSFORM, /**< (1, 0, -1, height-1) if a FBO is bound, (-1, height-1, 1, 0) otherwise */
2962 STATE_ROT_MATRIX_0, /**< ATI_envmap_bumpmap, rot matrix row 0 */
2963 STATE_ROT_MATRIX_1, /**< ATI_envmap_bumpmap, rot matrix row 1 */
2964 STATE_INTERNAL_DRIVER /* first available state index for drivers (must be last) */
25bb03e4
AM
2965diff --git a/src/mesa/state_tracker/st_cb_bufferobjects.c b/src/mesa/state_tracker/st_cb_bufferobjects.c
2966index 7991a93..50b352c 100644
2967--- a/src/mesa/state_tracker/st_cb_bufferobjects.c
2968+++ b/src/mesa/state_tracker/st_cb_bufferobjects.c
2969@@ -211,6 +211,13 @@ st_bufferobj_data(GLcontext *ctx,
2970
2971
2972 /**
2973+ * Dummy data whose's pointer is used for zero size buffers or ranges.
2974+ */
2975+static long st_bufferobj_zero_length = 0;
2976+
2977+
2978+
2979+/**
2980 * Called via glMapBufferARB().
2981 */
2982 static void *
2983@@ -233,10 +240,16 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
2984 break;
2985 }
2986
2987- obj->Pointer = pipe_buffer_map(st_context(ctx)->pipe,
2988- st_obj->buffer,
2989- flags,
2990- &st_obj->transfer);
2991+ /* Handle zero-size buffers here rather than in drivers */
2992+ if (obj->Size == 0) {
2993+ obj->Pointer = &st_bufferobj_zero_length;
2994+ }
2995+ else {
2996+ obj->Pointer = pipe_buffer_map(st_context(ctx)->pipe,
2997+ st_obj->buffer,
2998+ flags,
2999+ &st_obj->transfer);
3000+ }
3001
3002 if (obj->Pointer) {
3003 obj->Offset = 0;
3004@@ -247,13 +260,6 @@ st_bufferobj_map(GLcontext *ctx, GLenum target, GLenum access,
3005
3006
3007 /**
3008- * Dummy data whose's pointer is used for zero length ranges.
3009- */
3010-static long
3011-st_bufferobj_zero_length_range = 0;
3012-
3013-
3014-/**
3015 * Called via glMapBufferRange().
3016 */
3017 static void *
3018@@ -293,7 +299,7 @@ st_bufferobj_map_range(GLcontext *ctx, GLenum target,
3019 * length range from the pipe driver.
3020 */
3021 if (!length) {
3022- obj->Pointer = &st_bufferobj_zero_length_range;
3023+ obj->Pointer = &st_bufferobj_zero_length;
3024 }
3025 else {
3026 obj->Pointer = pipe_buffer_map_range(pipe,
c3c893c6
AM
3027diff --git a/src/mesa/state_tracker/st_cb_eglimage.c b/src/mesa/state_tracker/st_cb_eglimage.c
3028index 3145416..c54baf4 100644
3029--- a/src/mesa/state_tracker/st_cb_eglimage.c
3030+++ b/src/mesa/state_tracker/st_cb_eglimage.c
3031@@ -129,6 +129,7 @@ st_bind_surface(GLcontext *ctx, GLenum target,
3032
3033 /* FIXME create a non-default sampler view from the pipe_surface? */
3034 pipe_resource_reference(&stObj->pt, ps->texture);
3035+ pipe_sampler_view_reference(&stObj->sampler_view, NULL);
3036 pipe_resource_reference(&stImage->pt, stObj->pt);
3037
3038 stObj->width0 = ps->width;
9caf779f
AM
3039diff --git a/src/mesa/state_tracker/st_manager.c b/src/mesa/state_tracker/st_manager.c
3040index 66e32b4..cd418a0 100644
3041--- a/src/mesa/state_tracker/st_manager.c
3042+++ b/src/mesa/state_tracker/st_manager.c
3043@@ -486,9 +486,18 @@ st_context_notify_invalid_framebuffer(struct st_context_iface *stctxi,
3044 stfb = st_ws_framebuffer(st->ctx->WinSysDrawBuffer);
3045 if (!stfb || stfb->iface != stfbi)
3046 stfb = st_ws_framebuffer(st->ctx->WinSysReadBuffer);
3047- assert(stfb && stfb->iface == stfbi);
3048
3049- p_atomic_set(&stfb->revalidate, TRUE);
3050+ if (stfb && stfb->iface == stfbi) {
3051+ p_atomic_set(&stfb->revalidate, TRUE);
3052+ }
3053+ else {
3054+ /* This function is probably getting called when we've detected a
3055+ * change in a window's size but the currently bound context is
3056+ * not bound to that window.
3057+ * If the st_framebuffer_iface structure had a pointer to the
3058+ * corresponding st_framebuffer we'd be able to handle this.
3059+ */
3060+ }
3061 }
3062
3063 static void
aba744d1
AM
3064diff --git a/src/mesa/state_tracker/st_mesa_to_tgsi.c b/src/mesa/state_tracker/st_mesa_to_tgsi.c
3065index 0ed822b..2712717 100644
3066--- a/src/mesa/state_tracker/st_mesa_to_tgsi.c
3067+++ b/src/mesa/state_tracker/st_mesa_to_tgsi.c
3068@@ -760,10 +760,13 @@ emit_adjusted_wpos( struct st_translate *t,
3069
3070 /**
3071 * Emit the TGSI instructions for inverting the WPOS y coordinate.
3072+ * This code is unavoidable because it also depends on whether
3073+ * a FBO is bound (STATE_FB_WPOS_Y_TRANSFORM).
3074 */
3075 static void
3076-emit_inverted_wpos( struct st_translate *t,
3077- const struct gl_program *program )
3078+emit_wpos_inversion( struct st_translate *t,
3079+ const struct gl_program *program,
3080+ boolean invert)
3081 {
3082 struct ureg_program *ureg = t->ureg;
3083
3084@@ -771,17 +774,17 @@ emit_inverted_wpos( struct st_translate *t,
3085 * Need to replace instances of INPUT[WPOS] with temp T
3086 * where T = INPUT[WPOS] by y is inverted.
3087 */
3088- static const gl_state_index winSizeState[STATE_LENGTH]
3089- = { STATE_INTERNAL, STATE_FB_SIZE, 0, 0, 0 };
3090+ static const gl_state_index wposTransformState[STATE_LENGTH]
3091+ = { STATE_INTERNAL, STATE_FB_WPOS_Y_TRANSFORM, 0, 0, 0 };
3092
3093 /* XXX: note we are modifying the incoming shader here! Need to
3094 * do this before emitting the constant decls below, or this
3095 * will be missed:
3096 */
3097- unsigned winHeightConst = _mesa_add_state_reference(program->Parameters,
3098- winSizeState);
3099+ unsigned wposTransConst = _mesa_add_state_reference(program->Parameters,
3100+ wposTransformState);
3101
3102- struct ureg_src winsize = ureg_DECL_constant( ureg, winHeightConst );
3103+ struct ureg_src wpostrans = ureg_DECL_constant( ureg, wposTransConst );
3104 struct ureg_dst wpos_temp;
3105 struct ureg_src wpos_input = t->inputs[t->inputMapping[FRAG_ATTRIB_WPOS]];
3106
3107@@ -794,12 +797,23 @@ emit_inverted_wpos( struct st_translate *t,
3108 ureg_MOV( ureg, wpos_temp, wpos_input );
3109 }
3110
3111- /* SUB wpos_temp.y, winsize_const, wpos_input
3112- */
3113- ureg_SUB( ureg,
3114- ureg_writemask(wpos_temp, TGSI_WRITEMASK_Y ),
3115- winsize,
3116- wpos_input);
3117+ if (invert) {
3118+ /* MAD wpos_temp.y, wpos_input, wpostrans.xxxx, wpostrans.yyyy
3119+ */
3120+ ureg_MAD( ureg,
3121+ ureg_writemask(wpos_temp, TGSI_WRITEMASK_Y ),
3122+ wpos_input,
3123+ ureg_scalar(wpostrans, 0),
3124+ ureg_scalar(wpostrans, 1));
3125+ } else {
3126+ /* MAD wpos_temp.y, wpos_input, wpostrans.zzzz, wpostrans.wwww
3127+ */
3128+ ureg_MAD( ureg,
3129+ ureg_writemask(wpos_temp, TGSI_WRITEMASK_Y ),
3130+ wpos_input,
3131+ ureg_scalar(wpostrans, 2),
3132+ ureg_scalar(wpostrans, 3));
3133+ }
3134
3135 /* Use wpos_temp as position input from here on:
3136 */
3137@@ -861,8 +875,7 @@ emit_wpos(struct st_context *st,
3138
3139 /* we invert after adjustment so that we avoid the MOV to temporary,
3140 * and reuse the adjustment ADD instead */
3141- if (invert)
3142- emit_inverted_wpos(t, program);
3143+ emit_wpos_inversion(t, program, invert);
3144 }
3145
3146
3147diff --git a/src/mesa/state_tracker/st_program.c b/src/mesa/state_tracker/st_program.c
3148index 8c2d8b6..63faa4a 100644
3149--- a/src/mesa/state_tracker/st_program.c
3150+++ b/src/mesa/state_tracker/st_program.c
3151@@ -216,6 +216,8 @@ st_translate_vertex_program(struct st_context *st,
3152 return NULL;
3153 }
3154
3155+ vpv->key = *key;
3156+
3157 vpv->num_inputs = stvp->num_inputs;
3158 num_outputs = stvp->num_outputs;
3159 if (key->passthrough_edgeflags) {
9caf779f 3160diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c
25bb03e4 3161index 3fc554c..28063e0 100644
9caf779f
AM
3162--- a/src/mesa/swrast/s_texfilter.c
3163+++ b/src/mesa/swrast/s_texfilter.c
25bb03e4
AM
3164@@ -1368,6 +1368,7 @@ opt_sample_rgb_2d(GLcontext *ctx,
3165 rgba[k][RCOMP] = UBYTE_TO_FLOAT(texel[2]);
3166 rgba[k][GCOMP] = UBYTE_TO_FLOAT(texel[1]);
3167 rgba[k][BCOMP] = UBYTE_TO_FLOAT(texel[0]);
3168+ rgba[k][ACOMP] = 1.0F;
3169 }
3170 }
3171
3172@@ -2972,11 +2973,16 @@ choose_depth_texture_level(const struct gl_texture_object *tObj, GLfloat lambda)
9caf779f
AM
3173 {
3174 GLint level;
3175
3176- lambda = CLAMP(lambda, tObj->MinLod, tObj->MaxLod);
3177-
3178- level = (GLint) lambda;
3179-
3180- level = CLAMP(level, tObj->BaseLevel, tObj->_MaxLevel);
3181+ if (tObj->MinFilter == GL_NEAREST || tObj->MinFilter == GL_LINEAR) {
3182+ /* no mipmapping - use base level */
3183+ level = tObj->BaseLevel;
3184+ }
3185+ else {
3186+ /* choose mipmap level */
3187+ lambda = CLAMP(lambda, tObj->MinLod, tObj->MaxLod);
3188+ level = (GLint) lambda;
3189+ level = CLAMP(level, tObj->BaseLevel, tObj->_MaxLevel);
3190+ }
3191
3192 return level;
3193 }
This page took 0.413152 seconds and 4 git commands to generate.