From 7519107a9787970f9b3b8ec317a2b4526e217290 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Dec 2008 16:54:16 +0000 Subject: draw: add const qualifiers --- src/gallium/auxiliary/draw/draw_context.c | 4 ++-- src/gallium/auxiliary/draw/draw_context.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 41a4cba1dd..74deb44bd2 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -362,7 +362,7 @@ draw_set_mapped_element_buffer_range( struct draw_context *draw, unsigned eltSize, unsigned min_index, unsigned max_index, - void *elements ) + const void *elements ) { draw->pt.user.elts = elements; draw->pt.user.eltSize = eltSize; @@ -374,7 +374,7 @@ draw_set_mapped_element_buffer_range( struct draw_context *draw, void draw_set_mapped_element_buffer( struct draw_context *draw, unsigned eltSize, - void *elements ) + const void *elements ) { draw->pt.user.elts = elements; draw->pt.user.eltSize = eltSize; diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index 3eeb453531..1d40c6c3be 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -123,11 +123,11 @@ draw_set_mapped_element_buffer_range( struct draw_context *draw, unsigned eltSize, unsigned min_index, unsigned max_index, - void *elements ); + const void *elements ); void draw_set_mapped_element_buffer( struct draw_context *draw, unsigned eltSize, - void *elements ); + const void *elements ); void draw_set_mapped_vertex_buffer(struct draw_context *draw, unsigned attr, const void *buffer); -- cgit v1.2.3 From 50beb86ce399534b049322f1074365ed03395ab2 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Tue, 9 Dec 2008 16:57:53 +0000 Subject: util: new funcs for triming/validating primitives --- src/gallium/auxiliary/util/u_prim.h | 122 ++++++++++++++++++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 src/gallium/auxiliary/util/u_prim.h (limited to 'src') diff --git a/src/gallium/auxiliary/util/u_prim.h b/src/gallium/auxiliary/util/u_prim.h new file mode 100644 index 0000000000..e45e84ded2 --- /dev/null +++ b/src/gallium/auxiliary/util/u_prim.h @@ -0,0 +1,122 @@ +/************************************************************************** + * + * Copyright 2008 Tungsten Graphics, Inc., Cedar Park, Texas. + * 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 TUNGSTEN GRAPHICS 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. + * + **************************************************************************/ + + +#ifndef U_BLIT_H +#define U_BLIT_H + + +#ifdef __cplusplus +extern "C" { +#endif + +#include "pipe/p_defines.h" + +static INLINE boolean u_validate_pipe_prim( unsigned pipe_prim, unsigned nr ) +{ + boolean ok = TRUE; + + switch (pipe_prim) { + case PIPE_PRIM_POINTS: + ok = (nr >= 1); + break; + case PIPE_PRIM_LINES: + ok = (nr >= 2); + break; + case PIPE_PRIM_LINE_STRIP: + case PIPE_PRIM_LINE_LOOP: + ok = (nr >= 2); + break; + case PIPE_PRIM_TRIANGLES: + ok = (nr >= 3); + break; + case PIPE_PRIM_TRIANGLE_STRIP: + case PIPE_PRIM_TRIANGLE_FAN: + case PIPE_PRIM_POLYGON: + ok = (nr >= 3); + break; + case PIPE_PRIM_QUADS: + ok = (nr >= 4); + break; + case PIPE_PRIM_QUAD_STRIP: + ok = (nr >= 4); + break; + default: + ok = 0; + break; + } + + return ok; +} + + +static INLINE boolean u_trim_pipe_prim( unsigned pipe_prim, unsigned *nr ) +{ + boolean ok = TRUE; + + switch (pipe_prim) { + case PIPE_PRIM_POINTS: + ok = (*nr >= 1); + break; + case PIPE_PRIM_LINES: + ok = (*nr >= 2); + *nr -= (*nr % 2); + break; + case PIPE_PRIM_LINE_STRIP: + case PIPE_PRIM_LINE_LOOP: + ok = (*nr >= 2); + break; + case PIPE_PRIM_TRIANGLES: + ok = (*nr >= 3); + *nr -= (*nr % 3); + break; + case PIPE_PRIM_TRIANGLE_STRIP: + case PIPE_PRIM_TRIANGLE_FAN: + case PIPE_PRIM_POLYGON: + ok = (*nr >= 3); + break; + case PIPE_PRIM_QUADS: + ok = (*nr >= 4); + *nr -= (*nr % 4); + break; + case PIPE_PRIM_QUAD_STRIP: + ok = (*nr >= 4); + *nr -= (*nr % 2); + break; + default: + ok = 0; + break; + } + + if (!ok) + *nr = 0; + + return ok; +} + + +#endif -- cgit v1.2.3 From 99b862cd77fb088d0b2e62c6c15ecef82ec4fb80 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Dec 2008 18:00:36 -0700 Subject: gallium: restore default_depth_bits() call in xlib winsys This was accidentally disabled in a long-ago commit. --- src/gallium/winsys/xlib/fakeglx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/winsys/xlib/fakeglx.c b/src/gallium/winsys/xlib/fakeglx.c index 2c0075e934..a56e63572a 100644 --- a/src/gallium/winsys/xlib/fakeglx.c +++ b/src/gallium/winsys/xlib/fakeglx.c @@ -419,7 +419,7 @@ static XMesaVisual create_glx_visual( Display *dpy, XVisualInfo *visinfo ) { int vislevel; - GLint zBits = 24; /*default_depth_bits();*/ + GLint zBits = default_depth_bits(); GLint accBits = default_accum_bits(); GLboolean alphaFlag = default_alpha_bits() > 0; @@ -1289,7 +1289,7 @@ choose_visual( Display *dpy, int screen, const int *list, GLboolean fbConfig ) double_flag = GL_TRUE; if (vis->depth > 8) rgb_flag = GL_TRUE; - depth_size = 24; /*default_depth_bits();*/ + depth_size = default_depth_bits(); stencil_size = STENCIL_BITS; /* XXX accum??? */ } -- cgit v1.2.3 From 8137da952b6f30329adf7d49d2d9e58625534dd4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Dec 2008 18:00:59 -0700 Subject: gallium: only mark back color buffer surfaces as undefined after swapbuffers Marking all surfaces as undefined was wrong and cause some glean failures because glReadPixels was used after SwapBuffers. --- src/mesa/state_tracker/st_framebuffer.c | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/mesa/state_tracker/st_framebuffer.c b/src/mesa/state_tracker/st_framebuffer.c index 6ee1777fb7..7d270a3272 100644 --- a/src/mesa/state_tracker/st_framebuffer.c +++ b/src/mesa/state_tracker/st_framebuffer.c @@ -284,15 +284,17 @@ st_notify_swapbuffers_complete(struct st_framebuffer *stfb) if (ctx && ctx->DrawBuffer == &stfb->Base) { struct st_renderbuffer *strb; - int i; - - for (i = 0; i < BUFFER_COUNT; i++) { - if (stfb->Base.Attachment[i].Renderbuffer) { - strb = st_renderbuffer(stfb->Base.Attachment[i].Renderbuffer); - if (strb->surface) - strb->surface->status = PIPE_SURFACE_STATUS_UNDEFINED; - } - } + + /* Mark back color buffers as undefined */ + strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_BACK_LEFT]. + Renderbuffer); + if (strb && strb->surface) + strb->surface->status = PIPE_SURFACE_STATUS_UNDEFINED; + + strb = st_renderbuffer(stfb->Base.Attachment[BUFFER_BACK_RIGHT]. + Renderbuffer); + if (strb && strb->surface) + strb->surface->status = PIPE_SURFACE_STATUS_UNDEFINED; } } -- cgit v1.2.3 From d0bc5293d6e1e9c34fa822b7c2928932ed22462c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 10 Dec 2008 18:02:27 -0700 Subject: gallium: added draw_set_mrd() function to fix polygon offset The Minimum Resolvable Depth factor depends on the driver and can't just be computed from the number of Z buffer bits. Glean's polygon offset test now passes with softpipe. Still need to determine the MRD factor for other gallium drivers, if they use the draw module's polygon offset stage... --- src/gallium/auxiliary/draw/draw_context.c | 12 ++++++++++++ src/gallium/auxiliary/draw/draw_context.h | 1 + src/gallium/auxiliary/draw/draw_pipe_offset.c | 3 +-- src/gallium/auxiliary/draw/draw_private.h | 2 ++ src/gallium/drivers/softpipe/sp_state_surface.c | 20 ++++++++++++++++++++ 5 files changed, 36 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/draw/draw_context.c b/src/gallium/auxiliary/draw/draw_context.c index 74deb44bd2..fab8fc95fc 100644 --- a/src/gallium/auxiliary/draw/draw_context.c +++ b/src/gallium/auxiliary/draw/draw_context.c @@ -103,6 +103,18 @@ void draw_flush( struct draw_context *draw ) } +/** + * Specify the Minimum Resolvable Depth factor for polygon offset. + * This factor potentially depends on the number of Z buffer bits, + * the rasterization algorithm and the arithmetic performed on Z + * values between vertex shading and rasterization. It will vary + * from one driver to another. + */ +void draw_set_mrd(struct draw_context *draw, double mrd) +{ + draw->mrd = mrd; +} + /** * Register new primitive rasterization/rendering state. diff --git a/src/gallium/auxiliary/draw/draw_context.h b/src/gallium/auxiliary/draw/draw_context.h index 1d40c6c3be..a29bb01d81 100644 --- a/src/gallium/auxiliary/draw/draw_context.h +++ b/src/gallium/auxiliary/draw/draw_context.h @@ -72,6 +72,7 @@ void draw_enable_line_stipple(struct draw_context *draw, boolean enable); void draw_enable_point_sprites(struct draw_context *draw, boolean enable); +void draw_set_mrd(struct draw_context *draw, double mrd); boolean draw_install_aaline_stage(struct draw_context *draw, struct pipe_context *pipe); diff --git a/src/gallium/auxiliary/draw/draw_pipe_offset.c b/src/gallium/auxiliary/draw/draw_pipe_offset.c index 1fea5e6dcb..8ddc4ee617 100644 --- a/src/gallium/auxiliary/draw/draw_pipe_offset.c +++ b/src/gallium/auxiliary/draw/draw_pipe_offset.c @@ -122,9 +122,8 @@ static void offset_first_tri( struct draw_stage *stage, struct prim_header *header ) { struct offset_stage *offset = offset_stage(stage); - float mrd = 1.0f / 65535.0f; /* XXX this depends on depthbuffer bits! */ - offset->units = stage->draw->rasterizer->offset_units * mrd; + offset->units = stage->draw->rasterizer->offset_units * stage->draw->mrd; offset->scale = stage->draw->rasterizer->offset_scale; stage->tri = offset_tri; diff --git a/src/gallium/auxiliary/draw/draw_private.h b/src/gallium/auxiliary/draw/draw_private.h index 37c4c87f87..a16b45d340 100644 --- a/src/gallium/auxiliary/draw/draw_private.h +++ b/src/gallium/auxiliary/draw/draw_private.h @@ -172,6 +172,8 @@ struct draw_context boolean force_passthrough; /**< never clip or shade */ + double mrd; /**< minimum resolvable depth value, for polygon offset */ + /* pipe state that we need: */ const struct pipe_rasterizer_state *rasterizer; struct pipe_viewport_state viewport; diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c index ba8c9eece7..8877b18af9 100644 --- a/src/gallium/drivers/softpipe/sp_state_surface.c +++ b/src/gallium/drivers/softpipe/sp_state_surface.c @@ -101,6 +101,26 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe, } #endif + /* Tell draw module how deep the Z/depth buffer is */ + { + int depth_bits; + double mrd; + if (sp->framebuffer.zsbuf) { + depth_bits = pf_get_component_bits(sp->framebuffer.zsbuf->format, + PIPE_FORMAT_COMP_Z); + } + else { + depth_bits = 0; + } + if (depth_bits > 16) { + mrd = 0.0000001; + } + else { + mrd = 0.00002; + } + draw_set_mrd(sp->draw, mrd); + } + sp->framebuffer.width = fb->width; sp->framebuffer.height = fb->height; -- cgit v1.2.3