]>
Commit | Line | Data |
---|---|---|
387b119d AM |
1 | diff --git a/configs/darwin b/configs/darwin |
2 | index e2ca70a..721fbc7 100644 | |
3 | --- a/configs/darwin | |
4 | +++ b/configs/darwin | |
5 | @@ -9,8 +9,8 @@ INSTALL_DIR = /usr/X11 | |
6 | X11_DIR = $(INSTALL_DIR) | |
7 | ||
8 | # Compiler and flags | |
9 | -CC = gcc | |
10 | -CXX = g++ | |
11 | +CC = $(shell xcrun -find cc) | |
12 | +CXX = $(shell xcrun -find c++) | |
13 | PIC_FLAGS = -fPIC | |
14 | DEFINES = -D_DARWIN_C_SOURCE -DPTHREADS -D_GNU_SOURCE \ | |
15 | -DGLX_ALIAS_UNSUPPORTED \ | |
16 | @@ -24,11 +24,14 @@ DEFINES = -D_DARWIN_C_SOURCE -DPTHREADS -D_GNU_SOURCE \ | |
17 | # -DIN_DRI_DRIVER | |
18 | ||
19 | ARCH_FLAGS += $(RC_CFLAGS) | |
20 | +INCLUDE_FLAGS = -I$(INSTALL_DIR)/include -I$(X11_DIR)/include | |
21 | +OPT_FLAGS = -g3 -gdwarf-2 -Os -ffast-math -fno-strict-aliasing | |
22 | +WARN_FLAGS = -Wall -Wmissing-prototypes | |
23 | ||
24 | -CFLAGS = -ggdb3 -Os -Wall -Wmissing-prototypes -std=c99 -ffast-math -fno-strict-aliasing -fvisibility=hidden \ | |
25 | - -I$(INSTALL_DIR)/include -I$(X11_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES) | |
26 | -CXXFLAGS = -ggdb3 -Os -Wall -fno-strict-aliasing -fvisibility=hidden \ | |
27 | - -I$(INSTALL_DIR)/include -I$(X11_DIR)/include $(OPT_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES) | |
28 | +CFLAGS = -std=c99 -fvisibility=hidden \ | |
29 | + $(OPT_FLAGS) $(WARN_FLAGS) $(INCLUDE_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES) $(EXTRA_CFLAGS) | |
30 | +CXXFLAGS = -fvisibility=hidden \ | |
31 | + $(OPT_FLAGS) $(WARN_FLAGS) $(INCLUDE_FLAGS) $(PIC_FLAGS) $(ARCH_FLAGS) $(ASM_FLAGS) $(DEFINES) $(EXTRA_CFLAGS) | |
32 | ||
33 | # Library names (actual file names) | |
34 | GL_LIB_NAME = lib$(GL_LIB).dylib | |
35 | @@ -44,10 +47,10 @@ GLW_LIB_GLOB = lib$(GLW_LIB).*dylib | |
36 | OSMESA_LIB_GLOB = lib$(OSMESA_LIB).*dylib | |
37 | VG_LIB_GLOB = lib$(VG_LIB).*dylib | |
38 | ||
39 | -GL_LIB_DEPS = -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXext -lm -lpthread | |
40 | -OSMESA_LIB_DEPS = | |
41 | -GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) | |
42 | -GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXt | |
43 | +GL_LIB_DEPS = -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11-xcb -lxcb -lX11 -lXext $(EXTRA_LDFLAGS) | |
44 | +OSMESA_LIB_DEPS = $(EXTRA_LDFLAGS) | |
45 | +GLU_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) $(EXTRA_LDFLAGS) | |
46 | +GLW_LIB_DEPS = -L$(TOP)/$(LIB_DIR) -l$(GL_LIB) -L$(INSTALL_DIR)/$(LIB_DIR) -L$(X11_DIR)/$(LIB_DIR) -lX11 -lXt $(EXTRA_LDFLAGS) | |
47 | ||
48 | SRC_DIRS = glsl mapi/glapi mapi/vgapi glx/apple mesa gallium glu | |
49 | GLU_DIRS = sgi | |
50 | diff --git a/configs/darwin-fat-intel b/configs/darwin-fat-intel | |
51 | new file mode 100644 | |
52 | index 0000000..273ae3d | |
53 | --- /dev/null | |
54 | +++ b/configs/darwin-fat-intel | |
55 | @@ -0,0 +1,7 @@ | |
56 | +# Configuration for Darwin / MacOS X, making 32bit and 64bit fat dynamic libs for intel | |
57 | + | |
58 | +RC_CFLAGS=-arch i386 -arch x86_64 | |
59 | + | |
60 | +include $(TOP)/configs/darwin | |
61 | + | |
62 | +CONFIG_NAME = darwin-fat-intel | |
63 | diff --git a/docs/relnotes-8.0.1.html b/docs/relnotes-8.0.1.html | |
64 | index 8c8cd3f..29a314c 100644 | |
65 | --- a/docs/relnotes-8.0.1.html | |
66 | +++ b/docs/relnotes-8.0.1.html | |
67 | @@ -28,7 +28,9 @@ for DRI hardware acceleration. | |
68 | ||
69 | <h2>MD5 checksums</h2> | |
70 | <pre> | |
71 | -tdb | |
72 | +4855c2d93bd2ebd43f384bdcc92c9a27 MesaLib-8.0.1.tar.gz | |
73 | +24eeebf66971809d8f40775a379b36c9 MesaLib-8.0.1.tar.bz2 | |
74 | +54e745d14dac5717f7f65b4e2d5c1df2 MesaLib-8.0.1.zip | |
75 | </pre> | |
76 | ||
77 | <h2>New features</h2> | |
78 | diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h | |
79 | index 02c176e..f3a3f23 100644 | |
80 | --- a/src/gallium/auxiliary/draw/draw_context.h | |
81 | +++ b/src/gallium/auxiliary/draw/draw_context.h | |
82 | @@ -80,6 +80,21 @@ void draw_set_viewport_state( struct draw_context *draw, | |
83 | void draw_set_clip_state( struct draw_context *pipe, | |
84 | const struct pipe_clip_state *clip ); | |
85 | ||
86 | +/** | |
87 | + * Sets the rasterization state used by the draw module. | |
88 | + * The rast_handle is used to pass the driver specific representation | |
89 | + * of the rasterization state. It's going to be used when the | |
90 | + * draw module sets the state back on the driver itself using the | |
91 | + * pipe::bind_rasterizer_state method. | |
92 | + * | |
93 | + * NOTE: if you're calling this function from within the pipe's | |
94 | + * bind_rasterizer_state you should always call it before binding | |
95 | + * the actual state - that's because the draw module can try to | |
96 | + * bind its own rasterizer state which would reset your newly | |
97 | + * set state. i.e. always do | |
98 | + * draw_set_rasterizer_state(driver->draw, state->pipe_state, state); | |
99 | + * driver->state.raster = state; | |
100 | + */ | |
101 | void draw_set_rasterizer_state( struct draw_context *draw, | |
102 | const struct pipe_rasterizer_state *raster, | |
103 | void *rast_handle ); | |
104 | diff --git a/src/gallium/auxiliary/rtasm/rtasm_cpu.c b/src/gallium/auxiliary/rtasm/rtasm_cpu.c | |
105 | index 0461c81..7afcf14 100644 | |
106 | --- a/src/gallium/auxiliary/rtasm/rtasm_cpu.c | |
107 | +++ b/src/gallium/auxiliary/rtasm/rtasm_cpu.c | |
108 | @@ -25,43 +25,43 @@ | |
109 | * | |
110 | **************************************************************************/ | |
111 | ||
112 | +#include "pipe/p_config.h" | |
113 | +#include "rtasm_cpu.h" | |
114 | + | |
115 | +#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) | |
116 | ||
117 | #include "util/u_debug.h" | |
118 | -#include "rtasm_cpu.h" | |
119 | +#include "util/u_cpu_detect.h" | |
120 | ||
121 | +DEBUG_GET_ONCE_BOOL_OPTION(nosse, "GALLIUM_NOSSE", FALSE); | |
122 | ||
123 | -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) | |
124 | -static boolean rtasm_sse_enabled(void) | |
125 | +static struct util_cpu_caps *get_cpu_caps(void) | |
126 | { | |
127 | - static boolean firsttime = 1; | |
128 | - static boolean enabled; | |
129 | - | |
130 | - /* This gets called quite often at the moment: | |
131 | - */ | |
132 | - if (firsttime) { | |
133 | - enabled = !debug_get_bool_option("GALLIUM_NOSSE", FALSE); | |
134 | - firsttime = FALSE; | |
135 | - } | |
136 | - return enabled; | |
137 | + util_cpu_detect(); | |
138 | + return &util_cpu_caps; | |
139 | } | |
140 | -#endif | |
141 | ||
142 | int rtasm_cpu_has_sse(void) | |
143 | { | |
144 | - /* FIXME: actually detect this at run-time */ | |
145 | -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) | |
146 | - return rtasm_sse_enabled(); | |
147 | -#else | |
148 | - return 0; | |
149 | -#endif | |
150 | + return !debug_get_option_nosse() && get_cpu_caps()->has_sse; | |
151 | } | |
152 | ||
153 | int rtasm_cpu_has_sse2(void) | |
154 | { | |
155 | - /* FIXME: actually detect this at run-time */ | |
156 | -#if defined(PIPE_ARCH_X86) || defined(PIPE_ARCH_X86_64) | |
157 | - return rtasm_sse_enabled(); | |
158 | + return !debug_get_option_nosse() && get_cpu_caps()->has_sse2; | |
159 | +} | |
160 | + | |
161 | + | |
162 | #else | |
163 | + | |
164 | +int rtasm_cpu_has_sse(void) | |
165 | +{ | |
166 | return 0; | |
167 | -#endif | |
168 | } | |
169 | + | |
170 | +int rtasm_cpu_has_sse2(void) | |
171 | +{ | |
172 | + return 0; | |
173 | +} | |
174 | + | |
175 | +#endif | |
176 | diff --git a/src/gallium/auxiliary/util/u_debug_memory.c b/src/gallium/auxiliary/util/u_debug_memory.c | |
177 | index f1baa62..e24a8bc 100644 | |
178 | --- a/src/gallium/auxiliary/util/u_debug_memory.c | |
179 | +++ b/src/gallium/auxiliary/util/u_debug_memory.c | |
180 | @@ -38,6 +38,7 @@ | |
181 | ||
182 | #include "os/os_memory.h" | |
183 | #include "os/os_memory_debug.h" | |
184 | +#include "os/os_thread.h" | |
185 | ||
186 | #include "util/u_debug.h" | |
187 | #include "util/u_debug_stack.h" | |
188 | @@ -72,6 +73,8 @@ struct debug_memory_footer | |
189 | ||
190 | static struct list_head list = { &list, &list }; | |
191 | ||
192 | +pipe_static_mutex(list_mutex); | |
193 | + | |
194 | static unsigned long last_no = 0; | |
195 | ||
196 | ||
197 | @@ -132,7 +135,9 @@ debug_malloc(const char *file, unsigned line, const char *function, | |
198 | ftr = footer_from_header(hdr); | |
199 | ftr->magic = DEBUG_MEMORY_MAGIC; | |
200 | ||
201 | + pipe_mutex_lock(list_mutex); | |
202 | LIST_ADDTAIL(&hdr->head, &list); | |
203 | + pipe_mutex_unlock(list_mutex); | |
204 | ||
205 | return data_from_header(hdr); | |
206 | } | |
207 | @@ -164,7 +169,9 @@ debug_free(const char *file, unsigned line, const char *function, | |
208 | debug_assert(0); | |
209 | } | |
210 | ||
211 | + pipe_mutex_lock(list_mutex); | |
212 | LIST_DEL(&hdr->head); | |
213 | + pipe_mutex_unlock(list_mutex); | |
214 | hdr->magic = 0; | |
215 | ftr->magic = 0; | |
216 | ||
217 | @@ -232,7 +239,9 @@ debug_realloc(const char *file, unsigned line, const char *function, | |
218 | new_ftr = footer_from_header(new_hdr); | |
219 | new_ftr->magic = DEBUG_MEMORY_MAGIC; | |
220 | ||
221 | + pipe_mutex_lock(list_mutex); | |
222 | LIST_REPLACE(&old_hdr->head, &new_hdr->head); | |
223 | + pipe_mutex_unlock(list_mutex); | |
224 | ||
225 | /* copy data */ | |
226 | new_ptr = data_from_header(new_hdr); | |
227 | diff --git a/src/gallium/drivers/r300/compiler/radeon_program_alu.c b/src/gallium/drivers/r300/compiler/radeon_program_alu.c | |
228 | index dd1dfb3..c48f936 100644 | |
229 | --- a/src/gallium/drivers/r300/compiler/radeon_program_alu.c | |
230 | +++ b/src/gallium/drivers/r300/compiler/radeon_program_alu.c | |
231 | @@ -1165,35 +1165,79 @@ int radeonTransformDeriv(struct radeon_compiler* c, | |
232 | } | |
233 | ||
234 | /** | |
235 | + * IF Temp[0].x -> IF Temp[0].x | |
236 | + * ... -> ... | |
237 | + * KILP -> KIL -abs(Temp[0].x) | |
238 | + * ... -> ... | |
239 | + * ENDIF -> ENDIF | |
240 | + * | |
241 | + * === OR === | |
242 | + * | |
243 | * IF Temp[0].x -\ | |
244 | * KILP - > KIL -abs(Temp[0].x) | |
245 | * ENDIF -/ | |
246 | * | |
247 | - * This needs to be done in its own pass, because it modifies the instructions | |
248 | - * before and after KILP. | |
249 | + * === OR === | |
250 | + * | |
251 | + * IF Temp[0].x -> IF Temp[0].x | |
252 | + * ... -> ... | |
253 | + * ELSE -> ELSE | |
254 | + * ... -> ... | |
255 | + * KILP -> KIL -abs(Temp[0].x) | |
256 | + * ... -> ... | |
257 | + * ENDIF -> ENDIF | |
258 | + * | |
259 | + * === OR === | |
260 | + * | |
261 | + * KILP -> KIL -none.1111 | |
262 | + * | |
263 | + * This needs to be done in its own pass, because it might modify the | |
264 | + * instructions before and after KILP. | |
265 | */ | |
266 | void rc_transform_KILP(struct radeon_compiler * c, void *user) | |
267 | { | |
268 | struct rc_instruction * inst; | |
269 | for (inst = c->Program.Instructions.Next; | |
270 | inst != &c->Program.Instructions; inst = inst->Next) { | |
271 | + struct rc_instruction * if_inst; | |
272 | + unsigned in_if = 0; | |
273 | ||
274 | if (inst->U.I.Opcode != RC_OPCODE_KILP) | |
275 | continue; | |
276 | ||
277 | + for (if_inst = inst->Prev; if_inst != &c->Program.Instructions; | |
278 | + if_inst = if_inst->Prev) { | |
279 | + | |
280 | + if (if_inst->U.I.Opcode == RC_OPCODE_IF) { | |
281 | + in_if = 1; | |
282 | + break; | |
283 | + } | |
284 | + } | |
285 | + | |
286 | inst->U.I.Opcode = RC_OPCODE_KIL; | |
287 | ||
288 | - if (inst->Prev->U.I.Opcode != RC_OPCODE_IF | |
289 | - || inst->Next->U.I.Opcode != RC_OPCODE_ENDIF) { | |
290 | + if (!in_if) { | |
291 | inst->U.I.SrcReg[0] = negate(builtin_one); | |
292 | } else { | |
293 | - | |
294 | + /* This should work even if the KILP is inside the ELSE | |
295 | + * block, because -0.0 is considered negative. */ | |
296 | inst->U.I.SrcReg[0] = | |
297 | - negate(absolute(inst->Prev->U.I.SrcReg[0])); | |
298 | - /* Remove IF */ | |
299 | - rc_remove_instruction(inst->Prev); | |
300 | - /* Remove ENDIF */ | |
301 | - rc_remove_instruction(inst->Next); | |
302 | + negate(absolute(if_inst->U.I.SrcReg[0])); | |
303 | + | |
304 | + if (inst->Prev->U.I.Opcode != RC_OPCODE_IF | |
305 | + && inst->Next->U.I.Opcode != RC_OPCODE_ENDIF) { | |
306 | + | |
307 | + /* Optimize the special case: | |
308 | + * IF Temp[0].x | |
309 | + * KILP | |
310 | + * ENDIF | |
311 | + */ | |
312 | + | |
313 | + /* Remove IF */ | |
314 | + rc_remove_instruction(inst->Prev); | |
315 | + /* Remove ENDIF */ | |
316 | + rc_remove_instruction(inst->Next); | |
317 | + } | |
318 | } | |
319 | } | |
320 | } | |
321 | diff --git a/src/gallium/drivers/svga/svga_pipe_depthstencil.c b/src/gallium/drivers/svga/svga_pipe_depthstencil.c | |
322 | index c84615a..cb07dbe 100644 | |
323 | --- a/src/gallium/drivers/svga/svga_pipe_depthstencil.c | |
324 | +++ b/src/gallium/drivers/svga/svga_pipe_depthstencil.c | |
325 | @@ -57,10 +57,10 @@ svga_translate_stencil_op(unsigned op) | |
326 | case PIPE_STENCIL_OP_KEEP: return SVGA3D_STENCILOP_KEEP; | |
327 | case PIPE_STENCIL_OP_ZERO: return SVGA3D_STENCILOP_ZERO; | |
328 | case PIPE_STENCIL_OP_REPLACE: return SVGA3D_STENCILOP_REPLACE; | |
329 | - case PIPE_STENCIL_OP_INCR: return SVGA3D_STENCILOP_INCR; | |
330 | - case PIPE_STENCIL_OP_DECR: return SVGA3D_STENCILOP_DECR; | |
331 | - case PIPE_STENCIL_OP_INCR_WRAP: return SVGA3D_STENCILOP_INCRSAT; /* incorrect? */ | |
332 | - case PIPE_STENCIL_OP_DECR_WRAP: return SVGA3D_STENCILOP_DECRSAT; /* incorrect? */ | |
333 | + case PIPE_STENCIL_OP_INCR: return SVGA3D_STENCILOP_INCRSAT; | |
334 | + case PIPE_STENCIL_OP_DECR: return SVGA3D_STENCILOP_DECRSAT; | |
335 | + case PIPE_STENCIL_OP_INCR_WRAP: return SVGA3D_STENCILOP_INCR; | |
336 | + case PIPE_STENCIL_OP_DECR_WRAP: return SVGA3D_STENCILOP_DECR; | |
337 | case PIPE_STENCIL_OP_INVERT: return SVGA3D_STENCILOP_INVERT; | |
338 | default: | |
339 | assert(0); | |
340 | diff --git a/src/gallium/drivers/svga/svga_pipe_rasterizer.c b/src/gallium/drivers/svga/svga_pipe_rasterizer.c | |
341 | index a18845e..3342800 100644 | |
342 | --- a/src/gallium/drivers/svga/svga_pipe_rasterizer.c | |
343 | +++ b/src/gallium/drivers/svga/svga_pipe_rasterizer.c | |
344 | @@ -237,11 +237,11 @@ static void svga_bind_rasterizer_state( struct pipe_context *pipe, | |
345 | struct svga_context *svga = svga_context(pipe); | |
346 | struct svga_rasterizer_state *raster = (struct svga_rasterizer_state *)state; | |
347 | ||
348 | - svga->curr.rast = raster; | |
349 | ||
350 | draw_set_rasterizer_state(svga->swtnl.draw, raster ? &raster->templ : NULL, | |
351 | state); | |
352 | - | |
353 | + svga->curr.rast = raster; | |
354 | + | |
355 | svga->dirty |= SVGA_NEW_RAST; | |
356 | } | |
357 | ||
358 | diff --git a/src/gallium/drivers/svga/svga_screen.c b/src/gallium/drivers/svga/svga_screen.c | |
359 | index 82a3ff2..e22deb4 100644 | |
360 | --- a/src/gallium/drivers/svga/svga_screen.c | |
361 | +++ b/src/gallium/drivers/svga/svga_screen.c | |
362 | @@ -235,7 +235,7 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en | |
363 | case PIPE_SHADER_CAP_MAX_TEMPS: | |
364 | if (!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_FRAGMENT_SHADER_TEMPS, &result)) | |
365 | return 32; | |
366 | - return result.u; | |
367 | + return MIN2(result.u, SVGA3D_TEMPREG_MAX); | |
368 | case PIPE_SHADER_CAP_MAX_ADDRS: | |
369 | case PIPE_SHADER_CAP_INDIRECT_INPUT_ADDR: | |
370 | /* | |
371 | @@ -286,7 +286,7 @@ static int svga_get_shader_param(struct pipe_screen *screen, unsigned shader, en | |
372 | case PIPE_SHADER_CAP_MAX_TEMPS: | |
373 | if (!sws->get_cap(sws, SVGA3D_DEVCAP_MAX_VERTEX_SHADER_TEMPS, &result)) | |
374 | return 32; | |
375 | - return result.u; | |
376 | + return MIN2(result.u, SVGA3D_TEMPREG_MAX); | |
377 | case PIPE_SHADER_CAP_MAX_ADDRS: | |
378 | return 1; | |
379 | case PIPE_SHADER_CAP_MAX_PREDS: | |
380 | diff --git a/src/gallium/drivers/svga/svga_state_need_swtnl.c b/src/gallium/drivers/svga/svga_state_need_swtnl.c | |
381 | index 8c39a4b..ce4db8d 100644 | |
382 | --- a/src/gallium/drivers/svga/svga_state_need_swtnl.c | |
383 | +++ b/src/gallium/drivers/svga/svga_state_need_swtnl.c | |
384 | @@ -136,7 +136,7 @@ update_need_pipeline( struct svga_context *svga, | |
385 | ||
386 | /* EDGEFLAGS | |
387 | */ | |
388 | - if (vs->base.info.writes_edgeflag) { | |
389 | + if (vs && vs->base.info.writes_edgeflag) { | |
390 | SVGA_DBG(DEBUG_SWTNL, "%s: edgeflags\n", __FUNCTION__); | |
391 | need_pipeline = TRUE; | |
392 | } | |
393 | @@ -145,7 +145,8 @@ update_need_pipeline( struct svga_context *svga, | |
394 | */ | |
395 | if (svga->curr.reduced_prim == PIPE_PRIM_POINTS) { | |
396 | unsigned sprite_coord_gen = svga->curr.rast->templ.sprite_coord_enable; | |
397 | - unsigned generic_inputs = svga->curr.fs->generic_inputs; | |
398 | + unsigned generic_inputs = | |
399 | + svga->curr.fs ? svga->curr.fs->generic_inputs : 0; | |
400 | ||
401 | if (sprite_coord_gen && | |
402 | (generic_inputs & ~sprite_coord_gen)) { | |
403 | diff --git a/src/glx/apple/Makefile b/src/glx/apple/Makefile | |
404 | index 66e6658..dc64295 100644 | |
405 | --- a/src/glx/apple/Makefile | |
406 | +++ b/src/glx/apple/Makefile | |
407 | @@ -35,6 +35,7 @@ SOURCES = \ | |
408 | apple_xgl_api_stereo.c \ | |
409 | apple_xgl_api_viewport.c \ | |
410 | appledri.c \ | |
411 | + ../create_context.c \ | |
412 | ../clientattrib.c \ | |
413 | ../compsize.c \ | |
414 | ../glxconfig.c \ | |
415 | diff --git a/src/glx/create_context.c b/src/glx/create_context.c | |
416 | index 714f0e5..a1a55b3 100644 | |
417 | --- a/src/glx/create_context.c | |
418 | +++ b/src/glx/create_context.c | |
419 | @@ -80,8 +80,13 @@ glXCreateContextAttribsARB(Display *dpy, GLXFBConfig config, | |
420 | &dummy_err); | |
421 | } | |
422 | ||
423 | - if (gc == NULL) | |
424 | + if (gc == NULL) { | |
425 | +#ifdef GLX_USE_APPLEGL | |
426 | + gc = applegl_create_context(psc, cfg, share, 0); | |
427 | +#else | |
428 | gc = indirect_create_context(psc, cfg, share, 0); | |
429 | +#endif | |
430 | + } | |
431 | ||
432 | gc->xid = xcb_generate_id(c); | |
433 | gc->share_xid = (share != NULL) ? share->xid : 0; | |
434 | diff --git a/src/mesa/drivers/dri/i915/i915_fragprog.c b/src/mesa/drivers/dri/i915/i915_fragprog.c | |
435 | index 4f016a3..5b7e93e 100644 | |
436 | --- a/src/mesa/drivers/dri/i915/i915_fragprog.c | |
437 | +++ b/src/mesa/drivers/dri/i915/i915_fragprog.c | |
438 | @@ -1361,6 +1361,10 @@ i915ValidateFragmentProgram(struct i915_context *i915) | |
439 | EMIT_ATTR(_TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, S4_VFMT_XYZ, 12); | |
440 | } | |
441 | ||
442 | + /* Handle gl_PointSize builtin var here */ | |
443 | + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) | |
444 | + EMIT_ATTR(_TNL_ATTRIB_POINTSIZE, EMIT_1F, S4_VFMT_POINT_WIDTH, 4); | |
445 | + | |
446 | if (inputsRead & FRAG_BIT_COL0) { | |
447 | intel->coloroffset = offset / 4; | |
448 | EMIT_ATTR(_TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, S4_VFMT_COLOR, 4); | |
449 | diff --git a/src/mesa/drivers/dri/i915/i915_vtbl.c b/src/mesa/drivers/dri/i915/i915_vtbl.c | |
450 | index 11e8a35..e78dbc8 100644 | |
451 | --- a/src/mesa/drivers/dri/i915/i915_vtbl.c | |
452 | +++ b/src/mesa/drivers/dri/i915/i915_vtbl.c | |
453 | @@ -665,12 +665,11 @@ i915_set_draw_region(struct intel_context *intel, | |
454 | ||
455 | draw_offset = (draw_y << 16) | draw_x; | |
456 | ||
457 | + FALLBACK(intel, I915_FALLBACK_DRAW_OFFSET, | |
458 | + (ctx->DrawBuffer->Width + draw_x > 2048) || | |
459 | + (ctx->DrawBuffer->Height + draw_y > 2048)); | |
460 | /* When changing drawing rectangle offset, an MI_FLUSH is first required. */ | |
461 | if (draw_offset != i915->last_draw_offset) { | |
462 | - FALLBACK(intel, I915_FALLBACK_DRAW_OFFSET, | |
463 | - (ctx->DrawBuffer->Width + draw_x > 2048) || | |
464 | - (ctx->DrawBuffer->Height + draw_y > 2048)); | |
465 | - | |
466 | state->Buffer[I915_DESTREG_DRAWRECT0] = MI_FLUSH | INHIBIT_FLUSH_RENDER_CACHE; | |
467 | i915->last_draw_offset = draw_offset; | |
468 | } else | |
469 | diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h | |
470 | index 72e5059..3cfc54b 100644 | |
471 | --- a/src/mesa/drivers/dri/i965/brw_context.h | |
472 | +++ b/src/mesa/drivers/dri/i965/brw_context.h | |
473 | @@ -290,6 +290,12 @@ typedef enum | |
474 | BRW_VERT_RESULT_NDC = VERT_RESULT_MAX, | |
475 | BRW_VERT_RESULT_HPOS_DUPLICATE, | |
476 | BRW_VERT_RESULT_PAD, | |
477 | + /* | |
478 | + * It's actually not a vert_result but just a _mark_ to let sf aware that | |
479 | + * he need do something special to handle gl_PointCoord builtin variable | |
480 | + * correctly. see compile_sf_prog() for more info. | |
481 | + */ | |
482 | + BRW_VERT_RESULT_PNTC, | |
483 | BRW_VERT_RESULT_MAX | |
484 | } brw_vert_result; | |
485 | ||
486 | diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c | |
487 | index 3347157..b2581da 100644 | |
488 | --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c | |
489 | +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c | |
490 | @@ -2188,7 +2188,7 @@ void brw_fb_WRITE(struct brw_compile *p, | |
491 | msg_type, | |
492 | msg_length, | |
493 | header_present, | |
494 | - 1, /* last render target write */ | |
495 | + eot, /* last render target write */ | |
496 | response_length, | |
497 | eot, | |
498 | 0 /* send_commit_msg */); | |
499 | diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp | |
500 | index 0de1eef..20b57bd 100644 | |
501 | --- a/src/mesa/drivers/dri/i965/brw_fs.cpp | |
502 | +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp | |
503 | @@ -710,6 +710,15 @@ fs_visitor::calculate_urb_setup() | |
504 | urb_setup[fp_index] = urb_next++; | |
505 | } | |
506 | } | |
507 | + | |
508 | + /* | |
509 | + * It's a FS only attribute, and we did interpolation for this attribute | |
510 | + * in SF thread. So, count it here, too. | |
511 | + * | |
512 | + * See compile_sf_prog() for more info. | |
513 | + */ | |
514 | + if (brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(FRAG_ATTRIB_PNTC)) | |
515 | + urb_setup[FRAG_ATTRIB_PNTC] = urb_next++; | |
516 | } | |
517 | ||
518 | /* Each attribute is 4 setup channels, each of which is half a reg. */ | |
519 | diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c | |
520 | index 54c27f9..ccef3e83 100644 | |
521 | --- a/src/mesa/drivers/dri/i965/brw_sf.c | |
522 | +++ b/src/mesa/drivers/dri/i965/brw_sf.c | |
523 | @@ -64,6 +64,16 @@ static void compile_sf_prog( struct brw_context *brw, | |
524 | ||
525 | c.key = *key; | |
526 | brw_compute_vue_map(&c.vue_map, intel, c.key.userclip_active, c.key.attrs); | |
527 | + if (c.key.do_point_coord) { | |
528 | + /* | |
529 | + * gl_PointCoord is a FS instead of VS builtin variable, thus it's | |
530 | + * not included in c.vue_map generated in VS stage. Here we add | |
531 | + * it manually to let SF shader generate the needed interpolation | |
532 | + * coefficient for FS shader. | |
533 | + */ | |
534 | + c.vue_map.vert_result_to_slot[BRW_VERT_RESULT_PNTC] = c.vue_map.num_slots; | |
535 | + c.vue_map.slot_to_vert_result[c.vue_map.num_slots++] = BRW_VERT_RESULT_PNTC; | |
536 | + } | |
537 | c.urb_entry_read_offset = brw_sf_compute_urb_entry_read_offset(intel); | |
538 | c.nr_attr_regs = (c.vue_map.num_slots + 1)/2 - c.urb_entry_read_offset; | |
539 | c.nr_setup_regs = c.nr_attr_regs; | |
540 | @@ -125,6 +135,8 @@ brw_upload_sf_prog(struct brw_context *brw) | |
541 | { | |
542 | struct gl_context *ctx = &brw->intel.ctx; | |
543 | struct brw_sf_prog_key key; | |
544 | + /* _NEW_BUFFERS */ | |
545 | + bool render_to_fbo = ctx->DrawBuffer->Name != 0; | |
546 | ||
547 | memset(&key, 0, sizeof(key)); | |
548 | ||
549 | @@ -167,7 +179,15 @@ brw_upload_sf_prog(struct brw_context *brw) | |
550 | key.point_sprite_coord_replace |= (1 << i); | |
551 | } | |
552 | } | |
553 | - key.sprite_origin_lower_left = (ctx->Point.SpriteOrigin == GL_LOWER_LEFT); | |
554 | + if (brw->fragment_program->Base.InputsRead & BITFIELD64_BIT(FRAG_ATTRIB_PNTC)) | |
555 | + key.do_point_coord = 1; | |
556 | + /* | |
557 | + * Window coordinates in a FBO are inverted, which means point | |
558 | + * sprite origin must be inverted, too. | |
559 | + */ | |
560 | + if ((ctx->Point.SpriteOrigin == GL_LOWER_LEFT) != render_to_fbo) | |
561 | + key.sprite_origin_lower_left = true; | |
562 | + | |
563 | /* _NEW_LIGHT */ | |
564 | key.do_flat_shading = (ctx->Light.ShadeModel == GL_FLAT); | |
565 | key.do_twoside_color = (ctx->Light.Enabled && ctx->Light.Model.TwoSide); | |
566 | @@ -176,10 +196,9 @@ brw_upload_sf_prog(struct brw_context *brw) | |
567 | if (key.do_twoside_color) { | |
568 | /* If we're rendering to a FBO, we have to invert the polygon | |
569 | * face orientation, just as we invert the viewport in | |
570 | - * sf_unit_create_from_key(). ctx->DrawBuffer->Name will be | |
571 | - * nonzero if we're rendering to such an FBO. | |
572 | + * sf_unit_create_from_key(). | |
573 | */ | |
574 | - key.frontface_ccw = (ctx->Polygon.FrontFace == GL_CCW) ^ (ctx->DrawBuffer->Name != 0); | |
575 | + key.frontface_ccw = (ctx->Polygon.FrontFace == GL_CCW) != render_to_fbo; | |
576 | } | |
577 | ||
578 | if (!brw_search_cache(&brw->cache, BRW_SF_PROG, | |
579 | @@ -192,7 +211,8 @@ brw_upload_sf_prog(struct brw_context *brw) | |
580 | ||
581 | const struct brw_tracked_state brw_sf_prog = { | |
582 | .dirty = { | |
583 | - .mesa = (_NEW_HINT | _NEW_LIGHT | _NEW_POLYGON | _NEW_POINT | _NEW_TRANSFORM), | |
584 | + .mesa = (_NEW_HINT | _NEW_LIGHT | _NEW_POLYGON | _NEW_POINT | | |
585 | + _NEW_TRANSFORM | _NEW_BUFFERS), | |
586 | .brw = (BRW_NEW_REDUCED_PRIMITIVE), | |
587 | .cache = CACHE_NEW_VS_PROG | |
588 | }, | |
589 | diff --git a/src/mesa/drivers/dri/i965/brw_sf.h b/src/mesa/drivers/dri/i965/brw_sf.h | |
590 | index 4ef0240..f908fc0 100644 | |
591 | --- a/src/mesa/drivers/dri/i965/brw_sf.h | |
592 | +++ b/src/mesa/drivers/dri/i965/brw_sf.h | |
593 | @@ -52,6 +52,7 @@ struct brw_sf_prog_key { | |
594 | GLuint do_flat_shading:1; | |
595 | GLuint frontface_ccw:1; | |
596 | GLuint do_point_sprite:1; | |
597 | + GLuint do_point_coord:1; | |
598 | GLuint sprite_origin_lower_left:1; | |
599 | GLuint userclip_active:1; | |
600 | }; | |
601 | diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c | |
602 | index 1ee0098..ff6383b 100644 | |
603 | --- a/src/mesa/drivers/dri/i965/brw_sf_emit.c | |
604 | +++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c | |
605 | @@ -386,6 +386,8 @@ calculate_point_sprite_mask(struct brw_sf_compile *c, GLuint reg) | |
606 | if (c->key.point_sprite_coord_replace & (1 << (vert_result1 - VERT_RESULT_TEX0))) | |
607 | pc |= 0x0f; | |
608 | } | |
609 | + if (vert_result1 == BRW_VERT_RESULT_PNTC) | |
610 | + pc |= 0x0f; | |
611 | ||
612 | vert_result2 = vert_reg_to_vert_result(c, reg, 1); | |
613 | if (vert_result2 >= VERT_RESULT_TEX0 && vert_result2 <= VERT_RESULT_TEX7) { | |
614 | @@ -393,6 +395,8 @@ calculate_point_sprite_mask(struct brw_sf_compile *c, GLuint reg) | |
615 | VERT_RESULT_TEX0))) | |
616 | pc |= 0xf0; | |
617 | } | |
618 | + if (vert_result2 == BRW_VERT_RESULT_PNTC) | |
619 | + pc |= 0xf0; | |
620 | ||
621 | return pc; | |
622 | } | |
623 | diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c | |
624 | index a2959a8..4b27e06 100644 | |
625 | --- a/src/mesa/main/bufferobj.c | |
626 | +++ b/src/mesa/main/bufferobj.c | |
627 | @@ -1159,17 +1159,17 @@ _mesa_GetBufferParameterivARB(GLenum target, GLenum pname, GLint *params) | |
628 | *params = _mesa_bufferobj_mapped(bufObj); | |
629 | return; | |
630 | case GL_BUFFER_ACCESS_FLAGS: | |
631 | - if (ctx->VersionMajor < 3) | |
632 | + if (!ctx->Extensions.ARB_map_buffer_range) | |
633 | goto invalid_pname; | |
634 | *params = bufObj->AccessFlags; | |
635 | return; | |
636 | case GL_BUFFER_MAP_OFFSET: | |
637 | - if (ctx->VersionMajor < 3) | |
638 | + if (!ctx->Extensions.ARB_map_buffer_range) | |
639 | goto invalid_pname; | |
640 | *params = (GLint) bufObj->Offset; | |
641 | return; | |
642 | case GL_BUFFER_MAP_LENGTH: | |
643 | - if (ctx->VersionMajor < 3) | |
644 | + if (!ctx->Extensions.ARB_map_buffer_range) | |
645 | goto invalid_pname; | |
646 | *params = (GLint) bufObj->Length; | |
647 | return; | |
648 | @@ -1210,7 +1210,7 @@ _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params) | |
649 | *params = simplified_access_mode(bufObj->AccessFlags); | |
650 | return; | |
651 | case GL_BUFFER_ACCESS_FLAGS: | |
652 | - if (ctx->VersionMajor < 3) | |
653 | + if (!ctx->Extensions.ARB_map_buffer_range) | |
654 | goto invalid_pname; | |
655 | *params = bufObj->AccessFlags; | |
656 | return; | |
657 | @@ -1218,12 +1218,12 @@ _mesa_GetBufferParameteri64v(GLenum target, GLenum pname, GLint64 *params) | |
658 | *params = _mesa_bufferobj_mapped(bufObj); | |
659 | return; | |
660 | case GL_BUFFER_MAP_OFFSET: | |
661 | - if (ctx->VersionMajor < 3) | |
662 | + if (!ctx->Extensions.ARB_map_buffer_range) | |
663 | goto invalid_pname; | |
664 | *params = bufObj->Offset; | |
665 | return; | |
666 | case GL_BUFFER_MAP_LENGTH: | |
667 | - if (ctx->VersionMajor < 3) | |
668 | + if (!ctx->Extensions.ARB_map_buffer_range) | |
669 | goto invalid_pname; | |
670 | *params = bufObj->Length; | |
671 | return; | |
672 | diff --git a/src/mesa/main/pack.c b/src/mesa/main/pack.c | |
673 | index ee983f9..4b0ee79 100644 | |
674 | --- a/src/mesa/main/pack.c | |
675 | +++ b/src/mesa/main/pack.c | |
676 | @@ -5254,3 +5254,94 @@ _mesa_unpack_image( GLuint dimensions, | |
677 | } | |
678 | } | |
679 | ||
680 | + | |
681 | + | |
682 | +/** | |
683 | + * If we unpack colors from a luminance surface, we'll get pixel colors | |
684 | + * such as (l, l, l, a). | |
685 | + * When we call _mesa_pack_rgba_span_float(format=GL_LUMINANCE), that | |
686 | + * function will compute L=R+G+B before packing. The net effect is we'll | |
687 | + * accidentally store luminance values = 3*l. | |
688 | + * This function compensates for that by converting (aka rebasing) (l,l,l,a) | |
689 | + * to be (l,0,0,a). | |
690 | + * It's a similar story for other formats such as LUMINANCE_ALPHA, ALPHA | |
691 | + * and INTENSITY. | |
692 | + * | |
693 | + * Finally, we also need to do this when the actual surface format does | |
694 | + * not match the logical surface format. For example, suppose the user | |
695 | + * requests a GL_LUMINANCE texture but the driver stores it as RGBA. | |
696 | + * Again, we'll get pixel values like (l,l,l,a). | |
697 | + */ | |
698 | +void | |
699 | +_mesa_rebase_rgba_float(GLuint n, GLfloat rgba[][4], GLenum baseFormat) | |
700 | +{ | |
701 | + GLuint i; | |
702 | + | |
703 | + switch (baseFormat) { | |
704 | + case GL_ALPHA: | |
705 | + for (i = 0; i < n; i++) { | |
706 | + rgba[i][RCOMP] = 0.0F; | |
707 | + rgba[i][GCOMP] = 0.0F; | |
708 | + rgba[i][BCOMP] = 0.0F; | |
709 | + } | |
710 | + break; | |
711 | + case GL_INTENSITY: | |
712 | + /* fall-through */ | |
713 | + case GL_LUMINANCE: | |
714 | + for (i = 0; i < n; i++) { | |
715 | + rgba[i][GCOMP] = 0.0F; | |
716 | + rgba[i][BCOMP] = 0.0F; | |
717 | + rgba[i][ACOMP] = 1.0F; | |
718 | + } | |
719 | + break; | |
720 | + case GL_LUMINANCE_ALPHA: | |
721 | + for (i = 0; i < n; i++) { | |
722 | + rgba[i][GCOMP] = 0.0F; | |
723 | + rgba[i][BCOMP] = 0.0F; | |
724 | + } | |
725 | + break; | |
726 | + default: | |
727 | + /* no-op */ | |
728 | + ; | |
729 | + } | |
730 | +} | |
731 | + | |
732 | + | |
733 | +/** | |
734 | + * As above, but GLuint components. | |
735 | + */ | |
736 | +void | |
737 | +_mesa_rebase_rgba_uint(GLuint n, GLuint rgba[][4], GLenum baseFormat) | |
738 | +{ | |
739 | + GLuint i; | |
740 | + | |
741 | + switch (baseFormat) { | |
742 | + case GL_ALPHA: | |
743 | + for (i = 0; i < n; i++) { | |
744 | + rgba[i][RCOMP] = 0; | |
745 | + rgba[i][GCOMP] = 0; | |
746 | + rgba[i][BCOMP] = 0; | |
747 | + } | |
748 | + break; | |
749 | + case GL_INTENSITY: | |
750 | + /* fall-through */ | |
751 | + case GL_LUMINANCE: | |
752 | + for (i = 0; i < n; i++) { | |
753 | + rgba[i][GCOMP] = 0; | |
754 | + rgba[i][BCOMP] = 0; | |
755 | + rgba[i][ACOMP] = 1; | |
756 | + } | |
757 | + break; | |
758 | + case GL_LUMINANCE_ALPHA: | |
759 | + for (i = 0; i < n; i++) { | |
760 | + rgba[i][GCOMP] = 0; | |
761 | + rgba[i][BCOMP] = 0; | |
762 | + } | |
763 | + break; | |
764 | + default: | |
765 | + /* no-op */ | |
766 | + ; | |
767 | + } | |
768 | +} | |
769 | + | |
770 | + | |
771 | diff --git a/src/mesa/main/pack.h b/src/mesa/main/pack.h | |
772 | index b1853cd..cd49c74 100644 | |
773 | --- a/src/mesa/main/pack.h | |
774 | +++ b/src/mesa/main/pack.h | |
775 | @@ -149,4 +149,11 @@ _mesa_pack_rgba_span_int(struct gl_context *ctx, GLuint n, GLuint rgba[][4], | |
776 | GLenum dstFormat, GLenum dstType, | |
777 | GLvoid *dstAddr); | |
778 | ||
779 | + | |
780 | +extern void | |
781 | +_mesa_rebase_rgba_float(GLuint n, GLfloat rgba[][4], GLenum baseFormat); | |
782 | + | |
783 | +extern void | |
784 | +_mesa_rebase_rgba_uint(GLuint n, GLuint rgba[][4], GLenum baseFormat); | |
785 | + | |
786 | #endif | |
787 | diff --git a/src/mesa/main/readpix.c b/src/mesa/main/readpix.c | |
788 | index c1489d2..5b3c246 100644 | |
789 | --- a/src/mesa/main/readpix.c | |
790 | +++ b/src/mesa/main/readpix.c | |
791 | @@ -218,6 +218,16 @@ fast_read_rgba_pixels_memcpy( struct gl_context *ctx, | |
792 | return GL_FALSE; | |
793 | } | |
794 | ||
795 | + /* If the format is unsigned normalized then we can ignore clamping | |
796 | + * because the values are already in the range [0,1] so it won't | |
797 | + * have any effect anyway. | |
798 | + */ | |
799 | + if (_mesa_get_format_datatype(rb->Format) == GL_UNSIGNED_NORMALIZED) | |
800 | + transferOps &= ~IMAGE_CLAMP_BIT; | |
801 | + | |
802 | + if (transferOps) | |
803 | + return GL_FALSE; | |
804 | + | |
805 | dstStride = _mesa_image_row_stride(packing, width, format, type); | |
806 | dst = (GLubyte *) _mesa_image_address2d(packing, pixels, width, height, | |
807 | format, type, 0, 0); | |
808 | @@ -274,10 +284,14 @@ slow_read_rgba_pixels( struct gl_context *ctx, | |
809 | for (j = 0; j < height; j++) { | |
810 | if (_mesa_is_integer_format(format)) { | |
811 | _mesa_unpack_uint_rgba_row(rbFormat, width, map, (GLuint (*)[4]) rgba); | |
812 | + _mesa_rebase_rgba_uint(width, (GLuint (*)[4]) rgba, | |
813 | + rb->_BaseFormat); | |
814 | _mesa_pack_rgba_span_int(ctx, width, (GLuint (*)[4]) rgba, format, | |
815 | type, dst); | |
816 | } else { | |
817 | _mesa_unpack_rgba_row(rbFormat, width, map, (GLfloat (*)[4]) rgba); | |
818 | + _mesa_rebase_rgba_float(width, (GLfloat (*)[4]) rgba, | |
819 | + rb->_BaseFormat); | |
820 | _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, format, | |
821 | type, dst, packing, transferOps); | |
822 | } | |
823 | @@ -313,13 +327,11 @@ read_rgba_pixels( struct gl_context *ctx, | |
824 | transferOps |= IMAGE_CLAMP_BIT; | |
825 | } | |
826 | ||
827 | - if (!transferOps) { | |
828 | - /* Try the optimized paths first. */ | |
829 | - if (fast_read_rgba_pixels_memcpy(ctx, x, y, width, height, | |
830 | - format, type, pixels, packing, | |
831 | - transferOps)) { | |
832 | - return; | |
833 | - } | |
834 | + /* Try the optimized paths first. */ | |
835 | + if (fast_read_rgba_pixels_memcpy(ctx, x, y, width, height, | |
836 | + format, type, pixels, packing, | |
837 | + transferOps)) { | |
838 | + return; | |
839 | } | |
840 | ||
841 | slow_read_rgba_pixels(ctx, x, y, width, height, | |
842 | diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c | |
843 | index 8362199..76ac5a2 100644 | |
844 | --- a/src/mesa/main/texgetimage.c | |
845 | +++ b/src/mesa/main/texgetimage.c | |
846 | @@ -275,13 +275,8 @@ get_tex_rgba_compressed(struct gl_context *ctx, GLuint dimensions, | |
847 | ||
848 | if (baseFormat == GL_LUMINANCE || | |
849 | baseFormat == GL_LUMINANCE_ALPHA) { | |
850 | - /* Set green and blue to zero since the pack function here will | |
851 | - * compute L=R+G+B. | |
852 | - */ | |
853 | - GLuint i; | |
854 | - for (i = 0; i < width * height; i++) { | |
855 | - tempImage[i * 4 + GCOMP] = tempImage[i * 4 + BCOMP] = 0.0f; | |
856 | - } | |
857 | + _mesa_rebase_rgba_float(width * height, (GLfloat (*)[4]) tempImage, | |
858 | + baseFormat); | |
859 | } | |
860 | ||
861 | srcRow = tempImage; | |
862 | @@ -312,6 +307,8 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, | |
863 | const gl_format texFormat = | |
864 | _mesa_get_srgb_format_linear(texImage->TexFormat); | |
865 | const GLuint width = texImage->Width; | |
866 | + const GLenum destBaseFormat = _mesa_base_tex_format(ctx, format); | |
867 | + GLenum rebaseFormat = GL_NONE; | |
868 | GLuint height = texImage->Height; | |
869 | GLuint depth = texImage->Depth; | |
870 | GLuint img, row; | |
871 | @@ -332,6 +329,28 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, | |
872 | height = 1; | |
873 | } | |
874 | ||
875 | + if (texImage->_BaseFormat == GL_LUMINANCE || | |
876 | + texImage->_BaseFormat == GL_INTENSITY || | |
877 | + texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { | |
878 | + /* If a luminance (or intensity) texture is read back as RGB(A), the | |
879 | + * returned value should be (L,0,0,1), not (L,L,L,1). Set rebaseFormat | |
880 | + * here to get G=B=0. | |
881 | + */ | |
882 | + rebaseFormat = texImage->_BaseFormat; | |
883 | + } | |
884 | + else if ((texImage->_BaseFormat == GL_RGBA || | |
885 | + texImage->_BaseFormat == GL_RGB) && | |
886 | + (destBaseFormat == GL_LUMINANCE || | |
887 | + destBaseFormat == GL_LUMINANCE_ALPHA || | |
888 | + destBaseFormat == GL_LUMINANCE_INTEGER_EXT || | |
889 | + destBaseFormat == GL_LUMINANCE_ALPHA_INTEGER_EXT)) { | |
890 | + /* If we're reading back an RGB(A) texture as luminance then we need | |
891 | + * to return L=tex(R). Note, that's different from glReadPixels which | |
892 | + * returns L=R+G+B. | |
893 | + */ | |
894 | + rebaseFormat = GL_LUMINANCE_ALPHA; /* this covers GL_LUMINANCE too */ | |
895 | + } | |
896 | + | |
897 | for (img = 0; img < depth; img++) { | |
898 | GLubyte *srcMap; | |
899 | GLint rowstride; | |
900 | @@ -349,76 +368,14 @@ get_tex_rgba_uncompressed(struct gl_context *ctx, GLuint dimensions, | |
901 | ||
902 | if (is_integer) { | |
903 | _mesa_unpack_uint_rgba_row(texFormat, width, src, rgba_uint); | |
904 | - | |
905 | - if (texImage->_BaseFormat == GL_ALPHA) { | |
906 | - GLint col; | |
907 | - for (col = 0; col < width; col++) { | |
908 | - rgba_uint[col][RCOMP] = 0; | |
909 | - rgba_uint[col][GCOMP] = 0; | |
910 | - rgba_uint[col][BCOMP] = 0; | |
911 | - } | |
912 | - } | |
913 | - else if (texImage->_BaseFormat == GL_LUMINANCE) { | |
914 | - GLint col; | |
915 | - for (col = 0; col < width; col++) { | |
916 | - rgba_uint[col][GCOMP] = 0; | |
917 | - rgba_uint[col][BCOMP] = 0; | |
918 | - rgba_uint[col][ACOMP] = 1; | |
919 | - } | |
920 | - } | |
921 | - else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { | |
922 | - GLint col; | |
923 | - for (col = 0; col < width; col++) { | |
924 | - rgba_uint[col][GCOMP] = 0; | |
925 | - rgba_uint[col][BCOMP] = 0; | |
926 | - } | |
927 | - } | |
928 | - else if (texImage->_BaseFormat == GL_INTENSITY) { | |
929 | - GLint col; | |
930 | - for (col = 0; col < width; col++) { | |
931 | - rgba_uint[col][GCOMP] = 0; | |
932 | - rgba_uint[col][BCOMP] = 0; | |
933 | - rgba_uint[col][ACOMP] = 1; | |
934 | - } | |
935 | - } | |
936 | - | |
937 | + if (rebaseFormat) | |
938 | + _mesa_rebase_rgba_uint(width, rgba_uint, rebaseFormat); | |
939 | _mesa_pack_rgba_span_int(ctx, width, rgba_uint, | |
940 | format, type, dest); | |
941 | } else { | |
942 | _mesa_unpack_rgba_row(texFormat, width, src, rgba); | |
943 | - | |
944 | - if (texImage->_BaseFormat == GL_ALPHA) { | |
945 | - GLint col; | |
946 | - for (col = 0; col < width; col++) { | |
947 | - rgba[col][RCOMP] = 0.0F; | |
948 | - rgba[col][GCOMP] = 0.0F; | |
949 | - rgba[col][BCOMP] = 0.0F; | |
950 | - } | |
951 | - } | |
952 | - else if (texImage->_BaseFormat == GL_LUMINANCE) { | |
953 | - GLint col; | |
954 | - for (col = 0; col < width; col++) { | |
955 | - rgba[col][GCOMP] = 0.0F; | |
956 | - rgba[col][BCOMP] = 0.0F; | |
957 | - rgba[col][ACOMP] = 1.0F; | |
958 | - } | |
959 | - } | |
960 | - else if (texImage->_BaseFormat == GL_LUMINANCE_ALPHA) { | |
961 | - GLint col; | |
962 | - for (col = 0; col < width; col++) { | |
963 | - rgba[col][GCOMP] = 0.0F; | |
964 | - rgba[col][BCOMP] = 0.0F; | |
965 | - } | |
966 | - } | |
967 | - else if (texImage->_BaseFormat == GL_INTENSITY) { | |
968 | - GLint col; | |
969 | - for (col = 0; col < width; col++) { | |
970 | - rgba[col][GCOMP] = 0.0F; | |
971 | - rgba[col][BCOMP] = 0.0F; | |
972 | - rgba[col][ACOMP] = 1.0F; | |
973 | - } | |
974 | - } | |
975 | - | |
976 | + if (rebaseFormat) | |
977 | + _mesa_rebase_rgba_float(width, rgba, rebaseFormat); | |
978 | _mesa_pack_rgba_span_float(ctx, width, (GLfloat (*)[4]) rgba, | |
979 | format, type, dest, | |
980 | &ctx->Pack, transferOps); | |
981 | diff --git a/src/mesa/tnl/t_context.c b/src/mesa/tnl/t_context.c | |
982 | index 1ded44c..e38c0a3 100644 | |
983 | --- a/src/mesa/tnl/t_context.c | |
984 | +++ b/src/mesa/tnl/t_context.c | |
985 | @@ -151,8 +151,7 @@ _tnl_InvalidateState( struct gl_context *ctx, GLuint new_state ) | |
986 | if (ctx->RenderMode == GL_FEEDBACK) | |
987 | tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_TEX0); | |
988 | ||
989 | - if (ctx->Point._Attenuated || | |
990 | - (ctx->VertexProgram._Enabled && ctx->VertexProgram.PointSizeEnabled)) | |
991 | + if (ctx->Point._Attenuated || ctx->VertexProgram.PointSizeEnabled) | |
992 | tnl->render_inputs_bitset |= BITFIELD64_BIT(_TNL_ATTRIB_POINTSIZE); | |
993 | ||
994 | /* check for varying vars which are written by the vertex program */ |