From db22b35d213d58d188252f45d94fa353e638acee Mon Sep 17 00:00:00 2001 From: Thomas Hellstrom Date: Thu, 11 Jun 2009 00:54:06 +0200 Subject: dri st: Don't require the PIPE_TEXTURE_USAGE_RENDER_TARGET property for depth- and stencil renderbuffers. Signed-off-by: Thomas Hellstrom --- src/gallium/state_trackers/dri/dri_drawable.c | 2 -- 1 file changed, 2 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/dri/dri_drawable.c b/src/gallium/state_trackers/dri/dri_drawable.c index 15a2088df51..5846390d02c 100644 --- a/src/gallium/state_trackers/dri/dri_drawable.c +++ b/src/gallium/state_trackers/dri/dri_drawable.c @@ -231,7 +231,6 @@ dri_create_buffer(__DRIscreenPrivate * sPriv, if (visual->depthBits) { if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) depthFormat = PIPE_FORMAT_Z24S8_UNORM; else @@ -242,7 +241,6 @@ dri_create_buffer(__DRIscreenPrivate * sPriv, if (visual->stencilBits) { if (pscreen->is_format_supported(pscreen, PIPE_FORMAT_Z24S8_UNORM, PIPE_TEXTURE_2D, - PIPE_TEXTURE_USAGE_RENDER_TARGET | PIPE_TEXTURE_USAGE_DEPTH_STENCIL, 0)) stencilFormat = PIPE_FORMAT_Z24S8_UNORM; else -- cgit v1.2.3 From 5d0cf9ebb41c05b0c6fa6914ccbb1e1871e27099 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 18:42:13 +0100 Subject: softpipe: Fix softpipe_is_texture_referenced. Render results are only visible when the render cache is flushed. softpipe_is_texture_referenced must reflect that or transfers to/from the textures bound in the framebuffer won't be proceeded of the necessary flush, causing transfer data to be outdated/clobbered. This fixes conform drawpix test with softpipe. --- src/gallium/drivers/softpipe/sp_context.c | 16 ++++++++++++++++ src/gallium/drivers/softpipe/sp_context.h | 2 ++ src/gallium/drivers/softpipe/sp_draw_arrays.c | 2 ++ src/gallium/drivers/softpipe/sp_flush.c | 2 ++ 4 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 62e8d99cfd0..86df320ea8a 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -126,6 +126,22 @@ softpipe_is_texture_referenced( struct pipe_context *pipe, struct pipe_texture *texture, unsigned face, unsigned level) { + struct softpipe_context *softpipe = softpipe_context( pipe ); + unsigned i; + + if(softpipe->dirty_render_cache) { + for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) { + if(softpipe->framebuffer.cbufs[i] && + softpipe->framebuffer.cbufs[i]->texture == texture) + return PIPE_REFERENCED_FOR_WRITE; + } + if(softpipe->framebuffer.zsbuf && + softpipe->framebuffer.zsbuf->texture == texture) + return PIPE_REFERENCED_FOR_WRITE; + } + + /* FIXME: we also need to do the same for the texture cache */ + return PIPE_UNREFERENCED; } diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 59d6df8f2dd..dffc15a4f19 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -144,6 +144,8 @@ struct softpipe_context { struct draw_stage *vbuf; struct softpipe_vbuf_render *vbuf_render; + boolean dirty_render_cache; + struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS]; struct softpipe_tile_cache *zsbuf_cache; diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index f117096bf73..ba2766ff139 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -182,6 +182,8 @@ softpipe_draw_range_elements(struct pipe_context *pipe, /* Note: leave drawing surfaces mapped */ softpipe_unmap_constant_buffers(sp); + sp->dirty_render_cache = TRUE; + return TRUE; } diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index 035f4b963eb..4a14d49686e 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -71,6 +71,8 @@ softpipe_flush( struct pipe_context *pipe, * to unmap surfaces when flushing. */ softpipe_unmap_transfers(softpipe); + + softpipe->dirty_render_cache = FALSE; } /* Enable to dump BMPs of the color/depth buffers each frame */ -- cgit v1.2.3 From 940cb7ce163664778f7055953392fb43d5fc31fc Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 18:57:45 +0100 Subject: gallium: Ensure assert macro is defined before being used in p_thread.h --- src/gallium/include/pipe/p_thread.h | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/gallium/include/pipe/p_thread.h b/src/gallium/include/pipe/p_thread.h index de55e99ed49..ce8d79549ad 100644 --- a/src/gallium/include/pipe/p_thread.h +++ b/src/gallium/include/pipe/p_thread.h @@ -36,6 +36,7 @@ #include "pipe/p_compiler.h" +#include "util/u_debug.h" /* for assert */ #if defined(PIPE_OS_LINUX) || defined(PIPE_OS_BSD) || defined(PIPE_OS_SOLARIS) -- cgit v1.2.3 From c33ef1f7c6d93a82c77a6c11fd108bb6d4f8c6af Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 19:04:04 +0100 Subject: rtasm: Use 32bit constant. As we're only using 32bit bitmasks. --- src/gallium/auxiliary/rtasm/rtasm_ppc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/auxiliary/rtasm/rtasm_ppc.c b/src/gallium/auxiliary/rtasm/rtasm_ppc.c index e3586482db4..ef4b306cb67 100644 --- a/src/gallium/auxiliary/rtasm/rtasm_ppc.c +++ b/src/gallium/auxiliary/rtasm/rtasm_ppc.c @@ -168,7 +168,7 @@ ppc_allocate_register(struct ppc_function *p) { unsigned i; for (i = 0; i < PPC_NUM_REGS; i++) { - const uint64_t mask = 1 << i; + const uint32_t mask = 1 << i; if ((p->reg_used & mask) == 0) { p->reg_used |= mask; return i; @@ -200,7 +200,7 @@ ppc_allocate_fp_register(struct ppc_function *p) { unsigned i; for (i = 0; i < PPC_NUM_FP_REGS; i++) { - const uint64_t mask = 1 << i; + const uint32_t mask = 1 << i; if ((p->fp_used & mask) == 0) { p->fp_used |= mask; return i; @@ -232,7 +232,7 @@ ppc_allocate_vec_register(struct ppc_function *p) { unsigned i; for (i = 0; i < PPC_NUM_VEC_REGS; i++) { - const uint64_t mask = 1 << i; + const uint32_t mask = 1 << i; if ((p->vec_used & mask) == 0) { p->vec_used |= mask; return i; -- cgit v1.2.3 From 37f2117cd132527ebf89f9294b2f35db87326460 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 19:17:07 +0100 Subject: mesa: Use integer type with appropriate sign. --- src/mesa/main/api_validate.c | 4 ++-- src/mesa/main/texenv.c | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index 42d1e579e08..2c6f370df94 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -40,7 +40,7 @@ max_buffer_index(GLcontext *ctx, GLuint count, GLenum type, { const GLubyte *map = NULL; GLuint max = 0; - GLint i; + GLuint i; if (elementBuf->Name) { /* elements are in a user-defined buffer object. need to map it */ @@ -224,7 +224,7 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, /* Vertex buffer object tests */ if (ctx->Array.ElementArrayBufferObj->Name) { /* use indices in the buffer object */ - GLuint indexBytes; + GLsizei indexBytes; if (type == GL_UNSIGNED_INT) { indexBytes = count * sizeof(GLuint); diff --git a/src/mesa/main/texenv.c b/src/mesa/main/texenv.c index 4d511f2f7ed..4c04a7ed375 100644 --- a/src/mesa/main/texenv.c +++ b/src/mesa/main/texenv.c @@ -959,7 +959,7 @@ void GLAPIENTRY _mesa_GetTexBumpParameterivATI( GLenum pname, GLint *param ) { const struct gl_texture_unit *texUnit; - GLint i; + GLuint i; GLint temp = 0; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); @@ -1006,7 +1006,7 @@ void GLAPIENTRY _mesa_GetTexBumpParameterfvATI( GLenum pname, GLfloat *param ) { const struct gl_texture_unit *texUnit; - GLint i; + GLuint i; GLint temp = 0; GET_CURRENT_CONTEXT(ctx); ASSERT_OUTSIDE_BEGIN_END(ctx); -- cgit v1.2.3 From 6214c7262fe2d31553a4974022e08a7715693014 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 19:19:29 +0100 Subject: mesa: Use type modifier for float constants. --- src/mesa/main/macros.h | 14 +++++++------- src/mesa/main/texformat_tmp.h | 24 ++++++++++++------------ src/mesa/main/texgetimage.c | 4 ++-- 3 files changed, 21 insertions(+), 21 deletions(-) (limited to 'src') diff --git a/src/mesa/main/macros.h b/src/mesa/main/macros.h index 01d59dd42da..59def651a39 100644 --- a/src/mesa/main/macros.h +++ b/src/mesa/main/macros.h @@ -55,7 +55,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; /** Convert GLbyte in [-128,127] to GLfloat in [-1.0,1.0], texture/fb data */ -#define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0 : (B) * (1.0F/127.0F)) +#define BYTE_TO_FLOAT_TEX(B) ((B) == -128 ? -1.0F : (B) * (1.0F/127.0F)) /** Convert GLfloat in [-1.0,1.0] to GLbyte in [-128,127], texture/fb data */ #define FLOAT_TO_BYTE_TEX(X) ( (GLint) (127.0F * (X)) ) @@ -65,7 +65,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; #define USHORT_TO_FLOAT(S) ((GLfloat) (S) * (1.0F / 65535.0F)) /** Convert GLfloat in [0.0,1.0] to GLushort in [0, 65535] */ -#define FLOAT_TO_USHORT(X) ((GLuint) ((X) * 65535.0)) +#define FLOAT_TO_USHORT(X) ((GLuint) ((X) * 65535.0F)) /** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0] */ @@ -76,7 +76,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; /** Convert GLshort in [-32768,32767] to GLfloat in [-1.0,1.0], texture/fb data */ -#define SHORT_TO_FLOAT_TEX(S) ((S) == -32768 ? -1.0 : (S) * (1.0F/32767.0F)) +#define SHORT_TO_FLOAT_TEX(S) ((S) == -32768 ? -1.0F : (S) * (1.0F/32767.0F)) /** Convert GLfloat in [-1.0,1.0] to GLshort in [-32768,32767], texture/fb data */ #define FLOAT_TO_SHORT_TEX(X) ( (GLint) (32767.0F * (X)) ) @@ -86,7 +86,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; #define UINT_TO_FLOAT(U) ((GLfloat) (U) * (1.0F / 4294967295.0F)) /** Convert GLfloat in [0.0,1.0] to GLuint in [0,4294967295] */ -#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0)) +#define FLOAT_TO_UINT(X) ((GLuint) ((X) * 4294967295.0F)) /** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0] */ @@ -97,11 +97,11 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; #define FLOAT_TO_INT(X) ( (((GLint) (4294967294.0F * (X))) - 1) / 2 ) */ /* a close approximation: */ -#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0 * (X)) ) +#define FLOAT_TO_INT(X) ( (GLint) (2147483647.0F * (X)) ) /** Convert GLint in [-2147483648,2147483647] to GLfloat in [-1.0,1.0], texture/fb data */ -#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0 : (I) * (1.0F/2147483647.0)) +#define INT_TO_FLOAT_TEX(I) ((I) == -2147483648 ? -1.0F : (I) * (1.0F/2147483647.0F)) /** Convert GLfloat in [-1.0,1.0] to GLint in [-2147483648,2147483647], texture/fb data */ #define FLOAT_TO_INT_TEX(X) ( (GLint) (2147483647.0F * (X)) ) @@ -120,7 +120,7 @@ extern GLfloat _mesa_ubyte_to_float_color_tab[256]; #define INT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 15))) #define UINT_TO_USHORT(i) ((i) < 0 ? 0 : ((GLushort) ((i) >> 16))) #define UNCLAMPED_FLOAT_TO_USHORT(us, f) \ - us = ( (GLushort) IROUND( CLAMP((f), 0.0, 1.0) * 65535.0F) ) + us = ( (GLushort) IROUND( CLAMP((f), 0.0F, 1.0F) * 65535.0F) ) #define CLAMPED_FLOAT_TO_USHORT(us, f) \ us = ( (GLushort) IROUND( (f) * 65535.0F) ) diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h index f3b2fb9c9c4..1020624faa2 100644 --- a/src/mesa/main/texformat_tmp.h +++ b/src/mesa/main/texformat_tmp.h @@ -1348,12 +1348,12 @@ static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage, const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ const GLubyte cr = *src1 & 0xff; /* chroma V */ const GLfloat y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ - GLfloat r = 1.164 * (y - 16) + 1.596 * (cr - 128); - GLfloat g = 1.164 * (y - 16) - 0.813 * (cr - 128) - 0.391 * (cb - 128); - GLfloat b = 1.164 * (y - 16) + 2.018 * (cb - 128); - r *= (1.0 / 255.0F); - g *= (1.0 / 255.0F); - b *= (1.0 / 255.0F); + GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); + GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); + GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); + r *= (1.0F / 255.0F); + g *= (1.0F / 255.0F); + b *= (1.0F / 255.0F); texel[RCOMP] = CLAMP(r, 0.0F, 1.0F); texel[GCOMP] = CLAMP(g, 0.0F, 1.0F); texel[BCOMP] = CLAMP(b, 0.0F, 1.0F); @@ -1389,12 +1389,12 @@ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage, const GLubyte y1 = *src1 & 0xff; /* luminance */ const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */ const GLfloat y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ - GLfloat r = 1.164 * (y - 16) + 1.596 * (cr - 128); - GLfloat g = 1.164 * (y - 16) - 0.813 * (cr - 128) - 0.391 * (cb - 128); - GLfloat b = 1.164 * (y - 16) + 2.018 * (cb - 128); - r *= (1.0 / 255.0F); - g *= (1.0 / 255.0F); - b *= (1.0 / 255.0F); + GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); + GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); + GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); + r *= (1.0F / 255.0F); + g *= (1.0F / 255.0F); + b *= (1.0F / 255.0F); texel[RCOMP] = CLAMP(r, 0.0F, 1.0F); texel[GCOMP] = CLAMP(g, 0.0F, 1.0F); texel[BCOMP] = CLAMP(b, 0.0F, 1.0F); diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 70a25080cb0..58421c85283 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -73,8 +73,8 @@ linear_to_nonlinear(GLfloat cl) { /* can't have values outside [0, 1] */ GLfloat cs; - if (cl < 0.0031308) { - cs = 12.92 * cl; + if (cl < 0.0031308f) { + cs = 12.92f * cl; } else { cs = 1.055 * _mesa_pow(cl, 0.41666) - 0.055; -- cgit v1.2.3 From 053d8eb8914cae274ccd19abb0a492e7ca220660 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 19:20:05 +0100 Subject: mesa: Use appropriate float/integer types. --- src/mesa/main/texformat_tmp.h | 4 ++-- src/mesa/main/texgetimage.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/mesa/main/texformat_tmp.h b/src/mesa/main/texformat_tmp.h index 1020624faa2..eb160deff93 100644 --- a/src/mesa/main/texformat_tmp.h +++ b/src/mesa/main/texformat_tmp.h @@ -1347,7 +1347,7 @@ static void FETCH(f_ycbcr)( const struct gl_texture_image *texImage, const GLubyte cb = *src0 & 0xff; /* chroma U */ const GLubyte y1 = (*src1 >> 8) & 0xff; /* luminance */ const GLubyte cr = *src1 & 0xff; /* chroma V */ - const GLfloat y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ + const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); @@ -1388,7 +1388,7 @@ static void FETCH(f_ycbcr_rev)( const struct gl_texture_image *texImage, const GLubyte cr = (*src0 >> 8) & 0xff; /* chroma V */ const GLubyte y1 = *src1 & 0xff; /* luminance */ const GLubyte cb = (*src1 >> 8) & 0xff; /* chroma U */ - const GLfloat y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ + const GLubyte y = (i & 1) ? y1 : y0; /* choose even/odd luminance */ GLfloat r = 1.164F * (y - 16) + 1.596F * (cr - 128); GLfloat g = 1.164F * (y - 16) - 0.813F * (cr - 128) - 0.391F * (cb - 128); GLfloat b = 1.164F * (y - 16) + 2.018F * (cb - 128); diff --git a/src/mesa/main/texgetimage.c b/src/mesa/main/texgetimage.c index 58421c85283..02409d80098 100644 --- a/src/mesa/main/texgetimage.c +++ b/src/mesa/main/texgetimage.c @@ -77,7 +77,7 @@ linear_to_nonlinear(GLfloat cl) cs = 12.92f * cl; } else { - cs = 1.055 * _mesa_pow(cl, 0.41666) - 0.055; + cs = (GLfloat)(1.055 * _mesa_pow(cl, 0.41666) - 0.055); } return cs; } -- cgit v1.2.3 From c6af9b29476e4e445623e7a2f737ba95003bbe13 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 19:20:25 +0100 Subject: mesa: Always return a value. --- src/mesa/main/texenvprogram.c | 1 + 1 file changed, 1 insertion(+) (limited to 'src') diff --git a/src/mesa/main/texenvprogram.c b/src/mesa/main/texenvprogram.c index a70d069bd9c..b92ba2542d2 100644 --- a/src/mesa/main/texenvprogram.c +++ b/src/mesa/main/texenvprogram.c @@ -877,6 +877,7 @@ static struct ureg get_source( struct texenv_fragment_program *p, default: assert(0); + return undef; } } -- cgit v1.2.3 From 7585cbffe0ec8873a1e8d966f870aa1052943899 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 19:21:58 +0100 Subject: python/tests: Cleanup texture_sample. --- .../state_trackers/python/tests/texture_sample.py | 50 ++++++++++++++-------- 1 file changed, 32 insertions(+), 18 deletions(-) (limited to 'src') diff --git a/src/gallium/state_trackers/python/tests/texture_sample.py b/src/gallium/state_trackers/python/tests/texture_sample.py index 06130ea1c9c..c7b78abbbec 100755 --- a/src/gallium/state_trackers/python/tests/texture_sample.py +++ b/src/gallium/state_trackers/python/tests/texture_sample.py @@ -497,17 +497,13 @@ def main(): PIPE_TEXTURE_3D, ] - formats = [ + color_formats = [ PIPE_FORMAT_A8R8G8B8_UNORM, PIPE_FORMAT_X8R8G8B8_UNORM, #PIPE_FORMAT_A8R8G8B8_SRGB, PIPE_FORMAT_R5G6B5_UNORM, PIPE_FORMAT_A1R5G5B5_UNORM, PIPE_FORMAT_A4R4G4B4_UNORM, - PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_Z24X8_UNORM, - PIPE_FORMAT_Z16_UNORM, PIPE_FORMAT_A8_UNORM, PIPE_FORMAT_L8_UNORM, PIPE_FORMAT_YCBCR, @@ -517,6 +513,13 @@ def main(): #PIPE_FORMAT_DXT5_RGBA, ] + depth_formats = [ + PIPE_FORMAT_Z32_UNORM, + PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_Z16_UNORM, + ] + sizes = [64, 32, 16, 8, 4, 2, 1] #sizes = [1020, 508, 252, 62, 30, 14, 6, 3] #sizes = [64] @@ -531,8 +534,8 @@ def main(): PIPE_TEX_FACE_NEG_Z, ] - for target in targets: - for format in formats: + for format in color_formats: + for target in targets: for size in sizes: if target == PIPE_TEXTURE_3D: depth = size @@ -546,17 +549,7 @@ def main(): for level in range(0, last_level + 1): zslice = 0 while zslice < depth >> level: - if format in ( - PIPE_FORMAT_Z32_UNORM, - PIPE_FORMAT_Z24S8_UNORM, - PIPE_FORMAT_Z24X8_UNORM, - PIPE_FORMAT_Z16_UNORM, - ): - klass = TextureDepthSampleTest - else: - klass = TextureColorSampleTest - - test = klass( + test = TextureColorSampleTest( dev = dev, target = target, format = format, @@ -570,6 +563,27 @@ def main(): ) suite.add_test(test) zslice = (zslice + 1)*2 - 1 + for format in depth_formats: + target = PIPE_TEXTURE_2D + depth = 1 + face = 0 + last_level = 0 + level = 0 + zslice = 0 + for size in sizes: + test = TextureDepthSampleTest( + dev = dev, + target = target, + format = format, + width = size, + height = size, + depth = depth, + last_level = last_level, + face = face, + level = level, + zslice = zslice, + ) + suite.add_test(test) suite.run() -- cgit v1.2.3 From 227d233cffea9908e72c700441ad206635305077 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 19:22:35 +0100 Subject: python/tests: Add is_depth_stencil_format utility function. --- src/gallium/state_trackers/python/tests/base.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src') diff --git a/src/gallium/state_trackers/python/tests/base.py b/src/gallium/state_trackers/python/tests/base.py index 1fa7fe6f3b3..202ccfc3509 100755 --- a/src/gallium/state_trackers/python/tests/base.py +++ b/src/gallium/state_trackers/python/tests/base.py @@ -46,6 +46,14 @@ for name, value in globals().items(): if name.startswith("PIPE_FORMAT_") and isinstance(value, int): formats[value] = name +def is_depth_stencil_format(format): + # FIXME: make and use binding to pf_is_depth_stencil + return format in ( + PIPE_FORMAT_Z32_UNORM, + PIPE_FORMAT_Z24S8_UNORM, + PIPE_FORMAT_Z24X8_UNORM, + PIPE_FORMAT_Z16_UNORM, + ) def make_image(width, height, rgba): import Image -- cgit v1.2.3 From d027e8feff7d38cccadc6aaccc0454b21ce4dca0 Mon Sep 17 00:00:00 2001 From: Shuang He Date: Mon, 15 Jun 2009 16:19:30 -0600 Subject: intel: Release fb backing regions in intelDestroyBuffer() Fixes memory leak when destroying framebuffers. --- src/mesa/drivers/dri/intel/intel_screen.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src') diff --git a/src/mesa/drivers/dri/intel/intel_screen.c b/src/mesa/drivers/dri/intel/intel_screen.c index 65e62947ef6..50cb13a4822 100644 --- a/src/mesa/drivers/dri/intel/intel_screen.c +++ b/src/mesa/drivers/dri/intel/intel_screen.c @@ -395,6 +395,30 @@ intelCreateBuffer(__DRIscreenPrivate * driScrnPriv, static void intelDestroyBuffer(__DRIdrawablePrivate * driDrawPriv) { + struct intel_framebuffer *intel_fb = driDrawPriv->driverPrivate; + struct intel_renderbuffer *depth_rb; + struct intel_renderbuffer *stencil_rb; + + if (intel_fb) { + if (intel_fb->color_rb[0]) { + intel_renderbuffer_set_region(intel_fb->color_rb[0], NULL); + } + + if (intel_fb->color_rb[1]) { + intel_renderbuffer_set_region(intel_fb->color_rb[1], NULL); + } + + depth_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_DEPTH); + if (depth_rb) { + intel_renderbuffer_set_region(depth_rb, NULL); + } + + stencil_rb = intel_get_renderbuffer(&intel_fb->Base, BUFFER_STENCIL); + if (stencil_rb) { + intel_renderbuffer_set_region(stencil_rb, NULL); + } + } + _mesa_reference_framebuffer((GLframebuffer **)(&(driDrawPriv->driverPrivate)), NULL); } -- cgit v1.2.3 From 3463b1479d1c70e3b23189c72132e9ad5f710ff9 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 16 Jun 2009 13:05:25 +0100 Subject: gallium: Avoid atomic ops / locking when src is dst. --- src/gallium/include/pipe/p_refcnt.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) (limited to 'src') diff --git a/src/gallium/include/pipe/p_refcnt.h b/src/gallium/include/pipe/p_refcnt.h index 1f89453e09a..1f9088b3e9c 100644 --- a/src/gallium/include/pipe/p_refcnt.h +++ b/src/gallium/include/pipe/p_refcnt.h @@ -62,29 +62,29 @@ pipe_is_referenced(struct pipe_reference *reference) * Set 'ptr' to point to 'reference' and update reference counting. * The old thing pointed to, if any, will be unreferenced first. * 'reference' may be NULL. - * - * XXX: thread safety issues! */ static INLINE bool pipe_reference(struct pipe_reference **ptr, struct pipe_reference *reference) { bool destroy = FALSE; - /* bump the reference.count first */ - if (reference) { - assert(pipe_is_referenced(reference)); - p_atomic_inc(&reference->count); - } - - if (*ptr) { - assert(pipe_is_referenced(*ptr)); - if (p_atomic_dec_zero(&(*ptr)->count)) { - destroy = TRUE; + if(*ptr != reference) { + /* bump the reference.count first */ + if (reference) { + assert(pipe_is_referenced(reference)); + p_atomic_inc(&reference->count); } + + if (*ptr) { + assert(pipe_is_referenced(*ptr)); + if (p_atomic_dec_zero(&(*ptr)->count)) { + destroy = TRUE; + } + } + + *ptr = reference; } - *ptr = reference; - return destroy; } -- cgit v1.2.3 From ed7f4b42307bff4633689d6781cd3643f10041e5 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Jun 2009 08:45:06 -0600 Subject: mesa: fix REMAINDER() macro The results were incorrect for some negative values of A. See bug 21872. --- src/mesa/swrast/s_texfilter.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/mesa/swrast/s_texfilter.c b/src/mesa/swrast/s_texfilter.c index 31bfb5c9520..dd59314cd96 100644 --- a/src/mesa/swrast/s_texfilter.c +++ b/src/mesa/swrast/s_texfilter.c @@ -138,7 +138,7 @@ lerp_rgba_3d(GLfloat result[4], GLfloat a, GLfloat b, GLfloat c, * If A is a signed integer, A % B doesn't give the right value for A < 0 * (in terms of texture repeat). Just casting to unsigned fixes that. */ -#define REMAINDER(A, B) ((unsigned) (A) % (unsigned) (B)) +#define REMAINDER(A, B) (((A) + (B) * 1024) % (B)) /** -- cgit v1.2.3 From 3e48dd04456aaf2d42dfa7f3a3c99a95a5986eb6 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Jun 2009 09:34:35 -0600 Subject: mesa: fix incorrect viewport clamping in _mesa_set_viewport() A 0 by 0 viewport size is legal. Don't clamp against lower bound of one. The error checking earlier in the function prevents negative values. --- src/mesa/main/viewport.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/mesa/main/viewport.c b/src/mesa/main/viewport.c index ead856d32c3..50e0402d278 100644 --- a/src/mesa/main/viewport.c +++ b/src/mesa/main/viewport.c @@ -73,8 +73,8 @@ _mesa_set_viewport(GLcontext *ctx, GLint x, GLint y, } /* clamp width and height to the implementation dependent range */ - width = CLAMP(width, 1, (GLsizei) ctx->Const.MaxViewportWidth); - height = CLAMP(height, 1, (GLsizei) ctx->Const.MaxViewportHeight); + width = MIN2(width, (GLsizei) ctx->Const.MaxViewportWidth); + height = MIN2(height, (GLsizei) ctx->Const.MaxViewportHeight); ctx->Viewport.X = x; ctx->Viewport.Width = width; -- cgit v1.2.3 From 742ba084068b6856e94283a9c5fe3b39d48f64cb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Jun 2009 15:41:49 -0600 Subject: softpipe: fix out of bounds quad rasterization bug For some triangles we can generate quads which lie just outside the surface bounds. Just check the quad's mask before trying to emit/process the quad. Fixes failed assertion in Lightsmark. --- src/gallium/drivers/softpipe/sp_setup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src') diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index accc692b66f..e5be65242d6 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -444,7 +444,8 @@ static void flush_spans( struct setup_context *setup ) mask |= MASK_TOP_RIGHT; if (x+1 >= xleft1 && x+1 < xright1) mask |= MASK_BOTTOM_RIGHT; - EMIT_QUAD( setup, x, setup->span.y, mask ); + if (mask) + EMIT_QUAD( setup, x, setup->span.y, mask ); } break; @@ -458,7 +459,8 @@ static void flush_spans( struct setup_context *setup ) mask |= MASK_TOP_LEFT; if (x+1 >= xleft0 && x+1 < xright0) mask |= MASK_TOP_RIGHT; - EMIT_QUAD( setup, x, setup->span.y, mask ); + if (mask) + EMIT_QUAD( setup, x, setup->span.y, mask ); } break; @@ -472,7 +474,8 @@ static void flush_spans( struct setup_context *setup ) mask |= MASK_BOTTOM_LEFT; if (x+1 >= xleft1 && x+1 < xright1) mask |= MASK_BOTTOM_RIGHT; - EMIT_QUAD( setup, x, setup->span.y, mask ); + if (mask) + EMIT_QUAD( setup, x, setup->span.y, mask ); } break; -- cgit v1.2.3 From 6b917d0b1787280f976c2f0d1ead0e5d7587a3e9 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Jun 2009 18:19:45 -0600 Subject: i965: fix bugs in projective texture coordinates For the TXP instruction we check if the texcoord is really a 4-component atttibute which requires the divide by W step. This check involved the projtex_mask field. However, the projtex_mask field was being miscalculated because of some confusion between vertex program outputs and fragment program inputs. 1. Rework the size_masks calculation so we correctly set bits corresponding to fragment program input attributes. 2. Rename projtex_mask to proj_attrib_mask since we're interested in more than just texcoords (generic varying vars too). 3. Simply the indexing of the size_masks and proj_attrib_mask fields. 4. The tracker::active[] array was mis-dimensioned. Use MAX_PROGRAM_TEMPS instead of a magic number. 5. Update comments, add new assertions. With these changes the Lightsmark demo/benchmark renders correctly, until we eventually hit a GPU lockup... --- src/mesa/drivers/dri/i965/brw_context.h | 5 ++-- src/mesa/drivers/dri/i965/brw_vs_constval.c | 44 +++++++++++++++++++++-------- src/mesa/drivers/dri/i965/brw_wm.c | 2 +- src/mesa/drivers/dri/i965/brw_wm.h | 2 +- src/mesa/drivers/dri/i965/brw_wm_fp.c | 21 ++++++++++---- 5 files changed, 54 insertions(+), 20 deletions(-) (limited to 'src') diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h index aef2ff5f86f..577497bf6b0 100644 --- a/src/mesa/drivers/dri/i965/brw_context.h +++ b/src/mesa/drivers/dri/i965/brw_context.h @@ -616,9 +616,10 @@ struct brw_context struct brw_wm_prog_data *prog_data; struct brw_wm_compile *compile_data; - /* Input sizes, calculated from active vertex program: + /** Input sizes, calculated from active vertex program. + * One bit per fragment program input attribute. */ - GLuint input_size_masks[4]; + GLbitfield input_size_masks[4]; /** Array of surface default colors (texture border color) */ dri_bo *sdc_bo[BRW_MAX_TEX_UNIT]; diff --git a/src/mesa/drivers/dri/i965/brw_vs_constval.c b/src/mesa/drivers/dri/i965/brw_vs_constval.c index 2637344b482..249a800bf4b 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_constval.c +++ b/src/mesa/drivers/dri/i965/brw_vs_constval.c @@ -39,8 +39,8 @@ */ struct tracker { GLboolean twoside; - GLubyte active[PROGRAM_OUTPUT+1][128]; - GLuint size_masks[4]; + GLubyte active[PROGRAM_OUTPUT+1][MAX_PROGRAM_TEMPS]; + GLbitfield size_masks[4]; /**< one bit per fragment program input attrib */ }; @@ -53,8 +53,10 @@ static void set_active_component( struct tracker *t, case PROGRAM_TEMPORARY: case PROGRAM_INPUT: case PROGRAM_OUTPUT: + assert(file < PROGRAM_OUTPUT + 1); + assert(index < Elements(t->active[0])); t->active[file][index] |= active; - + break; default: break; } @@ -108,10 +110,15 @@ static GLubyte get_active( struct tracker *t, return active; } +/** + * Return the size (1,2,3 or 4) of the output/result for VERT_RESULT_idx. + */ static GLubyte get_output_size( struct tracker *t, GLuint idx ) { - GLubyte active = t->active[PROGRAM_OUTPUT][idx]; + GLubyte active; + assert(idx < VERT_RESULT_MAX); + active = t->active[PROGRAM_OUTPUT][idx]; if (active & (1<<3)) return 4; if (active & (1<<2)) return 3; if (active & (1<<1)) return 2; @@ -123,7 +130,7 @@ static GLubyte get_output_size( struct tracker *t, */ static void calc_sizes( struct tracker *t ) { - GLuint i; + GLint vertRes; if (t->twoside) { t->active[PROGRAM_OUTPUT][VERT_RESULT_COL0] |= @@ -133,12 +140,27 @@ static void calc_sizes( struct tracker *t ) t->active[PROGRAM_OUTPUT][VERT_RESULT_BFC1]; } - for (i = 0; i < FRAG_ATTRIB_MAX; i++) { - switch (get_output_size(t, i)) { - case 4: t->size_masks[4-1] |= 1<size_masks[3-1] |= 1<size_masks[2-1] |= 1<size_masks[1-1] |= 1<= VERT_RESULT_VAR0) + fragAttrib = FRAG_ATTRIB_VAR0 + vertRes - VERT_RESULT_VAR0; + else + continue; + assert(fragAttrib >= FRAG_ATTRIB_TEX0); + assert(fragAttrib <= FRAG_ATTRIB_MAX); + + switch (get_output_size(t, vertRes)) { + case 4: t->size_masks[4-1] |= 1 << fragAttrib; + case 3: t->size_masks[3-1] |= 1 << fragAttrib; + case 2: t->size_masks[2-1] |= 1 << fragAttrib; + case 1: t->size_masks[1-1] |= 1 << fragAttrib; break; } } diff --git a/src/mesa/drivers/dri/i965/brw_wm.c b/src/mesa/drivers/dri/i965/brw_wm.c index 90d74c2885c..c0b07da63b1 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.c +++ b/src/mesa/drivers/dri/i965/brw_wm.c @@ -260,7 +260,7 @@ static void brw_wm_populate_key( struct brw_context *brw, /* BRW_NEW_WM_INPUT_DIMENSIONS */ - key->projtex_mask = brw->wm.input_size_masks[4-1] >> (FRAG_ATTRIB_TEX0 - FRAG_ATTRIB_WPOS); + key->proj_attrib_mask = brw->wm.input_size_masks[4-1]; /* _NEW_LIGHT */ key->flat_shade = (ctx->Light.ShadeModel == GL_FLAT); diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index f0d31fc1ddc..0408034c38a 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -65,7 +65,7 @@ struct brw_wm_prog_key { GLuint flat_shade:1; GLuint runtime_check_aads_emit:1; - GLuint projtex_mask:16; + GLbitfield proj_attrib_mask; /**< one bit per fragment program attribute */ GLuint shadowtex_mask:16; GLuint yuvtex_mask:16; GLuint yuvtex_swap_mask:16; /* UV swaped */ diff --git a/src/mesa/drivers/dri/i965/brw_wm_fp.c b/src/mesa/drivers/dri/i965/brw_wm_fp.c index 1798d842c79..49aad281d7a 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_fp.c +++ b/src/mesa/drivers/dri/i965/brw_wm_fp.c @@ -834,10 +834,16 @@ static void precalc_tex( struct brw_wm_compile *c, } +/** + * Check if the given TXP instruction really needs the divide-by-W step. + */ static GLboolean projtex( struct brw_wm_compile *c, const struct prog_instruction *inst ) { - struct prog_src_register src = inst->SrcReg[0]; + const struct prog_src_register src = inst->SrcReg[0]; + GLboolean retVal; + + assert(inst->Opcode == OPCODE_TXP); /* Only try to detect the simplest cases. Could detect (later) * cases where we are trying to emit code like RCP {1.0}, MUL x, @@ -847,16 +853,21 @@ static GLboolean projtex( struct brw_wm_compile *c, * user-provided fragment programs anyway: */ if (inst->TexSrcTarget == TEXTURE_CUBE_INDEX) - return 0; /* ut2004 gun rendering !?! */ + retVal = GL_FALSE; /* ut2004 gun rendering !?! */ else if (src.File == PROGRAM_INPUT && GET_SWZ(src.Swizzle, W) == W && - (c->key.projtex_mask & (1<<(src.Index + FRAG_ATTRIB_WPOS - FRAG_ATTRIB_TEX0))) == 0) - return 0; + (c->key.proj_attrib_mask & (1 << src.Index)) == 0) + retVal = GL_FALSE; else - return 1; + retVal = GL_TRUE; + + return retVal; } +/** + * Emit code for TXP. + */ static void precalc_txp( struct brw_wm_compile *c, const struct prog_instruction *inst ) { -- cgit v1.2.3