From 092ca30366d15debb35939205d82a6ac2408fbb9 Mon Sep 17 00:00:00 2001 From: Karl Schultz Date: Mon, 22 Mar 2010 12:18:02 -0600 Subject: Fix potential compilation issue in visual studio project file Add quotes around filespec in post-build event to allow paths with embedded spaces. --- windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj b/windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj index 8995c03886..6e9aef2e1f 100644 --- a/windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj +++ b/windows/VC8/mesa/glsl_apps_compile/glsl_apps_compile.vcproj @@ -89,7 +89,7 @@ /> -- cgit v1.2.3 From 62d54f0387610ec4f71cc3d0fb2a5d49e370a0ef Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Mon, 22 Mar 2010 17:54:35 -0400 Subject: intel: Call intel_prepare_render() before looking up regions. Fixes #27213. --- src/mesa/drivers/dri/intel/intel_blit.c | 2 -- src/mesa/drivers/dri/intel/intel_mipmap_tree.c | 2 ++ src/mesa/drivers/dri/intel/intel_pixel_copy.c | 11 +++++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/intel/intel_blit.c b/src/mesa/drivers/dri/intel/intel_blit.c index f2769aa3e8..4ad42a7c28 100644 --- a/src/mesa/drivers/dri/intel/intel_blit.c +++ b/src/mesa/drivers/dri/intel/intel_blit.c @@ -119,8 +119,6 @@ intelEmitCopyBlit(struct intel_context *intel, break; } while (pass < 2); - intel_prepare_render(intel); - if (pass >= 2) { drm_intel_gem_bo_map_gtt(dst_buffer); drm_intel_gem_bo_map_gtt(src_buffer); diff --git a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c index 4f14946ec7..1b340afc6a 100644 --- a/src/mesa/drivers/dri/intel/intel_mipmap_tree.c +++ b/src/mesa/drivers/dri/intel/intel_mipmap_tree.c @@ -520,6 +520,8 @@ intel_miptree_image_copy(struct intel_context *intel, width = ALIGN(width, align_w); } + intel_prepare_render(intel); + for (i = 0; i < depth; i++) { intel_miptree_get_image_offset(src, level, face, i, &src_x, &src_y); intel_miptree_get_image_offset(dst, level, face, i, &dst_x, &dst_y); diff --git a/src/mesa/drivers/dri/intel/intel_pixel_copy.c b/src/mesa/drivers/dri/intel/intel_pixel_copy.c index f4f3fd6d88..757f2f7d4d 100644 --- a/src/mesa/drivers/dri/intel/intel_pixel_copy.c +++ b/src/mesa/drivers/dri/intel/intel_pixel_copy.c @@ -108,8 +108,8 @@ do_blit_copypixels(GLcontext * ctx, GLint dstx, GLint dsty, GLenum type) { struct intel_context *intel = intel_context(ctx); - struct intel_region *dst = intel_drawbuf_region(intel); - struct intel_region *src = copypix_src_region(intel, type); + struct intel_region *dst; + struct intel_region *src; struct gl_framebuffer *fb = ctx->DrawBuffer; struct gl_framebuffer *read_fb = ctx->ReadBuffer; GLint orig_dstx; @@ -133,13 +133,16 @@ do_blit_copypixels(GLcontext * ctx, ctx->Pixel.ZoomX != 1.0F || ctx->Pixel.ZoomY != 1.0F) return GL_FALSE; + intel_prepare_render(intel); + + dst = intel_drawbuf_region(intel); + src = copypix_src_region(intel, type); + if (!src || !dst) return GL_FALSE; intelFlush(&intel->ctx); - intel_prepare_render(intel); - /* XXX: We fail to handle different inversion between read and draw framebuffer. */ /* Clip to destination buffer. */ -- cgit v1.2.3 From 4eead425504057e0862bc214bceaa512775973f1 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 22 Mar 2010 18:09:15 -0700 Subject: mesa: set version string to 7.8-rc2 --- Makefile | 2 +- src/mesa/main/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 68b5adffbe..733d57b782 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ ultrix-gcc: # Rules for making release tarballs -VERSION=7.8-rc1 +VERSION=7.8-rc2 DIRECTORY = Mesa-$(VERSION) LIB_NAME = MesaLib-$(VERSION) DEMO_NAME = MesaDemos-$(VERSION) diff --git a/src/mesa/main/version.h b/src/mesa/main/version.h index 7ed1e1a32a..23d74ee2c9 100644 --- a/src/mesa/main/version.h +++ b/src/mesa/main/version.h @@ -35,7 +35,7 @@ #define MESA_MAJOR 7 #define MESA_MINOR 8 #define MESA_PATCH 0 -#define MESA_VERSION_STRING "7.8-rc1" +#define MESA_VERSION_STRING "7.8-rc2" /* To make version comparison easy */ #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -- cgit v1.2.3 From 094c6fbc45cee1b53d9f1d7d4123d6da6a8958a3 Mon Sep 17 00:00:00 2001 From: Kristian Høgsberg Date: Mon, 22 Mar 2010 21:57:26 -0400 Subject: glx: Suppress BadDrawable from DRI2CopyRegion This can happen when an X window is destroyed behind our back. We use DRI2CopyRegion behind the scenes in many places (like flushing the fake front to the real front) so we have to ignore X errors triggered in that case. The glean test cases trigger this consistently as they don't destroy the GLX drawable nicely, they just destroy the X window. --- src/glx/dri2.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/glx/dri2.c b/src/glx/dri2.c index 5de55cdbf2..9ca9b3eb06 100644 --- a/src/glx/dri2.c +++ b/src/glx/dri2.c @@ -62,6 +62,8 @@ static Bool DRI2WireToEvent(Display *dpy, XEvent *event, xEvent *wire); static Status DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire); +static int +DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code); static /* const */ XExtensionHooks dri2ExtensionHooks = { NULL, /* create_gc */ @@ -73,7 +75,7 @@ static /* const */ XExtensionHooks dri2ExtensionHooks = { DRI2CloseDisplay, /* close_display */ DRI2WireToEvent, /* wire_to_event */ DRI2EventToWire, /* event_to_wire */ - NULL, /* error */ + DRI2Error, /* error */ NULL, /* error_string */ }; @@ -160,6 +162,17 @@ DRI2EventToWire(Display *dpy, XEvent *event, xEvent *wire) return Success; } +static int +DRI2Error(Display *display, xError *err, XExtCodes *codes, int *ret_code) +{ + if (err->majorCode == codes->major_opcode && + err->errorCode == BadDrawable && + err->minorCode == X_DRI2CopyRegion) + return True; + + return False; +} + Bool DRI2QueryExtension(Display * dpy, int *eventBase, int *errorBase) { -- cgit v1.2.3 From 2ded27b2f0a7b01f5db77ea9a2a25df5baa876b3 Mon Sep 17 00:00:00 2001 From: Chia-I Wu Date: Tue, 23 Mar 2010 14:37:24 +0800 Subject: Add missing EGL files to the tarballs. Add the Makefile of Gallium EGL drivers and demos using EGL to the tarballs. --- Makefile | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Makefile b/Makefile index 733d57b782..7c75d7f833 100644 --- a/Makefile +++ b/Makefile @@ -324,6 +324,7 @@ GALLIUM_FILES = \ $(DIRECTORY)/src/gallium/*/Makefile \ $(DIRECTORY)/src/gallium/*/SConscript \ $(DIRECTORY)/src/gallium/*/*/Makefile \ + $(DIRECTORY)/src/gallium/*/*/Makefile.egl \ $(DIRECTORY)/src/gallium/*/*/Makefile.template \ $(DIRECTORY)/src/gallium/*/*/SConscript \ $(DIRECTORY)/src/gallium/*/*/*.[ch] \ @@ -407,6 +408,14 @@ DEMO_FILES = \ $(DIRECTORY)/progs/demos/*.cxx \ $(DIRECTORY)/progs/demos/*.dat \ $(DIRECTORY)/progs/demos/README \ + $(DIRECTORY)/progs/egl/Makefile \ + $(DIRECTORY)/progs/egl/*.[ch] \ + $(DIRECTORY)/progs/es1/*/Makefile \ + $(DIRECTORY)/progs/es1/*/*.[ch] \ + $(DIRECTORY)/progs/es2/*/Makefile \ + $(DIRECTORY)/progs/es2/*/*.[ch] \ + $(DIRECTORY)/progs/openvg/*/Makefile \ + $(DIRECTORY)/progs/openvg/*/*.[ch] \ $(DIRECTORY)/progs/fbdev/Makefile \ $(DIRECTORY)/progs/fbdev/glfbdevtest.c \ $(DIRECTORY)/progs/objviewer/*.[ch] \ -- cgit v1.2.3 From 4ceeb1307a018f426784620d3376f9f1ea07e53b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 08:58:09 -0600 Subject: st/glx: better format selection in xmesa_choose_z_stencil_format() This is a back-port of commit ef2664da6c4db1b52ef351641e3ee949b87f9c7b from master. --- src/gallium/state_trackers/glx/xlib/xm_api.c | 41 ++++++++++++++++------------ 1 file changed, 24 insertions(+), 17 deletions(-) diff --git a/src/gallium/state_trackers/glx/xlib/xm_api.c b/src/gallium/state_trackers/glx/xlib/xm_api.c index 217bdeff75..e8524a21c2 100644 --- a/src/gallium/state_trackers/glx/xlib/xm_api.c +++ b/src/gallium/state_trackers/glx/xlib/xm_api.c @@ -324,7 +324,7 @@ choose_pixel_format(XMesaVisual v) * at least matches the given depthBits and stencilBits. */ static void -xmesa_choose_z_stencil_format(int depthBits, int stencilBits, +xmesa_choose_z_stencil_format(int depth, int stencil, enum pipe_format *depthFormat, enum pipe_format *stencilFormat) { @@ -332,20 +332,28 @@ xmesa_choose_z_stencil_format(int depthBits, int stencilBits, const unsigned tex_usage = PIPE_TEXTURE_USAGE_DEPTH_STENCIL; const unsigned geom_flags = (PIPE_TEXTURE_GEOM_NON_SQUARE | PIPE_TEXTURE_GEOM_NON_POWER_OF_TWO); - static enum pipe_format formats[] = { - PIPE_FORMAT_S8Z24_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_Z16_UNORM, - PIPE_FORMAT_Z32_UNORM - }; - int i; + enum pipe_format formats[8]; + int count, i; - assert(screen); + count = 0; - *depthFormat = *stencilFormat = PIPE_FORMAT_NONE; + if (depth <= 16 && stencil == 0) { + formats[count++] = PIPE_FORMAT_Z16_UNORM; + } + if (depth <= 24 && stencil == 0) { + formats[count++] = PIPE_FORMAT_X8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24X8_UNORM; + } + if (depth <= 24 && stencil <= 8) { + formats[count++] = PIPE_FORMAT_S8Z24_UNORM; + formats[count++] = PIPE_FORMAT_Z24S8_UNORM; + } + if (depth <= 32 && stencil == 0) { + formats[count++] = PIPE_FORMAT_Z32_UNORM; + } - /* search for supported format */ - for (i = 0; i < Elements(formats); i++) { + *depthFormat = PIPE_FORMAT_NONE; + for (i = 0; i < count; i++) { if (screen->is_format_supported(screen, formats[i], target, tex_usage, geom_flags)) { *depthFormat = formats[i]; @@ -353,13 +361,12 @@ xmesa_choose_z_stencil_format(int depthBits, int stencilBits, } } - if (stencilBits) { + if (stencil) { *stencilFormat = *depthFormat; } - - /* XXX we should check that he chosen format has at least as many bits - * as what was requested. - */ + else { + *stencilFormat = PIPE_FORMAT_NONE; + } } -- cgit v1.2.3 From fc1ba0423ac31cff14346dbc888255fb5fd7d1b2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 09:00:19 -0600 Subject: softpipe: add special cases for all Z compare modes for 16-bit Z buffer We had fast paths for PIPE_FUNC_LESS and LEQUAL before. To satisfy OpenGL invariance rules, all depth compare modes should produce the same fragment Z values. Fixes progs/demos/singlebuffer.c --- src/gallium/drivers/softpipe/sp_quad_depth_test.c | 221 +++++---------------- .../drivers/softpipe/sp_quad_depth_test_tmp.h | 147 ++++++++++++++ 2 files changed, 195 insertions(+), 173 deletions(-) create mode 100644 src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 4815a0d49f..5854cee1be 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -730,169 +730,36 @@ depth_test_quads_fallback(struct quad_stage *qs, /** - * Special-case Z testing for 16-bit Zbuffer, PIPE_FUNC_LESS and - * Z buffer writes enabled. - * - * NOTE: there's no guarantee that the quads are sequentially side by - * side. The fragment shader may have culled some quads, etc. Sliver - * triangles may generate non-sequential quads. + * Special-case Z testing for 16-bit Zbuffer and Z buffer writes enabled. */ -static void -depth_interp_z16_less_write(struct quad_stage *qs, - struct quad_header *quads[], - unsigned nr) -{ - unsigned i, pass = 0; - const unsigned ix = quads[0]->input.x0; - const unsigned iy = quads[0]->input.y0; - const float fx = (float) ix; - const float fy = (float) iy; - const float dzdx = quads[0]->posCoef->dadx[2]; - const float dzdy = quads[0]->posCoef->dady[2]; - const float z0 = quads[0]->posCoef->a0[2] + dzdx * fx + dzdy * fy; - struct softpipe_cached_tile *tile; - ushort (*depth16)[TILE_SIZE]; - ushort init_idepth[4], idepth[4], depth_step; - const float scale = 65535.0; - - /* compute scaled depth of the four pixels in first quad */ - init_idepth[0] = (ushort)((z0) * scale); - init_idepth[1] = (ushort)((z0 + dzdx) * scale); - init_idepth[2] = (ushort)((z0 + dzdy) * scale); - init_idepth[3] = (ushort)((z0 + dzdx + dzdy) * scale); - - depth_step = (ushort)(dzdx * scale); - - tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache, ix, iy); - - for (i = 0; i < nr; i++) { - const unsigned outmask = quads[i]->inout.mask; - const int dx = quads[i]->input.x0 - ix; - unsigned mask = 0; - - /* compute depth for this quad */ - idepth[0] = init_idepth[0] + dx * depth_step; - idepth[1] = init_idepth[1] + dx * depth_step; - idepth[2] = init_idepth[2] + dx * depth_step; - idepth[3] = init_idepth[3] + dx * depth_step; - - depth16 = (ushort (*)[TILE_SIZE]) - &tile->data.depth16[iy % TILE_SIZE][(ix + dx)% TILE_SIZE]; - - if ((outmask & 1) && idepth[0] < depth16[0][0]) { - depth16[0][0] = idepth[0]; - mask |= (1 << 0); - } - - if ((outmask & 2) && idepth[1] < depth16[0][1]) { - depth16[0][1] = idepth[1]; - mask |= (1 << 1); - } - - if ((outmask & 4) && idepth[2] < depth16[1][0]) { - depth16[1][0] = idepth[2]; - mask |= (1 << 2); - } - - if ((outmask & 8) && idepth[3] < depth16[1][1]) { - depth16[1][1] = idepth[3]; - mask |= (1 << 3); - } - - quads[i]->inout.mask = mask; - if (quads[i]->inout.mask) - quads[pass++] = quads[i]; - } - - if (pass) - qs->next->run(qs->next, quads, pass); - -} - - -/** - * Special-case Z testing for 16-bit Zbuffer, PIPE_FUNC_LEQUAL and - * Z buffer writes enabled. - * - * NOTE: there's no guarantee that the quads are sequentially side by - * side. The fragment shader may have culled some quads, etc. Sliver - * triangles may generate non-sequential quads. - */ -static void -depth_interp_z16_lequal_write(struct quad_stage *qs, - struct quad_header *quads[], - unsigned nr) -{ - unsigned i, pass = 0; - const unsigned ix = quads[0]->input.x0; - const unsigned iy = quads[0]->input.y0; - const float fx = (float) ix; - const float fy = (float) iy; - const float dzdx = quads[0]->posCoef->dadx[2]; - const float dzdy = quads[0]->posCoef->dady[2]; - const float z0 = quads[0]->posCoef->a0[2] + dzdx * fx + dzdy * fy; - struct softpipe_cached_tile *tile; - ushort (*depth16)[TILE_SIZE]; - ushort init_idepth[4], idepth[4], depth_step; - const float scale = 65535.0; - - /* compute scaled depth of the four pixels in first quad */ - init_idepth[0] = (ushort)((z0) * scale); - init_idepth[1] = (ushort)((z0 + dzdx) * scale); - init_idepth[2] = (ushort)((z0 + dzdy) * scale); - init_idepth[3] = (ushort)((z0 + dzdx + dzdy) * scale); - - depth_step = (ushort)(dzdx * scale); - - tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache, ix, iy); - - for (i = 0; i < nr; i++) { - const unsigned outmask = quads[i]->inout.mask; - const int dx = quads[i]->input.x0 - ix; - unsigned mask = 0; - - /* compute depth for this quad */ - idepth[0] = init_idepth[0] + dx * depth_step; - idepth[1] = init_idepth[1] + dx * depth_step; - idepth[2] = init_idepth[2] + dx * depth_step; - idepth[3] = init_idepth[3] + dx * depth_step; - - depth16 = (ushort (*)[TILE_SIZE]) - &tile->data.depth16[iy % TILE_SIZE][(ix + dx)% TILE_SIZE]; - if ((outmask & 1) && idepth[0] <= depth16[0][0]) { - depth16[0][0] = idepth[0]; - mask |= (1 << 0); - } - - if ((outmask & 2) && idepth[1] <= depth16[0][1]) { - depth16[0][1] = idepth[1]; - mask |= (1 << 1); - } +#define NAME depth_interp_z16_less_write +#define OPERATOR < +#include "sp_quad_depth_test_tmp.h" - if ((outmask & 4) && idepth[2] <= depth16[1][0]) { - depth16[1][0] = idepth[2]; - mask |= (1 << 2); - } +#define NAME depth_interp_z16_equal_write +#define OPERATOR == +#include "sp_quad_depth_test_tmp.h" - if ((outmask & 8) && idepth[3] <= depth16[1][1]) { - depth16[1][1] = idepth[3]; - mask |= (1 << 3); - } +#define NAME depth_interp_z16_lequal_write +#define OPERATOR <= +#include "sp_quad_depth_test_tmp.h" - depth16 = (ushort (*)[TILE_SIZE]) &depth16[0][2]; +#define NAME depth_interp_z16_greater_write +#define OPERATOR > +#include "sp_quad_depth_test_tmp.h" - quads[i]->inout.mask = mask; - if (quads[i]->inout.mask) - quads[pass++] = quads[i]; - } - - if (pass) - qs->next->run(qs->next, quads, pass); - -} +#define NAME depth_interp_z16_notequal_write +#define OPERATOR != +#include "sp_quad_depth_test_tmp.h" +#define NAME depth_interp_z16_gequal_write +#define OPERATOR >= +#include "sp_quad_depth_test_tmp.h" +#define NAME depth_interp_z16_always_write +#define ALWAYS 1 +#include "sp_quad_depth_test_tmp.h" @@ -926,6 +793,10 @@ choose_depth_test(struct quad_stage *qs, boolean occlusion = qs->softpipe->active_query_count; + /* default */ + qs->run = depth_test_quads_fallback; + + /* look for special cases */ if (!alpha && !depth && !stencil) { @@ -938,36 +809,40 @@ choose_depth_test(struct quad_stage *qs, !occlusion && !stencil) { - switch (depthfunc) { - case PIPE_FUNC_LESS: - switch (qs->softpipe->framebuffer.zsbuf->format) { - case PIPE_FORMAT_Z16_UNORM: + if (qs->softpipe->framebuffer.zsbuf->format == PIPE_FORMAT_Z16_UNORM) { + switch (depthfunc) { + case PIPE_FUNC_NEVER: + qs->run = depth_test_quads_fallback; + break; + case PIPE_FUNC_LESS: qs->run = depth_interp_z16_less_write; break; - default: - qs->run = depth_test_quads_fallback; + case PIPE_FUNC_EQUAL: + qs->run = depth_interp_z16_equal_write; break; - } - break; - case PIPE_FUNC_LEQUAL: - switch (qs->softpipe->framebuffer.zsbuf->format) { - case PIPE_FORMAT_Z16_UNORM: + case PIPE_FUNC_LEQUAL: qs->run = depth_interp_z16_lequal_write; break; + case PIPE_FUNC_GREATER: + qs->run = depth_interp_z16_greater_write; + break; + case PIPE_FUNC_NOTEQUAL: + qs->run = depth_interp_z16_notequal_write; + break; + case PIPE_FUNC_GEQUAL: + qs->run = depth_interp_z16_gequal_write; + break; + case PIPE_FUNC_ALWAYS: + qs->run = depth_interp_z16_always_write; + break; default: qs->run = depth_test_quads_fallback; break; } - break; - default: - qs->run = depth_test_quads_fallback; } } - else { - qs->run = depth_test_quads_fallback; - } - + /* next quad/fragment stage */ qs->run( qs, quads, nr ); } diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h b/src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h new file mode 100644 index 0000000000..25af415c25 --- /dev/null +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test_tmp.h @@ -0,0 +1,147 @@ +/************************************************************************** + * + * Copyright 2010 VMware, Inc. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the + * "Software"), to deal in the Software without restriction, including + * without limitation the rights to use, copy, modify, merge, publish, + * distribute, sub license, and/or sell copies of the Software, and to + * permit persons to whom the Software is furnished to do so, subject to + * the following conditions: + * + * The above copyright notice and this permission notice (including the + * next paragraph) shall be included in all copies or substantial portions + * of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR + * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, + * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE + * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + **************************************************************************/ + + +/* + * Template for generating Z test functions + * Only PIPE_FORMAT_Z16_UNORM supported at this time. + */ + + +#ifndef NAME +#error "NAME is not defined!" +#endif + +#if !defined(OPERATOR) && !defined(ALWAYS) +#error "neither OPERATOR nor ALWAYS is defined!" +#endif + + +/* + * NOTE: there's no guarantee that the quads are sequentially side by + * side. The fragment shader may have culled some quads, etc. Sliver + * triangles may generate non-sequential quads. + */ +static void +NAME(struct quad_stage *qs, + struct quad_header *quads[], + unsigned nr) +{ + unsigned i, pass = 0; + const unsigned ix = quads[0]->input.x0; + const unsigned iy = quads[0]->input.y0; + const float fx = (float) ix; + const float fy = (float) iy; + const float dzdx = quads[0]->posCoef->dadx[2]; + const float dzdy = quads[0]->posCoef->dady[2]; + const float z0 = quads[0]->posCoef->a0[2] + dzdx * fx + dzdy * fy; + struct softpipe_cached_tile *tile; + ushort (*depth16)[TILE_SIZE]; + ushort init_idepth[4], idepth[4], depth_step; + const float scale = 65535.0; + + /* compute scaled depth of the four pixels in first quad */ + init_idepth[0] = (ushort)((z0) * scale); + init_idepth[1] = (ushort)((z0 + dzdx) * scale); + init_idepth[2] = (ushort)((z0 + dzdy) * scale); + init_idepth[3] = (ushort)((z0 + dzdx + dzdy) * scale); + + depth_step = (ushort)(dzdx * scale); + + tile = sp_get_cached_tile(qs->softpipe->zsbuf_cache, ix, iy); + + for (i = 0; i < nr; i++) { + const unsigned outmask = quads[i]->inout.mask; + const int dx = quads[i]->input.x0 - ix; + unsigned mask = 0; + + /* compute depth for this quad */ + idepth[0] = init_idepth[0] + dx * depth_step; + idepth[1] = init_idepth[1] + dx * depth_step; + idepth[2] = init_idepth[2] + dx * depth_step; + idepth[3] = init_idepth[3] + dx * depth_step; + + depth16 = (ushort (*)[TILE_SIZE]) + &tile->data.depth16[iy % TILE_SIZE][(ix + dx)% TILE_SIZE]; + +#ifdef ALWAYS + if (outmask & 1) { + depth16[0][0] = idepth[0]; + mask |= (1 << 0); + } + + if (outmask & 2) { + depth16[0][1] = idepth[1]; + mask |= (1 << 1); + } + + if (outmask & 4) { + depth16[1][0] = idepth[2]; + mask |= (1 << 2); + } + + if (outmask & 8) { + depth16[1][1] = idepth[3]; + mask |= (1 << 3); + } +#else + /* Note: OPERATOR appears here: */ + if ((outmask & 1) && (idepth[0] OPERATOR depth16[0][0])) { + depth16[0][0] = idepth[0]; + mask |= (1 << 0); + } + + if ((outmask & 2) && (idepth[1] OPERATOR depth16[0][1])) { + depth16[0][1] = idepth[1]; + mask |= (1 << 1); + } + + if ((outmask & 4) && (idepth[2] OPERATOR depth16[1][0])) { + depth16[1][0] = idepth[2]; + mask |= (1 << 2); + } + + if ((outmask & 8) && (idepth[3] OPERATOR depth16[1][1])) { + depth16[1][1] = idepth[3]; + mask |= (1 << 3); + } +#endif + + depth16 = (ushort (*)[TILE_SIZE]) &depth16[0][2]; + + quads[i]->inout.mask = mask; + if (quads[i]->inout.mask) + quads[pass++] = quads[i]; + } + + if (pass) + qs->next->run(qs->next, quads, pass); +} + + +#undef NAME +#undef OPERATOR +#undef ALWAYS -- cgit v1.2.3 From ff54af530bc17429eda73a761dd6b73e3ec0d6ef Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 23 Mar 2010 09:08:35 -0600 Subject: softpipe: comments, re-formatting, etc --- src/gallium/drivers/softpipe/sp_quad_depth_test.c | 38 ++++++++++++++--------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_quad_depth_test.c b/src/gallium/drivers/softpipe/sp_quad_depth_test.c index 5854cee1be..17cd5b8207 100644 --- a/src/gallium/drivers/softpipe/sp_quad_depth_test.c +++ b/src/gallium/drivers/softpipe/sp_quad_depth_test.c @@ -1,6 +1,7 @@ /************************************************************************** * * Copyright 2007 Tungsten Graphics, Inc., Cedar Park, Texas. + * Copyright 2010 VMware, Inc. * All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a @@ -18,7 +19,7 @@ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. - * IN NO EVENT SHALL TUNGSTEN GRAPHICS AND/OR ITS SUPPLIERS BE LIABLE FOR + * IN NO EVENT SHALL THE AUTHORS AND/OR ITS SUPPLIERS BE LIABLE FOR * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. @@ -26,7 +27,7 @@ **************************************************************************/ /** - * \brief Quad depth testing + * \brief Quad depth / stencil testing */ #include "pipe/p_defines.h" @@ -96,7 +97,9 @@ get_depth_stencil_values( struct depth_data *data, } } -/* If the shader has not been run, interpolate the depth values + +/** + * If the shader has not been run, interpolate the depth values * ourselves. */ static void @@ -115,6 +118,9 @@ interpolate_quad_depth( struct quad_header *quad ) } +/** + * Compute the depth_data::qzzzz[] values from the float fragment Z values. + */ static void convert_quad_depth( struct depth_data *data, const struct quad_header *quad ) @@ -173,6 +179,9 @@ convert_quad_depth( struct depth_data *data, +/** + * Write data->bzzzz[] values and data->stencilVals into the Z/stencil buffer. + */ static void write_depth_stencil_values( struct depth_data *data, struct quad_header *quad ) @@ -225,7 +234,6 @@ write_depth_stencil_values( struct depth_data *data, - /** Only 8-bit stencil supported */ #define STENCIL_MAX 0xff @@ -408,12 +416,11 @@ apply_stencil_op(struct depth_data *data, -/* +/** * To increase efficiency, we should probably have multiple versions * of this function that are specifically for Z16, Z32 and FP Z buffers. * Try to effectively do that with codegen... */ - static boolean depth_test_quad(struct quad_stage *qs, struct depth_data *data, @@ -523,7 +530,6 @@ depth_stencil_test_quad(struct quad_stage *qs, wrtMask = softpipe->depth_stencil->stencil[face].writemask; valMask = softpipe->depth_stencil->stencil[face].valuemask; - /* do the stencil test first */ { unsigned passMask, failMask; @@ -563,7 +569,7 @@ depth_stencil_test_quad(struct quad_stage *qs, #define ALPHATEST( FUNC, COMP ) \ - static int \ + static int \ alpha_test_quads_##FUNC( struct quad_stage *qs, \ struct quad_header *quads[], \ unsigned nr ) \ @@ -629,6 +635,7 @@ alpha_test_quads(struct quad_stage *qs, } } + static unsigned mask_count[16] = { 0, /* 0x0 */ @@ -665,6 +672,9 @@ get_depth_bits(struct quad_stage *qs) +/** + * General depth/stencil test function. Used when there's no fast-path. + */ static void depth_test_quads_fallback(struct quad_stage *qs, struct quad_header *quads[], @@ -712,7 +722,6 @@ depth_test_quads_fallback(struct quad_stage *qs, write_depth_stencil_values(&data, quads[i]); } - quads[pass++] = quads[i]; } @@ -848,22 +857,23 @@ choose_depth_test(struct quad_stage *qs, - - -static void depth_test_begin(struct quad_stage *qs) +static void +depth_test_begin(struct quad_stage *qs) { qs->run = choose_depth_test; qs->next->begin(qs->next); } -static void depth_test_destroy(struct quad_stage *qs) +static void +depth_test_destroy(struct quad_stage *qs) { FREE( qs ); } -struct quad_stage *sp_quad_depth_test_stage( struct softpipe_context *softpipe ) +struct quad_stage * +sp_quad_depth_test_stage(struct softpipe_context *softpipe) { struct quad_stage *stage = CALLOC_STRUCT(quad_stage); -- cgit v1.2.3