From 63af29bfbe265318bcf5be69e420de361b900321 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Fri, 12 Mar 2010 18:32:10 +0000 Subject: mesa: Fix memory leak in decompress-with-blit. (cherry picked from commit f05a4ee6f2840590c90da4be2fe5c6295410a5af) --- src/mesa/state_tracker/st_cb_texture.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mesa/state_tracker/st_cb_texture.c b/src/mesa/state_tracker/st_cb_texture.c index c849132e74..92eefca2e7 100644 --- a/src/mesa/state_tracker/st_cb_texture.c +++ b/src/mesa/state_tracker/st_cb_texture.c @@ -880,6 +880,8 @@ decompress_with_blit(GLcontext * ctx, GLenum target, GLint level, _mesa_unmap_pbo_dest(ctx, &ctx->Pack); + screen->tex_transfer_destroy(tex_xfer); + /* destroy the temp / dest surface */ util_destroy_rgba_surface(dst_texture, dst_surface); } -- cgit v1.2.3 From 346298c7658f2ec8b105e5e53101637af232724f Mon Sep 17 00:00:00 2001 From: Marcin BaczyƄski Date: Sat, 13 Mar 2010 14:26:45 +0100 Subject: Replace _mesa_strtod with _mesa_strtof. Reviewed-by: Ian Romanick --- src/mesa/main/imports.c | 12 +++++++----- src/mesa/main/imports.h | 4 ++-- src/mesa/shader/lex.yy.c | 8 ++++---- src/mesa/shader/nvfragparse.c | 2 +- src/mesa/shader/program_lexer.l | 8 ++++---- src/mesa/shader/slang/slang_compile.c | 4 ++-- 6 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/mesa/main/imports.c b/src/mesa/main/imports.c index 56e8195810..1ae0853364 100644 --- a/src/mesa/main/imports.c +++ b/src/mesa/main/imports.c @@ -795,18 +795,20 @@ _mesa_strdup( const char *s ) } } -/** Wrapper around strtod() */ -double -_mesa_strtod( const char *s, char **end ) +/** Wrapper around strtof() */ +float +_mesa_strtof( const char *s, char **end ) { #ifdef _GNU_SOURCE static locale_t loc = NULL; if (!loc) { loc = newlocale(LC_CTYPE_MASK, "C", NULL); } - return strtod_l(s, end, loc); + return strtof_l(s, end, loc); +#elif defined(_ISOC99_SOURCE) || (defined(_XOPEN_SOURCE) && _XOPEN_SOURCE >= 600) + return strtof(s, end); #else - return strtod(s, end); + return (float)strtod(s, end); #endif } diff --git a/src/mesa/main/imports.h b/src/mesa/main/imports.h index fb4a00eca7..d28f4ad125 100644 --- a/src/mesa/main/imports.h +++ b/src/mesa/main/imports.h @@ -575,8 +575,8 @@ _mesa_getenv( const char *var ); extern char * _mesa_strdup( const char *s ); -extern double -_mesa_strtod( const char *s, char **end ); +extern float +_mesa_strtof( const char *s, char **end ); extern unsigned int _mesa_str_checksum(const char *str); diff --git a/src/mesa/shader/lex.yy.c b/src/mesa/shader/lex.yy.c index a08617ff8d..4c5c644a6e 100644 --- a/src/mesa/shader/lex.yy.c +++ b/src/mesa/shader/lex.yy.c @@ -2198,7 +2198,7 @@ case 142: YY_RULE_SETUP #line 326 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK @@ -2210,7 +2210,7 @@ YY_DO_BEFORE_ACTION; /* set up yytext again */ YY_RULE_SETUP #line 330 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK @@ -2218,7 +2218,7 @@ case 144: YY_RULE_SETUP #line 334 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK @@ -2226,7 +2226,7 @@ case 145: YY_RULE_SETUP #line 338 "program_lexer.l" { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } YY_BREAK diff --git a/src/mesa/shader/nvfragparse.c b/src/mesa/shader/nvfragparse.c index d03cb4e493..0de3c5804d 100644 --- a/src/mesa/shader/nvfragparse.c +++ b/src/mesa/shader/nvfragparse.c @@ -456,7 +456,7 @@ Parse_ScalarConstant(struct parse_state *parseState, GLfloat *number) { char *end = NULL; - *number = (GLfloat) _mesa_strtod((const char *) parseState->pos, &end); + *number = (GLfloat) _mesa_strtof((const char *) parseState->pos, &end); if (end && end > (char *) parseState->pos) { /* got a number */ diff --git a/src/mesa/shader/program_lexer.l b/src/mesa/shader/program_lexer.l index b00765793d..fe18272cdb 100644 --- a/src/mesa/shader/program_lexer.l +++ b/src/mesa/shader/program_lexer.l @@ -324,19 +324,19 @@ ARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require return INTEGER; } {num}?{frac}{exp}? { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } {num}"."/[^.] { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } {num}{exp} { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } {num}"."{exp} { - yylval->real = (float) _mesa_strtod(yytext, NULL); + yylval->real = _mesa_strtof(yytext, NULL); return REAL; } diff --git a/src/mesa/shader/slang/slang_compile.c b/src/mesa/shader/slang/slang_compile.c index b95c15fea6..ad86676157 100644 --- a/src/mesa/shader/slang/slang_compile.c +++ b/src/mesa/shader/slang/slang_compile.c @@ -246,7 +246,7 @@ parse_general_number(slang_parse_ctx *ctx, float *number) if (flt[strlen(flt) - 1] == 'f' || flt[strlen(flt) - 1] == 'F') { flt[strlen(flt) - 1] = '\0'; } - *number = (float)_mesa_strtod(flt, (char **)NULL); + *number = _mesa_strtof(flt, (char **)NULL); free(flt); return 1; @@ -312,7 +312,7 @@ parse_float(slang_parse_ctx * C, float *number) slang_string_concat(whole, "E"); slang_string_concat(whole, exponent); - *number = (float) (_mesa_strtod(whole, (char **) NULL)); + *number = _mesa_strtof(whole, (char **) NULL); _slang_free(whole); } -- cgit v1.2.3 From e9c2c4a76466fc1ccfbf4d5de048414f7126b940 Mon Sep 17 00:00:00 2001 From: Pauli Nieminen Date: Mon, 15 Mar 2010 10:30:18 +0200 Subject: radeon: Fix buffer object unmap to be called only once for dma buffers. If flush happens inside radeonRefillCurrentMaRegion the last dma buffer would be unmapped twice. Unmapping buffer when moving buffer to wait list fixes the mapping error. --- src/mesa/drivers/dri/radeon/radeon_dma.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/radeon/radeon_dma.c b/src/mesa/drivers/dri/radeon/radeon_dma.c index 22499bc38d..6b7690cf8b 100644 --- a/src/mesa/drivers/dri/radeon/radeon_dma.c +++ b/src/mesa/drivers/dri/radeon/radeon_dma.c @@ -184,9 +184,6 @@ void radeonRefillCurrentDmaRegion(radeonContextPtr rmesa, int size) radeon_print(RADEON_DMA, RADEON_NORMAL, "%s size %d minimum_size %d\n", __FUNCTION__, size, rmesa->dma.minimum_size); - if (!is_empty_list(&rmesa->dma.reserved)) - radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo); - if (is_empty_list(&rmesa->dma.free) || last_elem(&rmesa->dma.free)->bo->size < size) { dma_bo = CALLOC_STRUCT(radeon_dma_bo); @@ -336,9 +333,6 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa) legacy_track_pending(rmesa->radeonScreen->bom, 0); } - if (!is_empty_list(&rmesa->dma.reserved)) - radeon_bo_unmap(first_elem(&rmesa->dma.reserved)->bo); - /* move waiting bos to free list. wait list provides gpu time to handle data before reuse */ foreach_s(dma_bo, temp, &rmesa->dma.wait) { @@ -368,6 +362,7 @@ void radeonReleaseDmaRegions(radeonContextPtr rmesa) /* move reserved to wait list */ foreach_s(dma_bo, temp, &rmesa->dma.reserved) { + radeon_bo_unmap(dma_bo->bo); /* free objects that are too small to be used because of large request */ if (dma_bo->bo->size < rmesa->dma.minimum_size) { radeon_bo_unref(dma_bo->bo); -- cgit v1.2.3 From d320152b4786e72f0fe76ec5e8cf58b0eea91b13 Mon Sep 17 00:00:00 2001 From: "Matthew W. S. Bell" Date: Mon, 15 Mar 2010 01:18:02 +0000 Subject: Correct GL_EQUIV code in r67/7xx. From 247e121106e8d3e389f2e5a6edf13ea70ac18df7 Mon Sep 17 00:00:00 2001 These seem to be documented in . --- src/mesa/drivers/dri/r600/r700_state.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/drivers/dri/r600/r700_state.c b/src/mesa/drivers/dri/r600/r700_state.c index 6f156b5409..12eaebbc16 100644 --- a/src/mesa/drivers/dri/r600/r700_state.c +++ b/src/mesa/drivers/dri/r600/r700_state.c @@ -614,7 +614,7 @@ static GLuint translate_logicop(GLenum logicop) case GL_XOR: return 0x66; case GL_EQUIV: - return 0xaa; + return 0x99; case GL_AND_REVERSE: return 0x44; case GL_AND_INVERTED: -- cgit v1.2.3 From f0c32629276a0bf33eed5ba519e3536061e239ad Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 16 Mar 2010 07:38:51 -0700 Subject: mesa: set version string to 7.8-rc1 --- Makefile | 2 +- src/mesa/main/version.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index c4ee9e583c..37683e0f0d 100644 --- a/Makefile +++ b/Makefile @@ -180,7 +180,7 @@ ultrix-gcc: # Rules for making release tarballs -VERSION=7.8-devel +VERSION=7.8-rc1 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 d521569f8d..7ed1e1a32a 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-devel" +#define MESA_VERSION_STRING "7.8-rc1" /* To make version comparison easy */ #define MESA_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + (c)) -- cgit v1.2.3 From c1c9fad293eed751668fe2b34ff611af8d268131 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 16 Mar 2010 07:48:14 -0700 Subject: Remove nonexistant files from tarballs rule of Makefile The Makefile should eventually be fixed to stop building tarballs if one of the individual calls to tar fails. --- Makefile | 16 +--------------- 1 file changed, 1 insertion(+), 15 deletions(-) diff --git a/Makefile b/Makefile index 37683e0f0d..68b5adffbe 100644 --- a/Makefile +++ b/Makefile @@ -244,7 +244,6 @@ MAIN_FILES = \ $(DIRECTORY)/src/mesa/shader/descrip.mms \ $(DIRECTORY)/src/mesa/shader/slang/*.[ch] \ $(DIRECTORY)/src/mesa/shader/slang/descrip.mms \ - $(DIRECTORY)/src/mesa/shader/slang/library/*.[ch] \ $(DIRECTORY)/src/mesa/shader/slang/library/*.gc \ $(DIRECTORY)/src/mesa/shader/slang/library/Makefile \ $(DIRECTORY)/src/mesa/swrast/*.[ch] \ @@ -380,15 +379,6 @@ SGI_GLU_FILES = \ $(DIRECTORY)/src/glu/sgi/libtess/*.[ch] \ $(DIRECTORY)/src/glu/sgi/libutil/*.[ch] -MESA_GLU_FILES = \ - $(DIRECTORY)/src/glu/mesa/README[12] \ - $(DIRECTORY)/src/glu/mesa/Makefile* \ - $(DIRECTORY)/src/glu/mesa/descrip.mms \ - $(DIRECTORY)/src/glu/mesa/mms_depend \ - $(DIRECTORY)/src/glu/mesa/*.def \ - $(DIRECTORY)/src/glu/mesa/depend \ - $(DIRECTORY)/src/glu/mesa/*.[ch] - GLW_FILES = \ $(DIRECTORY)/src/glw/*.[ch] \ $(DIRECTORY)/src/glw/Makefile* \ @@ -451,11 +441,7 @@ GLUT_FILES = \ $(DIRECTORY)/src/glut/glx/*.[ch] \ $(DIRECTORY)/src/glut/beos/*.[ch] \ $(DIRECTORY)/src/glut/beos/*.cpp \ - $(DIRECTORY)/src/glut/beos/Makefile \ - $(DIRECTORY)/src/glut/fbdev/Makefile \ - $(DIRECTORY)/src/glut/fbdev/*[ch] \ - $(DIRECTORY)/src/glut/mini/*[ch] \ - $(DIRECTORY)/src/glut/mini/glut.pc.in \ + $(DIRECTORY)/src/glut/beos/Makefile DEPEND_FILES = \ $(TOP)/src/mesa/depend \ -- cgit v1.2.3 From 7ee4db50b10ab2d8fdfc4781f26b84041cf568d7 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 10 Mar 2010 10:38:20 -0800 Subject: i965: Fix the response len of masked sampler messages for 8-wide dispatch. The bad response length would hang the GPU with a masked sample in a shader using control flow. For 8-wide, the response length is always 4, and masked slots are just not written to. brw_wm_glsl.c already allocates registers in the right locations. Fixes piglit glsl-fs-bug25902 (fd.o bug #25902). (cherry picked from commit f6d210c284751ac50a8d6358de7e75a1ff1e4ac7) (cherry picked from commit dc8c0359448cdae7b367552ba58783c04b199778) --- src/mesa/drivers/dri/i965/brw_eu_emit.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index f69d529613..82f2fdab2f 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -1290,7 +1290,7 @@ void brw_SAMPLE(struct brw_compile *p, GLuint simd_mode) { GLboolean need_stall = 0; - + if (writemask == 0) { /*printf("%s: zero writemask??\n", __FUNCTION__); */ return; @@ -1327,8 +1327,14 @@ void brw_SAMPLE(struct brw_compile *p, /* printf("need stall %x %x\n", newmask , writemask); */ } else { + GLboolean dispatch_16 = GL_FALSE; + struct brw_reg m1 = brw_message_reg(msg_reg_nr); - + + guess_execution_size(p->current, dest); + if (p->current->header.execution_size == BRW_EXECUTE_16) + dispatch_16 = GL_TRUE; + newmask = ~newmask & WRITEMASK_XYZW; brw_push_insn_state(p); @@ -1343,7 +1349,13 @@ void brw_SAMPLE(struct brw_compile *p, src0 = retype(brw_null_reg(), BRW_REGISTER_TYPE_UW); dest = offset(dest, dst_offset); - response_length = len * 2; + + /* For 16-wide dispatch, masked channels are skipped in the + * response. For 8-wide, masked channels still take up slots, + * and are just not written to. + */ + if (dispatch_16) + response_length = len * 2; } } -- cgit v1.2.3 From 837f003eeb1ce56c2d8285e82ee86b5ffbb19442 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Wed, 10 Mar 2010 11:00:40 -0800 Subject: i965: Add support for the CMP opcode in the GLSL path. This would be triggered by use of sqrt() along with control flow. Fixes piglit-fs-sqrt-branch and a bug in Yo Frankie!. (cherry picked from commit 48dca99feb394febc3af44e14f23fb12a9cc9204) --- src/mesa/drivers/dri/i965/brw_wm.h | 6 ++++++ src/mesa/drivers/dri/i965/brw_wm_emit.c | 12 ++++++------ src/mesa/drivers/dri/i965/brw_wm_glsl.c | 3 +++ 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm.h b/src/mesa/drivers/dri/i965/brw_wm.h index 88d84ee82f..47b764d24d 100644 --- a/src/mesa/drivers/dri/i965/brw_wm.h +++ b/src/mesa/drivers/dri/i965/brw_wm.h @@ -328,6 +328,12 @@ void emit_cinterp(struct brw_compile *p, const struct brw_reg *dst, GLuint mask, const struct brw_reg *arg0); +void emit_cmp(struct brw_compile *p, + const struct brw_reg *dst, + GLuint mask, + const struct brw_reg *arg0, + const struct brw_reg *arg1, + const struct brw_reg *arg2); void emit_ddxy(struct brw_compile *p, const struct brw_reg *dst, GLuint mask, diff --git a/src/mesa/drivers/dri/i965/brw_wm_emit.c b/src/mesa/drivers/dri/i965/brw_wm_emit.c index 9315bca315..c7d87b9d94 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_emit.c +++ b/src/mesa/drivers/dri/i965/brw_wm_emit.c @@ -566,12 +566,12 @@ static void emit_sne( struct brw_compile *p, emit_sop(p, dst, mask, BRW_CONDITIONAL_NEQ, arg0, arg1); } -static void emit_cmp( struct brw_compile *p, - const struct brw_reg *dst, - GLuint mask, - const struct brw_reg *arg0, - const struct brw_reg *arg1, - const struct brw_reg *arg2 ) +void emit_cmp(struct brw_compile *p, + const struct brw_reg *dst, + GLuint mask, + const struct brw_reg *arg0, + const struct brw_reg *arg1, + const struct brw_reg *arg2) { GLuint i; diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index 562608e2ec..a42e6bf7a5 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -1960,6 +1960,9 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) case OPCODE_LG2: emit_math1(c, BRW_MATH_FUNCTION_LOG, dst, dst_flags, args[0]); break; + case OPCODE_CMP: + emit_cmp(p, dst, dst_flags, args[0], args[1], args[2]); + break; case OPCODE_MIN: unalias2(c, emit_min, dst, dst_flags, args[0], args[1]); break; -- cgit v1.2.3 From 1254d3d315497636a2445533372dd3d1fa6f96dc Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 8 Mar 2010 12:12:31 -0800 Subject: i965: Fix up the handling of point sprite coordinate replacement. The code was walking over the regs of pairs of attributes and checking whether the attribute with a given reg index had point sprite enabled. So the point sprite setup code was rarely even getting executed. Instead, we need to determine which channels of a reg need point sprite coordinate replacement. In addition, it was multiplying the attribute by 1/w, when it's supposed to cover (0, 1) in each direction regardless of w, and it wasn't filling in the Z and W components of the texcoord as specified. Fixes piglit point-sprite and the spriteblast demo. Bug #24431, #22245. (cherry picked from commit bc632d04370566c1156cbd0345fe303834f0b910) --- src/mesa/drivers/dri/i965/brw_sf.c | 21 ++--- src/mesa/drivers/dri/i965/brw_sf.h | 6 +- src/mesa/drivers/dri/i965/brw_sf_emit.c | 135 ++++++++++++++++++++------------ 3 files changed, 96 insertions(+), 66 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_sf.c b/src/mesa/drivers/dri/i965/brw_sf.c index 8e6839b812..57d1c29ade 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.c +++ b/src/mesa/drivers/dri/i965/brw_sf.c @@ -46,7 +46,6 @@ static void compile_sf_prog( struct brw_context *brw, struct brw_sf_prog_key *key ) { - GLcontext *ctx = &brw->intel.ctx; struct brw_sf_compile c; const GLuint *program; GLuint program_size; @@ -69,20 +68,14 @@ static void compile_sf_prog( struct brw_context *brw, /* Construct map from attribute number to position in the vertex. */ - for (i = idx = 0; i < VERT_RESULT_MAX; i++) + for (i = idx = 0; i < VERT_RESULT_MAX; i++) { if (c.key.attrs & BITFIELD64_BIT(i)) { c.attr_to_idx[i] = idx; c.idx_to_attr[idx] = i; - if (i >= VERT_RESULT_TEX0 && i <= VERT_RESULT_TEX7) { - c.point_attrs[i].CoordReplace = - ctx->Point.CoordReplace[i - VERT_RESULT_TEX0]; - } - else { - c.point_attrs[i].CoordReplace = GL_FALSE; - } idx++; } - + } + /* Which primitive? Or all three? */ switch (key->primitive) { @@ -162,6 +155,14 @@ static void upload_sf_prog(struct brw_context *brw) } key.do_point_sprite = ctx->Point.PointSprite; + if (key.do_point_sprite) { + int i; + + for (i = 0; i < 8; i++) { + if (ctx->Point.CoordReplace[i]) + key.point_sprite_coord_replace |= (1 << i); + } + } key.sprite_origin_lower_left = (ctx->Point.SpriteOrigin == GL_LOWER_LEFT); /* _NEW_LIGHT */ key.do_flat_shading = (ctx->Light.ShadeModel == GL_FLAT); diff --git a/src/mesa/drivers/dri/i965/brw_sf.h b/src/mesa/drivers/dri/i965/brw_sf.h index 0ba731fac9..a0680a56f2 100644 --- a/src/mesa/drivers/dri/i965/brw_sf.h +++ b/src/mesa/drivers/dri/i965/brw_sf.h @@ -46,6 +46,7 @@ struct brw_sf_prog_key { GLbitfield64 attrs; + uint8_t point_sprite_coord_replace; GLuint primitive:2; GLuint do_twoside_color:1; GLuint do_flat_shading:1; @@ -56,10 +57,6 @@ struct brw_sf_prog_key { GLuint pad:24; }; -struct brw_sf_point_tex { - GLboolean CoordReplace; -}; - struct brw_sf_compile { struct brw_compile func; struct brw_sf_prog_key key; @@ -100,7 +97,6 @@ struct brw_sf_compile { GLubyte attr_to_idx[VERT_RESULT_MAX]; GLubyte idx_to_attr[VERT_RESULT_MAX]; - struct brw_sf_point_tex point_attrs[VERT_RESULT_MAX]; }; diff --git a/src/mesa/drivers/dri/i965/brw_sf_emit.c b/src/mesa/drivers/dri/i965/brw_sf_emit.c index bb08055e3b..56f7c986e7 100644 --- a/src/mesa/drivers/dri/i965/brw_sf_emit.c +++ b/src/mesa/drivers/dri/i965/brw_sf_emit.c @@ -354,6 +354,33 @@ static GLboolean calculate_masks( struct brw_sf_compile *c, return is_last_attr; } +/* Calculates the predicate control for which channels of a reg + * (containing 2 attrs) to do point sprite coordinate replacement on. + */ +static uint16_t +calculate_point_sprite_mask(struct brw_sf_compile *c, GLuint reg) +{ + int attr1, attr2; + uint16_t pc = 0; + + attr1 = c->idx_to_attr[reg * 2]; + if (attr1 >= VERT_RESULT_TEX0 && attr1 <= VERT_RESULT_TEX7) { + if (c->key.point_sprite_coord_replace & (1 << (attr1 - VERT_RESULT_TEX0))) + pc |= 0x0f; + } + + if (reg * 2 + 1 < c->nr_setup_attrs) { + attr2 = c->idx_to_attr[reg * 2 + 1]; + if (attr2 >= VERT_RESULT_TEX0 && attr2 <= VERT_RESULT_TEX7) { + if (c->key.point_sprite_coord_replace & (1 << (attr2 - + VERT_RESULT_TEX0))) + pc |= 0xf0; + } + } + + return pc; +} + void brw_emit_tri_setup( struct brw_sf_compile *c, GLboolean allocate) @@ -529,22 +556,27 @@ void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate) copy_z_inv_w(c); for (i = 0; i < c->nr_setup_regs; i++) { - struct brw_sf_point_tex *tex = &c->point_attrs[c->idx_to_attr[2*i]]; struct brw_reg a0 = offset(c->vert[0], i); - GLushort pc, pc_persp, pc_linear; + GLushort pc, pc_persp, pc_linear, pc_coord_replace; GLboolean last = calculate_masks(c, i, &pc, &pc_persp, &pc_linear); - - if (pc_persp) - { - if (!tex->CoordReplace) { - brw_set_predicate_control_flag_value(p, pc_persp); - brw_MUL(p, a0, a0, c->inv_w[0]); - } + + pc_coord_replace = calculate_point_sprite_mask(c, i); + pc_persp &= ~pc_coord_replace; + + if (pc_persp) { + brw_set_predicate_control_flag_value(p, pc_persp); + brw_MUL(p, a0, a0, c->inv_w[0]); } - if (tex->CoordReplace) { - /* Caculate 1.0/PointWidth */ - brw_math(&c->func, + /* Point sprite coordinate replacement: A texcoord with this + * enabled gets replaced with the value (x, y, 0, 1) where x and + * y vary from 0 to 1 across the horizontal and vertical of the + * point. + */ + if (pc_coord_replace) { + brw_set_predicate_control_flag_value(p, pc_coord_replace); + /* Caculate 1.0/PointWidth */ + brw_math(&c->func, c->tmp, BRW_MATH_FUNCTION_INV, BRW_MATH_SATURATE_NONE, @@ -553,50 +585,51 @@ void brw_emit_point_sprite_setup( struct brw_sf_compile *c, GLboolean allocate) BRW_MATH_DATA_SCALAR, BRW_MATH_PRECISION_FULL); - if (c->key.sprite_origin_lower_left) { - brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]); - brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0)); - brw_MUL(p, c->m2Cy, c->tmp, negate(c->inv_w[0])); - brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0)); - } else { - brw_MUL(p, c->m1Cx, c->tmp, c->inv_w[0]); - brw_MOV(p, vec1(suboffset(c->m1Cx, 1)), brw_imm_f(0.0)); - brw_MUL(p, c->m2Cy, c->tmp, c->inv_w[0]); - brw_MOV(p, vec1(suboffset(c->m2Cy, 0)), brw_imm_f(0.0)); - } - } else { - brw_MOV(p, c->m1Cx, brw_imm_ud(0)); - brw_MOV(p, c->m2Cy, brw_imm_ud(0)); - } + brw_set_access_mode(p, BRW_ALIGN_16); - { - brw_set_predicate_control_flag_value(p, pc); - if (tex->CoordReplace) { - if (c->key.sprite_origin_lower_left) { - brw_MUL(p, c->m3C0, c->inv_w[0], brw_imm_f(1.0)); - brw_MOV(p, vec1(suboffset(c->m3C0, 0)), brw_imm_f(0.0)); - } - else - brw_MOV(p, c->m3C0, brw_imm_f(0.0)); + /* dA/dx, dA/dy */ + brw_MOV(p, c->m1Cx, brw_imm_f(0.0)); + brw_MOV(p, c->m2Cy, brw_imm_f(0.0)); + brw_MOV(p, brw_writemask(c->m1Cx, WRITEMASK_X), c->tmp); + if (c->key.sprite_origin_lower_left) { + brw_MOV(p, brw_writemask(c->m2Cy, WRITEMASK_Y), negate(c->tmp)); } else { - brw_MOV(p, c->m3C0, a0); /* constant value */ + brw_MOV(p, brw_writemask(c->m2Cy, WRITEMASK_Y), c->tmp); } - /* Copy m0..m3 to URB. - */ - brw_urb_WRITE(p, - brw_null_reg(), - 0, - brw_vec8_grf(0, 0), - 0, /* allocate */ - 1, /* used */ - 4, /* msg len */ - 0, /* response len */ - last, /* eot */ - last, /* writes complete */ - i*4, /* urb destination offset */ - BRW_URB_SWIZZLE_TRANSPOSE); + /* attribute constant offset */ + brw_MOV(p, c->m3C0, brw_imm_f(0.0)); + if (c->key.sprite_origin_lower_left) { + brw_MOV(p, brw_writemask(c->m3C0, WRITEMASK_YW), brw_imm_f(1.0)); + } else { + brw_MOV(p, brw_writemask(c->m3C0, WRITEMASK_W), brw_imm_f(1.0)); + } + + brw_set_access_mode(p, BRW_ALIGN_1); } + + if (pc & ~pc_coord_replace) { + brw_set_predicate_control_flag_value(p, pc & ~pc_coord_replace); + brw_MOV(p, c->m1Cx, brw_imm_ud(0)); + brw_MOV(p, c->m2Cy, brw_imm_ud(0)); + brw_MOV(p, c->m3C0, a0); /* constant value */ + } + + + brw_set_predicate_control_flag_value(p, pc); + /* Copy m0..m3 to URB. */ + brw_urb_WRITE(p, + brw_null_reg(), + 0, + brw_vec8_grf(0, 0), + 0, /* allocate */ + 1, /* used */ + 4, /* msg len */ + 0, /* response len */ + last, /* eot */ + last, /* writes complete */ + i*4, /* urb destination offset */ + BRW_URB_SWIZZLE_TRANSPOSE); } } -- cgit v1.2.3 From 009392f50db7ae0f6ef1fcbff268d5b833852074 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 8 Mar 2010 16:08:33 -0800 Subject: i965: Fix up VP constbuf leak on program delete. (cherry picked from commit 7f6d2754d586545ab6c970acffdd897294879039) --- src/mesa/drivers/dri/i965/brw_program.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_program.c b/src/mesa/drivers/dri/i965/brw_program.c index c78f7b38ae..1fd957b3ad 100644 --- a/src/mesa/drivers/dri/i965/brw_program.c +++ b/src/mesa/drivers/dri/i965/brw_program.c @@ -95,9 +95,17 @@ static void brwDeleteProgram( GLcontext *ctx, struct gl_program *prog ) { if (prog->Target == GL_FRAGMENT_PROGRAM_ARB) { - struct gl_fragment_program *fprog = (struct gl_fragment_program *) prog; - struct brw_fragment_program *brw_fprog = brw_fragment_program(fprog); - dri_bo_unreference(brw_fprog->const_buffer); + struct gl_fragment_program *fp = (struct gl_fragment_program *) prog; + struct brw_fragment_program *brw_fp = brw_fragment_program(fp); + + dri_bo_unreference(brw_fp->const_buffer); + } + + if (prog->Target == GL_VERTEX_PROGRAM_ARB) { + struct gl_vertex_program *vp = (struct gl_vertex_program *) prog; + struct brw_vertex_program *brw_vp = brw_vertex_program(vp); + + dri_bo_unreference(brw_vp->const_buffer); } _mesa_delete_program( ctx, prog ); -- cgit v1.2.3 From d24f59d0081074ae9c4532949e75147447c8a82a Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 9 Mar 2010 09:56:42 -0800 Subject: i965: Fix nested loops in the VS. We were patching up all the break and continues between the start of our loop and the end of our loop, even if they were breaks/continues for an inner loop. Avoiding patching already patched breaks/continues fixes piglit glsl-vs-loop-nested. (cherry picked from commit f6f547d87ea68f44c50a0b0231b7360ca94b2975) --- src/mesa/drivers/dri/i965/brw_vs_emit.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index a7c4b58972..a48804a660 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1717,11 +1717,13 @@ void brw_vs_emit(struct brw_vs_compile *c ) /* patch all the BREAK/CONT instructions from last BEGINLOOP */ while (inst0 > loop_inst[loop_depth]) { inst0--; - if (inst0->header.opcode == BRW_OPCODE_BREAK) { + if (inst0->header.opcode == BRW_OPCODE_BREAK && + inst0->bits3.if_else.jump_count == 0) { inst0->bits3.if_else.jump_count = br * (inst1 - inst0 + 1); inst0->bits3.if_else.pop_count = 0; } - else if (inst0->header.opcode == BRW_OPCODE_CONTINUE) { + else if (inst0->header.opcode == BRW_OPCODE_CONTINUE && + inst0->bits3.if_else.jump_count == 0) { inst0->bits3.if_else.jump_count = br * (inst1 - inst0); inst0->bits3.if_else.pop_count = 0; } -- cgit v1.2.3 From 42e0e8686688ff91e92fa4ac46c6dacb2d5f2140 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 9 Mar 2010 11:56:14 -0800 Subject: i965: Unalias all GLSL source regs from the destination regs used. We were doing it ad-hoc before, as instructions with potential aliasing problems were identified. But thanks to swizzling basically anything can have aliasing, so just do it generally at source reg setup time. This is somewhat inefficient, because sometimes an operation doesn't need unaliasing protection if the swizzling is safe, but the unaliasing before didn't cover those cases either. Fixes piglit glsl-fs-loop. (cherry picked from commit 6b194dab6b4d9f12cdd54c699b23c0d3420a49c2) --- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 138 ++++++-------------------------- 1 file changed, 25 insertions(+), 113 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index a42e6bf7a5..e3e6f66339 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -614,112 +614,6 @@ static void invoke_subroutine( struct brw_wm_compile *c, } } -/* Workaround for using brw_wm_emit.c's emit functions, which expect - * destination regs to be uniquely written. Moves arguments out to - * temporaries as necessary for instructions which use their destination as - * a temporary. - */ -static void -unalias3(struct brw_wm_compile *c, - void (*func)(struct brw_compile *c, - const struct brw_reg *dst, - GLuint mask, - const struct brw_reg *arg0, - const struct brw_reg *arg1, - const struct brw_reg *arg2), - const struct brw_reg *dst, - GLuint mask, - const struct brw_reg *arg0, - const struct brw_reg *arg1, - const struct brw_reg *arg2) -{ - struct brw_compile *p = &c->func; - struct brw_reg tmp_arg0[4], tmp_arg1[4], tmp_arg2[4]; - int i, j; - int mark = mark_tmps(c); - - for (j = 0; j < 4; j++) { - tmp_arg0[j] = arg0[j]; - tmp_arg1[j] = arg1[j]; - tmp_arg2[j] = arg2[j]; - } - - for (i = 0; i < 4; i++) { - if (mask & (1<func; - struct brw_reg tmp_arg0[4], tmp_arg1[4]; - int i, j; - int mark = mark_tmps(c); - - for (j = 0; j < 4; j++) { - tmp_arg0[j] = arg0[j]; - tmp_arg1[j] = arg1[j]; - } - - for (i = 0; i < 4; i++) { - if (mask & (1<func; + int i, j; for (i = 0; i < 4; i++) { - if (mask & (1 << i)) + if (mask & (1 << i)) { regs[i] = get_src_reg(c, inst, index, i); + + /* Unalias destination registers from our sources. */ + if (regs[i].file == BRW_GENERAL_REGISTER_FILE) { + for (j = 0; j < 4; j++) { + if (memcmp(®s[i], &dst[j], sizeof(regs[0])) == 0) { + struct brw_reg tmp = alloc_tmp(c); + brw_MOV(p, tmp, regs[i]); + regs[i] = tmp; + break; + } + } + } + } } } @@ -1845,6 +1754,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) int dst_flags; struct brw_reg args[3][4], dst[4]; int j; + int mark = mark_tmps( c ); c->cur_inst = i; @@ -1866,7 +1776,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) } } for (j = 0; j < brw_wm_nr_args(inst->Opcode); j++) - get_argument_regs(c, inst, j, args[j], WRITEMASK_XYZW); + get_argument_regs(c, inst, j, dst, args[j], WRITEMASK_XYZW); dst_flags = inst->DstReg.WriteMask; if (inst->SaturateMode == SATURATE_ZERO_ONE) @@ -1920,8 +1830,7 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) emit_alu1(p, brw_RNDD, dst, dst_flags, args[0]); break; case OPCODE_LRP: - unalias3(c, emit_lrp, - dst, dst_flags, args[0], args[1], args[2]); + emit_lrp(p, dst, dst_flags, args[0], args[1], args[2]); break; case OPCODE_TRUNC: emit_alu1(p, brw_RNDZ, dst, dst_flags, args[0]); @@ -1964,10 +1873,10 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) emit_cmp(p, dst, dst_flags, args[0], args[1], args[2]); break; case OPCODE_MIN: - unalias2(c, emit_min, dst, dst_flags, args[0], args[1]); + emit_min(p, dst, dst_flags, args[0], args[1]); break; case OPCODE_MAX: - unalias2(c, emit_max, dst, dst_flags, args[0], args[1]); + emit_max(p, dst, dst_flags, args[0], args[1]); break; case OPCODE_DDX: case OPCODE_DDY: @@ -2122,6 +2031,9 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) inst->Opcode); } + /* Release temporaries containing any unaliased source regs. */ + release_tmps( c, mark ); + if (inst->CondUpdate) brw_set_predicate_control(p, BRW_PREDICATE_NORMAL); else -- cgit v1.2.3 From a29c7948d965ad274ae7ac98fe01f2f877b19d94 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Tue, 9 Mar 2010 14:22:51 -0800 Subject: i965: Fix ENDLOOP to only patch up this loop's BREAK and CONT. Corresponds to d225a25e21a24508aea3b877c78beb35502e942d and fixes piglit glsl-fs-loop-nested. Bug #25173. (cherry picked from commit a81836ee2fe5092d695b717addf8cec91f569777) --- src/mesa/drivers/dri/i965/brw_wm_glsl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c index e3e6f66339..315b030484 100644 --- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c +++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c @@ -2015,11 +2015,13 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c) /* patch all the BREAK/CONT instructions from last BGNLOOP */ while (inst0 > loop_inst[loop_depth]) { inst0--; - if (inst0->header.opcode == BRW_OPCODE_BREAK) { + if (inst0->header.opcode == BRW_OPCODE_BREAK && + inst0->bits3.if_else.jump_count == 0) { inst0->bits3.if_else.jump_count = br * (inst1 - inst0 + 1); inst0->bits3.if_else.pop_count = 0; } - else if (inst0->header.opcode == BRW_OPCODE_CONTINUE) { + else if (inst0->header.opcode == BRW_OPCODE_CONTINUE && + inst0->bits3.if_else.jump_count == 0) { inst0->bits3.if_else.jump_count = br * (inst1 - inst0); inst0->bits3.if_else.pop_count = 0; } -- cgit v1.2.3