From 5cb255f0d7ab048355b454d69e44ab9735c8921e Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Wed, 27 Jan 2010 13:48:21 +0000 Subject: svga: better path for generating white pixels for xor logicop workaround --- src/gallium/drivers/svga/svga_context.c | 1 - src/gallium/drivers/svga/svga_context.h | 4 - src/gallium/drivers/svga/svga_state_fs.c | 126 +++++++------------------ src/gallium/drivers/svga/svga_tgsi.h | 1 + src/gallium/drivers/svga/svga_tgsi_decl_sm30.c | 15 ++- src/gallium/drivers/svga/svga_tgsi_insn.c | 34 +++++-- 6 files changed, 75 insertions(+), 106 deletions(-) diff --git a/src/gallium/drivers/svga/svga_context.c b/src/gallium/drivers/svga/svga_context.c index af99c9de37c..1e76592ec60 100644 --- a/src/gallium/drivers/svga/svga_context.c +++ b/src/gallium/drivers/svga/svga_context.c @@ -215,7 +215,6 @@ struct pipe_context *svga_context_create( struct pipe_screen *screen ) svga->state.hw_draw.num_views = 0; svga->dirty = ~0; - svga->state.white_fs_id = SVGA3D_INVALID_ID; LIST_INITHEAD(&svga->dirty_buffers); diff --git a/src/gallium/drivers/svga/svga_context.h b/src/gallium/drivers/svga/svga_context.h index 32e9304f819..52d47046e74 100644 --- a/src/gallium/drivers/svga/svga_context.h +++ b/src/gallium/drivers/svga/svga_context.h @@ -329,10 +329,6 @@ struct svga_context unsigned texture_timestamp; - /* Internally generated shaders: - */ - unsigned white_fs_id; - /* */ struct svga_sw_state sw; diff --git a/src/gallium/drivers/svga/svga_state_fs.c b/src/gallium/drivers/svga/svga_state_fs.c index 4fe91416778..3b700cd0227 100644 --- a/src/gallium/drivers/svga/svga_state_fs.c +++ b/src/gallium/drivers/svga/svga_state_fs.c @@ -103,70 +103,6 @@ fail: return ret; } -/* The blend workaround for simulating logicop xor behaviour requires - * that the incoming fragment color be white. This change achieves - * that by hooking up a hard-wired fragment shader that just emits - * color 1,1,1,1 - * - * This is a slightly incomplete solution as it assumes that the - * actual bound shader has no other effects beyond generating a - * fragment color. In particular shaders containing TEXKIL and/or - * depth-write will not have the correct behaviour, nor will those - * expecting to use alphatest. - * - * These are avoidable issues, but they are not much worse than the - * unavoidable ones associated with this technique, so it's not clear - * how much effort should be expended trying to resolve them - the - * ultimate result will still not be correct in most cases. - * - * Shader below was generated with: - * SVGA_DEBUG=tgsi ./mesa/progs/fp/fp-tri white.txt - */ -static int emit_white_fs( struct svga_context *svga ) -{ - int ret = PIPE_ERROR; - - /* ps_3_0 - * def c0, 1.000000, 0.000000, 0.000000, 1.000000 - * mov oC0, c0.x - * end - */ - static const unsigned white_tokens[] = { - 0xffff0300, - 0x05000051, - 0xa00f0000, - 0x3f800000, - 0x00000000, - 0x00000000, - 0x3f800000, - 0x02000001, - 0x800f0800, - 0xa0000000, - 0x0000ffff, - }; - - assert(SVGA3D_INVALID_ID == UTIL_BITMASK_INVALID_INDEX); - svga->state.white_fs_id = util_bitmask_add(svga->fs_bm); - if(svga->state.white_fs_id == SVGA3D_INVALID_ID) - goto no_fs_id; - - ret = SVGA3D_DefineShader(svga->swc, - svga->state.white_fs_id, - SVGA3D_SHADERTYPE_PS, - white_tokens, - sizeof(white_tokens)); - if (ret) - goto no_definition; - - return 0; - -no_definition: - util_bitmask_clear(svga->fs_bm, svga->state.white_fs_id); - svga->state.white_fs_id = SVGA3D_INVALID_ID; -no_fs_id: - return ret; -} - /* SVGA_NEW_TEXTURE_BINDING * SVGA_NEW_RAST @@ -194,6 +130,23 @@ static int make_fs_key( const struct svga_context *svga, PIPE_WINDING_CW); } + /* The blend workaround for simulating logicop xor behaviour + * requires that the incoming fragment color be white. This change + * achieves that by creating a varient of the current fragment + * shader that overrides all output colors with 1,1,1,1 + * + * This will work for most shaders, including those containing + * TEXKIL and/or depth-write. However, it will break on the + * combination of xor-logicop plus alphatest. + * + * Ultimately, we could implement alphatest in the shader using + * texkil prior to overriding the outgoing fragment color. + * + * SVGA_NEW_BLEND + */ + if (svga->curr.blend->need_white_fragments) { + key->white_fragments = 1; + } /* XXX: want to limit this to the textures that the shader actually * refers to. @@ -233,40 +186,29 @@ static int emit_hw_fs( struct svga_context *svga, unsigned id = SVGA3D_INVALID_ID; int ret = 0; + struct svga_fragment_shader *fs = svga->curr.fs; + struct svga_fs_compile_key key; + /* SVGA_NEW_BLEND + * SVGA_NEW_TEXTURE_BINDING + * SVGA_NEW_RAST + * SVGA_NEW_NEED_SWTNL + * SVGA_NEW_SAMPLER */ - if (svga->curr.blend->need_white_fragments) { - if (svga->state.white_fs_id == SVGA3D_INVALID_ID) { - ret = emit_white_fs( svga ); - if (ret) - return ret; - } - id = svga->state.white_fs_id; - } - else { - struct svga_fragment_shader *fs = svga->curr.fs; - struct svga_fs_compile_key key; - - /* SVGA_NEW_TEXTURE_BINDING - * SVGA_NEW_RAST - * SVGA_NEW_NEED_SWTNL - * SVGA_NEW_SAMPLER - */ - ret = make_fs_key( svga, &key ); + ret = make_fs_key( svga, &key ); + if (ret) + return ret; + + result = search_fs_key( fs, &key ); + if (!result) { + ret = compile_fs( svga, fs, &key, &result ); if (ret) return ret; - - result = search_fs_key( fs, &key ); - if (!result) { - ret = compile_fs( svga, fs, &key, &result ); - if (ret) - return ret; - } - - assert (result); - id = result->id; } + assert (result); + id = result->id; + assert(id != SVGA3D_INVALID_ID); if (result != svga->state.hw_draw.fs) { diff --git a/src/gallium/drivers/svga/svga_tgsi.h b/src/gallium/drivers/svga/svga_tgsi.h index 896c90a89ae..25f60c78b7c 100644 --- a/src/gallium/drivers/svga/svga_tgsi.h +++ b/src/gallium/drivers/svga/svga_tgsi.h @@ -49,6 +49,7 @@ struct svga_fs_compile_key { boolean light_twoside:1; boolean front_cw:1; + boolean white_fragments:1; ubyte num_textures; ubyte num_unnormalized_coords; struct { diff --git a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c index 2291cf116dd..4c078ba9117 100644 --- a/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c +++ b/src/gallium/drivers/svga/svga_tgsi_decl_sm30.c @@ -194,8 +194,19 @@ static boolean ps30_output( struct svga_shader_emitter *emit, switch (semantic.SemanticName) { case TGSI_SEMANTIC_COLOR: - emit->output_map[idx] = dst_register( SVGA3DREG_COLOROUT, - semantic.SemanticIndex ); + if (emit->unit == PIPE_SHADER_FRAGMENT && + emit->key.fkey.white_fragments) { + + emit->output_map[idx] = dst_register( SVGA3DREG_TEMP, + emit->nr_hw_temp++ ); + emit->temp_col[idx] = emit->output_map[idx]; + emit->true_col[idx] = dst_register( SVGA3DREG_COLOROUT, + semantic.SemanticIndex ); + } + else { + emit->output_map[idx] = dst_register( SVGA3DREG_COLOROUT, + semantic.SemanticIndex ); + } break; case TGSI_SEMANTIC_POSITION: emit->output_map[idx] = dst_register( SVGA3DREG_TEMP, diff --git a/src/gallium/drivers/svga/svga_tgsi_insn.c b/src/gallium/drivers/svga/svga_tgsi_insn.c index ea409b7e165..b5424dacf7d 100644 --- a/src/gallium/drivers/svga/svga_tgsi_insn.c +++ b/src/gallium/drivers/svga/svga_tgsi_insn.c @@ -1011,10 +1011,10 @@ static boolean emit_kilp(struct svga_shader_emitter *emit, { SVGA3dShaderInstToken inst; SVGA3dShaderDestToken temp; - struct src_register one = get_zero_immediate( emit ); + struct src_register one = scalar( get_zero_immediate( emit ), + TGSI_SWIZZLE_W ); inst = inst_token( SVGA3DOP_TEXKILL ); - one = scalar( one, TGSI_SWIZZLE_W ); /* texkill doesn't allow negation on the operand so lets move * negation of {1} to a temp register */ @@ -2254,11 +2254,28 @@ static boolean emit_ps_postamble( struct svga_shader_emitter *emit ) for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { if (SVGA3dShaderGetRegType(emit->true_col[i].value) != 0) { - if (!submit_op1( emit, - inst_token(SVGA3DOP_MOV), - emit->true_col[i], - src(emit->temp_col[i]) )) - return FALSE; + /* Potentially override output colors with white for XOR + * logicop workaround. + */ + if (emit->unit == PIPE_SHADER_FRAGMENT && + emit->key.fkey.white_fragments) { + + struct src_register one = scalar( get_zero_immediate( emit ), + TGSI_SWIZZLE_W ); + + if (!submit_op1( emit, + inst_token(SVGA3DOP_MOV), + emit->true_col[i], + one )) + return FALSE; + } + else { + if (!submit_op1( emit, + inst_token(SVGA3DOP_MOV), + emit->true_col[i], + src(emit->temp_col[i]) )) + return FALSE; + } } } @@ -2467,6 +2484,9 @@ needs_to_create_zero( struct svga_shader_emitter *emit ) if (emit->key.fkey.light_twoside) return TRUE; + if (emit->key.fkey.white_fragments) + return TRUE; + if (emit->emit_frontface) return TRUE; -- cgit v1.2.3 From ac597f5acc8886a0c44aaa4f2484f9d569ae5d6d Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 27 Jan 2010 14:45:56 +0000 Subject: svga: Fix PIPE_LOGICOP_INVERT. Actually the current XOR implementation is an INVERT. This fixes rectangle selection in Maya. --- src/gallium/drivers/svga/svga_pipe_blend.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/src/gallium/drivers/svga/svga_pipe_blend.c b/src/gallium/drivers/svga/svga_pipe_blend.c index 3ad3f97816c..c0cbda3af4b 100644 --- a/src/gallium/drivers/svga/svga_pipe_blend.c +++ b/src/gallium/drivers/svga/svga_pipe_blend.c @@ -92,6 +92,7 @@ svga_create_blend_state(struct pipe_context *pipe, if (templ->logicop_enable) { switch (templ->logicop_func) { case PIPE_LOGICOP_XOR: + case PIPE_LOGICOP_INVERT: blend->need_white_fragments = TRUE; blend->rt[i].blend_enable = TRUE; blend->rt[i].srcblend = SVGA3D_BLENDOP_ONE; @@ -125,12 +126,6 @@ svga_create_blend_state(struct pipe_context *pipe, blend->rt[i].dstblend = SVGA3D_BLENDOP_ONE; blend->rt[i].blendeq = SVGA3D_BLENDEQ_MAXIMUM; break; - case PIPE_LOGICOP_INVERT: - blend->rt[i].blend_enable = TRUE; - blend->rt[i].srcblend = SVGA3D_BLENDOP_INVSRCCOLOR; - blend->rt[i].dstblend = SVGA3D_BLENDOP_ZERO; - blend->rt[i].blendeq = SVGA3D_BLENDEQ_ADD; - break; case PIPE_LOGICOP_AND: /* Approximate with minimum - works for the 0 & anything case: */ blend->rt[i].blend_enable = TRUE; -- cgit v1.2.3 From 15fe4918223f04fa89d523220609abea0cac34e2 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 27 Jan 2010 15:41:25 +0000 Subject: svga: Prevent buffer overflow in buffer ranges. Do this by extending the nearest range to cover the new range. This fixes an access fault in Call of Duty which was doing many disjoint glBufferSubData calls. --- src/gallium/drivers/svga/svga_screen_buffer.c | 62 +++++++++++++++++++++++---- 1 file changed, 54 insertions(+), 8 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen_buffer.c b/src/gallium/drivers/svga/svga_screen_buffer.c index 719adde27ef..6a58ff238ad 100644 --- a/src/gallium/drivers/svga/svga_screen_buffer.c +++ b/src/gallium/drivers/svga/svga_screen_buffer.c @@ -310,10 +310,20 @@ svga_buffer_upload_queue(struct svga_buffer *sbuf, unsigned end) { unsigned i; + unsigned nearest_range; + unsigned nearest_dist; assert(sbuf->hw.buf); assert(end > start); + if (sbuf->hw.num_ranges < SVGA_BUFFER_MAX_RANGES) { + nearest_range = sbuf->hw.num_ranges; + nearest_dist = ~0; + } else { + nearest_range = SVGA_BUFFER_MAX_RANGES - 1; + nearest_dist = 0; + } + /* * Try to grow one of the ranges. * @@ -325,11 +335,33 @@ svga_buffer_upload_queue(struct svga_buffer *sbuf, */ for(i = 0; i < sbuf->hw.num_ranges; ++i) { - if(start <= sbuf->hw.ranges[i].end && sbuf->hw.ranges[i].start <= end) { + int left_dist; + int right_dist; + int dist; + + left_dist = start - sbuf->hw.ranges[i].end; + right_dist = sbuf->hw.ranges[i].start - end; + dist = MAX2(left_dist, right_dist); + + if (dist <= 0) { + /* + * Ranges are contiguous or overlapping -- extend this one and return. + */ + sbuf->hw.ranges[i].start = MIN2(sbuf->hw.ranges[i].start, start); - sbuf->hw.ranges[i].end = MAX2(sbuf->hw.ranges[i].end, end); + sbuf->hw.ranges[i].end = MAX2(sbuf->hw.ranges[i].end, end); return; } + else { + /* + * Discontiguous ranges -- keep track of the nearest range. + */ + + if (dist < nearest_dist) { + nearest_range = i; + nearest_dist = dist; + } + } } /* @@ -344,13 +376,27 @@ svga_buffer_upload_queue(struct svga_buffer *sbuf, assert(!sbuf->hw.svga); assert(!sbuf->hw.boxes); - /* - * Add a new range. - */ + if (sbuf->hw.num_ranges < SVGA_BUFFER_MAX_RANGES) { + /* + * Add a new range. + */ - sbuf->hw.ranges[sbuf->hw.num_ranges].start = start; - sbuf->hw.ranges[sbuf->hw.num_ranges].end = end; - ++sbuf->hw.num_ranges; + sbuf->hw.ranges[sbuf->hw.num_ranges].start = start; + sbuf->hw.ranges[sbuf->hw.num_ranges].end = end; + ++sbuf->hw.num_ranges; + } else { + /* + * Everything else failed, so just extend the nearest range. + * + * It is OK to do this because we always keep a local copy of the + * host buffer data, for SW TNL, and the host never modifies the buffer. + */ + + assert(nearest_range < SVGA_BUFFER_MAX_RANGES); + assert(nearest_range < sbuf->hw.num_ranges); + sbuf->hw.ranges[nearest_range].start = MIN2(sbuf->hw.ranges[nearest_range].start, start); + sbuf->hw.ranges[nearest_range].end = MAX2(sbuf->hw.ranges[nearest_range].end, end); + } } -- cgit v1.2.3 From e3257912e006120f6ab611e77005eed1a464030a Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 27 Jan 2010 16:25:31 +0000 Subject: mesa: Warn when indices are out of bounds, but do not skip the draw in debug builds. The driver (or preferably the hardware) should handle out of bounds indices. If there are problems then it's better to detect those in the debug builds. --- src/mesa/vbo/vbo_exec_array.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index bd2fccdba14..fdd6b0259e3 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -722,8 +722,7 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, #ifdef DEBUG /* 'end' was out of bounds, but now let's check the actual array - * indexes to see if any of them are out of bounds. If so, warn - * and skip the draw to avoid potential segfault, etc. + * indexes to see if any of them are out of bounds. */ { GLuint max = _mesa_max_buffer_index(ctx, count, type, indices, @@ -740,7 +739,6 @@ vbo_exec_DrawRangeElementsBaseVertex(GLenum mode, ctx->Array.ElementArrayBufferObj->Name, ctx->Array.ElementArrayBufferObj->Size); } - return; } /* XXX we could also find the min index and compare to 'start' * to see if start is correct. But it's more likely to get the -- cgit v1.2.3 From 0dab80fbfb5703bfbeed691051c353aeca3aaa7a Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Wed, 27 Jan 2010 10:20:15 +0200 Subject: r600: fix XPD with writemask same variable used for 2 different temp registers fixes e.g. glsl/bump --- src/mesa/drivers/dri/r600/r700_assembler.c | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r700_assembler.c b/src/mesa/drivers/dri/r600/r700_assembler.c index b0b38927e67..a6b656af951 100644 --- a/src/mesa/drivers/dri/r600/r700_assembler.c +++ b/src/mesa/drivers/dri/r600/r700_assembler.c @@ -4164,20 +4164,21 @@ GLboolean assemble_TEX(r700_AssemblerBase *pAsm) GLboolean assemble_XPD(r700_AssemblerBase *pAsm) { - BITS tmp; + BITS tmp1; + BITS tmp2 = 0; if( GL_FALSE == checkop2(pAsm) ) { return GL_FALSE; } - tmp = gethelpr(pAsm); + tmp1 = gethelpr(pAsm); pAsm->D.dst.opcode = SQ_OP2_INST_MUL; setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE); pAsm->D.dst.rtype = DST_REG_TEMPORARY; - pAsm->D.dst.reg = tmp; + pAsm->D.dst.reg = tmp1; nomask_PVSDST(&(pAsm->D.dst)); if( GL_FALSE == assemble_src(pAsm, 0, -1) ) @@ -4203,11 +4204,11 @@ GLboolean assemble_XPD(r700_AssemblerBase *pAsm) if(0xF != pAsm->pILInst[pAsm->uiCurInst].DstReg.WriteMask) { - tmp = gethelpr(pAsm); + tmp2 = gethelpr(pAsm); setaddrmode_PVSDST(&(pAsm->D.dst), ADDR_ABSOLUTE); pAsm->D.dst.rtype = DST_REG_TEMPORARY; - pAsm->D.dst.reg = tmp; + pAsm->D.dst.reg = tmp2; nomask_PVSDST(&(pAsm->D.dst)); } @@ -4235,7 +4236,7 @@ GLboolean assemble_XPD(r700_AssemblerBase *pAsm) // result1 + (neg) result0 setaddrmode_PVSSRC(&(pAsm->S[2].src),ADDR_ABSOLUTE); pAsm->S[2].src.rtype = SRC_REG_TEMPORARY; - pAsm->S[2].src.reg = tmp; + pAsm->S[2].src.reg = tmp1; neg_PVSSRC(&(pAsm->S[2].src)); noswizzle_PVSSRC(&(pAsm->S[2].src)); @@ -4258,7 +4259,7 @@ GLboolean assemble_XPD(r700_AssemblerBase *pAsm) // Use tmp as source setaddrmode_PVSSRC(&(pAsm->S[0].src), ADDR_ABSOLUTE); pAsm->S[0].src.rtype = SRC_REG_TEMPORARY; - pAsm->S[0].src.reg = tmp; + pAsm->S[0].src.reg = tmp2; noneg_PVSSRC(&(pAsm->S[0].src)); noswizzle_PVSSRC(&(pAsm->S[0].src)); -- cgit v1.2.3 From 77b7b3a1ab36f1dafa905dbe709d0d72dbc9d54d Mon Sep 17 00:00:00 2001 From: Andre Maasikas Date: Wed, 27 Jan 2010 11:22:56 +0200 Subject: r600: increase max texture units to 16 --- src/mesa/drivers/dri/r600/r600_context.c | 6 ++---- src/mesa/drivers/dri/r600/r600_tex.h | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index dbd233729c0..126de433a38 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -237,10 +237,8 @@ static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) { context_t *r600 = R700_CONTEXT(ctx); - ctx->Const.MaxTextureImageUnits = - driQueryOptioni(&r600->radeon.optionCache, "texture_image_units"); - ctx->Const.MaxTextureCoordUnits = - driQueryOptioni(&r600->radeon.optionCache, "texture_coord_units"); + ctx->Const.MaxTextureImageUnits = 16; + ctx->Const.MaxTextureCoordUnits = 8; ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureImageUnits, ctx->Const.MaxTextureCoordUnits); diff --git a/src/mesa/drivers/dri/r600/r600_tex.h b/src/mesa/drivers/dri/r600/r600_tex.h index fb0e1a023e1..0e3d32892a0 100644 --- a/src/mesa/drivers/dri/r600/r600_tex.h +++ b/src/mesa/drivers/dri/r600/r600_tex.h @@ -42,7 +42,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. /* Texel pitch is 8 alignment. */ #define R700_TEXEL_PITCH_ALIGNMENT_MASK 0x7 -#define R700_MAX_TEXTURE_UNITS 8 /* TODO : should be 16, lets make it work, review later */ +#define R700_MAX_TEXTURE_UNITS 16 extern void r600SetDepthTexMode(struct gl_texture_object *tObj); -- cgit v1.2.3 From 2041d3e4b76009687bb2a7752c3ee94e5c160357 Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 27 Jan 2010 12:16:50 -0500 Subject: r600: rv670 support 8 tex instructions just like other r6xx also clarify some other const values. --- src/mesa/drivers/dri/r600/r600_context.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 126de433a38..7803a98c969 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -238,6 +238,9 @@ static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) context_t *r600 = R700_CONTEXT(ctx); ctx->Const.MaxTextureImageUnits = 16; + /* 8 per clause on r6xx, 16 on r7xx + * but I think mesa only supports 8 at the moment + */ ctx->Const.MaxTextureCoordUnits = 8; ctx->Const.MaxTextureUnits = MIN2(ctx->Const.MaxTextureImageUnits, @@ -273,9 +276,8 @@ static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) ctx->Const.FragmentProgram.MaxNativeAttribs = 32; ctx->Const.FragmentProgram.MaxNativeParameters = 256; ctx->Const.FragmentProgram.MaxNativeAluInstructions = 8192; - /* 8 per clause on r6xx, 16 on rv670/r7xx */ - if ((screen->chip_family == CHIP_FAMILY_RV670) || - (screen->chip_family >= CHIP_FAMILY_RV770)) + /* 8 per clause on r6xx, 16 on r7xx */ + if (screen->chip_family >= CHIP_FAMILY_RV770) ctx->Const.FragmentProgram.MaxNativeTexInstructions = 16; else ctx->Const.FragmentProgram.MaxNativeTexInstructions = 8; -- cgit v1.2.3 From bba95570196dad29880426152a1b7fb77619296d Mon Sep 17 00:00:00 2001 From: Alex Deucher Date: Wed, 27 Jan 2010 12:18:02 -0500 Subject: r600: fix warning --- src/mesa/drivers/dri/r600/r600_context.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/mesa/drivers/dri/r600/r600_context.c b/src/mesa/drivers/dri/r600/r600_context.c index 7803a98c969..5cfa490a7e0 100644 --- a/src/mesa/drivers/dri/r600/r600_context.c +++ b/src/mesa/drivers/dri/r600/r600_context.c @@ -235,8 +235,6 @@ static void r600_init_vtbl(radeonContextPtr radeon) static void r600InitConstValues(GLcontext *ctx, radeonScreenPtr screen) { - context_t *r600 = R700_CONTEXT(ctx); - ctx->Const.MaxTextureImageUnits = 16; /* 8 per clause on r6xx, 16 on r7xx * but I think mesa only supports 8 at the moment -- cgit v1.2.3 From 50e890bc51cfc278378f25cb70be79f1bad0b6b6 Mon Sep 17 00:00:00 2001 From: Rodolfo Ribeiro Gomes Date: Tue, 26 Jan 2010 14:20:06 -0700 Subject: glx: fix possible memory leaks in dri2CreateScreen() Original patch fixed up by Brian Paul. --- src/glx/x11/dri2_glx.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/glx/x11/dri2_glx.c b/src/glx/x11/dri2_glx.c index 89efe3ab292..9988fa1b132 100644 --- a/src/glx/x11/dri2_glx.c +++ b/src/glx/x11/dri2_glx.c @@ -437,8 +437,10 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, psc->ext_list_first_time = GL_TRUE; if (!DRI2Connect(psc->dpy, RootWindow(psc->dpy, screen), - &driverName, &deviceName)) + &driverName, &deviceName)) { + XFree(psp); return NULL; + } psc->driver = driOpenDriver(driverName); if (psc->driver == NULL) { @@ -467,17 +469,17 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, psc->fd = open(deviceName, O_RDWR); if (psc->fd < 0) { ErrorMessageF("failed to open drm device: %s\n", strerror(errno)); - return NULL; + goto handle_error; } if (drmGetMagic(psc->fd, &magic)) { ErrorMessageF("failed to get magic\n"); - return NULL; + goto handle_error; } if (!DRI2Authenticate(psc->dpy, RootWindow(psc->dpy, screen), magic)) { ErrorMessageF("failed to authenticate magic %d\n", magic); - return NULL; + goto handle_error; } /* If the server does not support the protocol for @@ -491,7 +493,7 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, if (psc->__driScreen == NULL) { ErrorMessageF("failed to create dri screen\n"); - return NULL; + goto handle_error; } driBindExtensions(psc, 1); @@ -521,6 +523,7 @@ dri2CreateScreen(__GLXscreenConfigs * psc, int screen, handle_error: Xfree(driverName); Xfree(deviceName); + XFree(psp); /* FIXME: clean up here */ -- cgit v1.2.3 From 82c76cd16f35f4d903f49761af7eb28a755ad299 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 27 Jan 2010 16:25:59 -0700 Subject: windows: assorted build fixes These changes were originally submitted by Karl Schultz for Mesa 7.7-rc2 but weren't applied. --- src/mesa/drivers/windows/gdi/mesa.def | 4 ++-- src/mesa/drivers/windows/gdi/wmesa.c | 12 ------------ windows/VC8/mesa/gdi/gdi.vcproj | 8 ++++++++ windows/VC8/mesa/mesa/mesa.vcproj | 12 ++++++++++-- 4 files changed, 20 insertions(+), 16 deletions(-) diff --git a/src/mesa/drivers/windows/gdi/mesa.def b/src/mesa/drivers/windows/gdi/mesa.def index 62f75d9541f..700e3334295 100644 --- a/src/mesa/drivers/windows/gdi/mesa.def +++ b/src/mesa/drivers/windows/gdi/mesa.def @@ -870,7 +870,6 @@ EXPORTS _mesa_bzero _mesa_calloc _mesa_choose_tex_format - _mesa_compressed_texture_size _mesa_create_framebuffer _mesa_create_visual _mesa_delete_array_object @@ -932,6 +931,8 @@ EXPORTS _mesa_update_framebuffer_visual _mesa_use_program _mesa_Viewport + _mesa_meta_init + _mesa_meta_free _mesa_meta_CopyColorSubTable _mesa_meta_CopyColorTable _mesa_meta_CopyConvolutionFilter1D @@ -941,7 +942,6 @@ EXPORTS _mesa_meta_CopyTexSubImage1D _mesa_meta_CopyTexSubImage2D _mesa_meta_CopyTexSubImage3D - _mesa_wait_query _swrast_Accum _swrast_Bitmap _swrast_BlitFramebuffer diff --git a/src/mesa/drivers/windows/gdi/wmesa.c b/src/mesa/drivers/windows/gdi/wmesa.c index 8929b22af16..1788313b297 100644 --- a/src/mesa/drivers/windows/gdi/wmesa.c +++ b/src/mesa/drivers/windows/gdi/wmesa.c @@ -1286,9 +1286,6 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, rb->PutMonoValues = write_mono_rgba_pixels_16; rb->GetRow = read_rgba_span_16; rb->GetValues = read_rgba_pixels_16; - rb->RedBits = 5; - rb->GreenBits = 6; - rb->BlueBits = 5; break; case PF_8R8G8B: if (cColorBits == 24) @@ -1300,9 +1297,6 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, rb->PutMonoValues = write_mono_rgba_pixels_24; rb->GetRow = read_rgba_span_24; rb->GetValues = read_rgba_pixels_24; - rb->RedBits = 8; - rb->GreenBits = 8; - rb->BlueBits = 8; } else { @@ -1313,9 +1307,6 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, rb->PutMonoValues = write_mono_rgba_pixels_32; rb->GetRow = read_rgba_span_32; rb->GetValues = read_rgba_pixels_32; - rb->RedBits = 8; - rb->GreenBits = 8; - rb->BlueBits = 8; } break; default: @@ -1331,9 +1322,6 @@ void wmesa_set_renderbuffer_funcs(struct gl_renderbuffer *rb, int pixelformat, rb->PutMonoValues = write_mono_rgba_pixels_front; rb->GetRow = read_rgba_span_front; rb->GetValues = read_rgba_pixels_front; - rb->RedBits = 8; /* XXX fix these (565?) */ - rb->GreenBits = 8; - rb->BlueBits = 8; } } diff --git a/windows/VC8/mesa/gdi/gdi.vcproj b/windows/VC8/mesa/gdi/gdi.vcproj index a3dd5ef5b62..220923f9051 100644 --- a/windows/VC8/mesa/gdi/gdi.vcproj +++ b/windows/VC8/mesa/gdi/gdi.vcproj @@ -396,6 +396,10 @@ RelativePath="..\..\..\..\src\mesa\drivers\windows\gdi\mesa.def" > + + @@ -417,6 +421,10 @@ RelativePath="..\..\..\..\src\mesa\drivers\common\driverfuncs.h" > + + diff --git a/windows/VC8/mesa/mesa/mesa.vcproj b/windows/VC8/mesa/mesa/mesa.vcproj index 993c28ddc17..19de4ebd02f 100644 --- a/windows/VC8/mesa/mesa/mesa.vcproj +++ b/windows/VC8/mesa/mesa/mesa.vcproj @@ -450,6 +450,10 @@ RelativePath="..\..\..\..\src\mesa\main\fog.c" > + + @@ -1323,6 +1327,10 @@ RelativePath="..\..\..\..\src\mesa\main\fog.h" > + + @@ -1896,11 +1904,11 @@ > Date: Wed, 27 Jan 2010 17:08:03 -0700 Subject: docs: Fixed Windows build for 7.7.1 --- docs/relnotes-7.7.1.html | 1 + 1 file changed, 1 insertion(+) diff --git a/docs/relnotes-7.7.1.html b/docs/relnotes-7.7.1.html index b20c8a7724f..959efd9e57c 100644 --- a/docs/relnotes-7.7.1.html +++ b/docs/relnotes-7.7.1.html @@ -43,6 +43,7 @@ tbd
  • Allocate constants more tightly in GL_ARB_vertex/fragment parser.
  • Fixed mipmap generation bug caused by invalid viewport state.
  • Gallium SSE codegen for XPD didn't always work. +
  • Fixed Windows build. -- cgit v1.2.3 From 40298bf272c7fbb289b442b4424c2c17402ae322 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 28 Jan 2010 17:11:02 +0000 Subject: python/retrace: Dump all vertices for verbosity level 3. --- src/gallium/state_trackers/python/retrace/interpreter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/state_trackers/python/retrace/interpreter.py b/src/gallium/state_trackers/python/retrace/interpreter.py index 348f2e43683..18fa84f2a4c 100755 --- a/src/gallium/state_trackers/python/retrace/interpreter.py +++ b/src/gallium/state_trackers/python/retrace/interpreter.py @@ -557,7 +557,7 @@ class Context(Object): sys.stdout.write('\t{\n') for i in range(start, start + count): - if i >= start + 16: + if i >= start + 16 and not self.interpreter.verbosity(3): sys.stdout.write('\t...\n') break offset = i*isize -- cgit v1.2.3 From 8e240d7e0eb640cc954f6d81119136e2d546d618 Mon Sep 17 00:00:00 2001 From: Keith Whitwell Date: Mon, 10 Aug 2009 18:45:07 +0100 Subject: svga: remove sleep in DEBUG_FLUSH path --- src/gallium/drivers/svga/svga_pipe_draw.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/gallium/drivers/svga/svga_pipe_draw.c b/src/gallium/drivers/svga/svga_pipe_draw.c index 719b3419f86..8794deeb0a3 100644 --- a/src/gallium/drivers/svga/svga_pipe_draw.c +++ b/src/gallium/drivers/svga/svga_pipe_draw.c @@ -218,9 +218,6 @@ svga_draw_range_elements( struct pipe_context *pipe, if (SVGA_DEBUG & DEBUG_FLUSH) { static unsigned id; debug_printf("%s %d\n", __FUNCTION__, id++); - if (id > 1300) - util_time_sleep( 2000 ); - svga_hwtnl_flush_retry( svga ); svga_context_flush(svga, NULL); } -- cgit v1.2.3 From 8db8adfd01a1ff1e2a160ae3b0199bd3daa4191a Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Thu, 28 Jan 2010 17:59:26 +0100 Subject: st/xorg: Update to new libkms interface but be backwards compatible --- src/gallium/state_trackers/xorg/xorg_crtc.c | 4 ++++ src/gallium/state_trackers/xorg/xorg_driver.c | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/src/gallium/state_trackers/xorg/xorg_crtc.c b/src/gallium/state_trackers/xorg/xorg_crtc.c index 0160b1aa59f..daa9f8b8204 100644 --- a/src/gallium/state_trackers/xorg/xorg_crtc.c +++ b/src/gallium/state_trackers/xorg/xorg_crtc.c @@ -243,7 +243,11 @@ crtc_load_cursor_argb_kms(xf86CrtcPtr crtc, CARD32 * image) unsigned attr[8]; attr[0] = KMS_BO_TYPE; +#ifdef KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8 + attr[1] = KMS_BO_TYPE_CURSOR_64X64_A8R8G8B8; +#else attr[1] = KMS_BO_TYPE_CURSOR; +#endif attr[2] = KMS_WIDTH; attr[3] = 64; attr[4] = KMS_HEIGHT; diff --git a/src/gallium/state_trackers/xorg/xorg_driver.c b/src/gallium/state_trackers/xorg/xorg_driver.c index e4ad789e9bc..f53a879a14a 100644 --- a/src/gallium/state_trackers/xorg/xorg_driver.c +++ b/src/gallium/state_trackers/xorg/xorg_driver.c @@ -1008,7 +1008,11 @@ drv_create_front_buffer_kms(ScrnInfoPtr pScrn) int ret; attr[0] = KMS_BO_TYPE; +#ifdef KMS_BO_TYPE_SCANOUT_X8R8G8B8 + attr[1] = KMS_BO_TYPE_SCANOUT_X8R8G8B8; +#else attr[1] = KMS_BO_TYPE_SCANOUT; +#endif attr[2] = KMS_WIDTH; attr[3] = pScrn->virtualX; attr[4] = KMS_HEIGHT; -- cgit v1.2.3 From 4eb48a3af78beda4ee1628d0ecd6a437a0721a72 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 15 Dec 2009 12:13:43 +0000 Subject: llvmpipe: Fix bad SI -> FP conversion into lp_build_log2_approx. It should be a bitcast as the integer value is actually an encoded FP already. --- src/gallium/drivers/llvmpipe/lp_bld_arit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c index f5d9db70fb5..d35e13bd797 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c @@ -1284,7 +1284,7 @@ lp_build_log2_approx(struct lp_build_context *bld, /* mant = (float) mantissa(x) */ mant = LLVMBuildAnd(bld->builder, i, mantmask, ""); mant = LLVMBuildOr(bld->builder, mant, one, ""); - mant = LLVMBuildSIToFP(bld->builder, mant, vec_type, ""); + mant = LLVMBuildBitCast(bld->builder, mant, vec_type, ""); logmant = lp_build_polynomial(bld, mant, lp_build_log2_polynomial, Elements(lp_build_log2_polynomial)); -- cgit v1.2.3 From aa8b23e077f8c4f4c517e58533a72db0fb861091 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 15 Dec 2009 13:58:53 +0000 Subject: llvmpipe: Fix typo in lp_build_log constant. --- src/gallium/drivers/llvmpipe/lp_bld_arit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c index d35e13bd797..9ed15bc3f7c 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c @@ -1082,7 +1082,7 @@ lp_build_log(struct lp_build_context *bld, LLVMValueRef x) { /* log(2) */ - LLVMValueRef log2 = lp_build_const_scalar(bld->type, 1.4426950408889634); + LLVMValueRef log2 = lp_build_const_scalar(bld->type, 0.69314718055994529); return lp_build_mul(bld, log2, lp_build_exp2(bld, x)); } -- cgit v1.2.3 From 0451d0fd01bdd4ee6a2497a3a1c749446739602e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 15 Dec 2009 14:15:52 +0000 Subject: llvmpipe: Fix lp_build_polynomial comment. --- src/gallium/drivers/llvmpipe/lp_bld_arit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c index 9ed15bc3f7c..46dabda8cdb 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c @@ -1094,7 +1094,7 @@ lp_build_log(struct lp_build_context *bld, /** * Generate polynomial. - * Ex: x^2 * coeffs[0] + x * coeffs[1] + coeffs[2]. + * Ex: coeffs[0] + x * coeffs[1] + x^2 * coeffs[2]. */ static LLVMValueRef lp_build_polynomial(struct lp_build_context *bld, -- cgit v1.2.3 From e20547042c03e22234c9580f005286552bd4ae18 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 15 Dec 2009 14:46:43 +0000 Subject: llvmpipe: Fix yet another copynpaste typo in lp_build_log2_approx. Now fslight looks perfect. --- src/gallium/drivers/llvmpipe/lp_bld_arit.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c index 46dabda8cdb..a94b30af9bf 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c @@ -1290,7 +1290,7 @@ lp_build_log2_approx(struct lp_build_context *bld, Elements(lp_build_log2_polynomial)); /* This effectively increases the polynomial degree by one, but ensures that log2(1) == 0*/ - logmant = LLVMBuildMul(bld->builder, logmant, LLVMBuildMul(bld->builder, mant, bld->one, ""), ""); + logmant = LLVMBuildMul(bld->builder, logmant, LLVMBuildSub(bld->builder, mant, bld->one, ""), ""); res = LLVMBuildAdd(bld->builder, logmant, logexp, ""); } -- cgit v1.2.3 From 96ec4eb755d0296c807ca5c89383a3b9f9fc1dbe Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 14 Dec 2009 15:24:31 -0700 Subject: llvmpipe: fix broken lp_build_abs() --- src/gallium/drivers/llvmpipe/lp_bld_arit.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_arit.c b/src/gallium/drivers/llvmpipe/lp_bld_arit.c index a94b30af9bf..1aee9b35f31 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_arit.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_arit.c @@ -628,7 +628,8 @@ lp_build_abs(struct lp_build_context *bld, if(type.floating) { /* Mask out the sign bit */ LLVMTypeRef int_vec_type = lp_build_int_vec_type(type); - LLVMValueRef mask = lp_build_int_const_scalar(type, ((unsigned long long)1 << type.width) - 1); + unsigned long absMask = ~(1 << (type.width - 1)); + LLVMValueRef mask = lp_build_int_const_scalar(type, ((unsigned long long) absMask)); a = LLVMBuildBitCast(bld->builder, a, int_vec_type, ""); a = LLVMBuildAnd(bld->builder, a, mask, ""); a = LLVMBuildBitCast(bld->builder, a, vec_type, ""); -- cgit v1.2.3 From 46167149ceac96cf91f2031d2c58346b80f0834d Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Mon, 14 Dec 2009 15:27:35 -0700 Subject: llvmpipe: fix broken TGSI_OPCODE_FRC codegen --- src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c index e722bca1a6c..88cdf9e349f 100644 --- a/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c +++ b/src/gallium/drivers/llvmpipe/lp_bld_tgsi_soa.c @@ -766,7 +766,7 @@ emit_instruction( FOR_EACH_DST0_ENABLED_CHANNEL( inst, chan_index ) { src0 = emit_fetch( bld, inst, 0, chan_index ); tmp0 = lp_build_floor(&bld->base, src0); - tmp0 = lp_build_sub(&bld->base, tmp0, src0); + tmp0 = lp_build_sub(&bld->base, src0, tmp0); dst0[chan_index] = tmp0; } break; -- cgit v1.2.3 From 4e506eac8f11a23249a46265b796c4764d9d045e Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Wed, 16 Dec 2009 15:06:02 +0000 Subject: llvmpipe: add LP_DEBUG env var Cherry-picked from dec35d04aeb398eef159aaf8cde5e0d04622b811. --- src/gallium/drivers/llvmpipe/lp_debug.h | 71 +++++++++++++++++ src/gallium/drivers/llvmpipe/lp_screen.c | 22 ++++++ src/gallium/drivers/llvmpipe/lp_state_fs.c | 117 ++++++++++++++--------------- 3 files changed, 151 insertions(+), 59 deletions(-) create mode 100644 src/gallium/drivers/llvmpipe/lp_debug.h diff --git a/src/gallium/drivers/llvmpipe/lp_debug.h b/src/gallium/drivers/llvmpipe/lp_debug.h new file mode 100644 index 00000000000..74b27574942 --- /dev/null +++ b/src/gallium/drivers/llvmpipe/lp_debug.h @@ -0,0 +1,71 @@ +/************************************************************************** + * + * Copyright 2007 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 LP_DEBUG_H +#define LP_DEBUG_H + +#include "pipe/p_compiler.h" +#include "util/u_debug.h" + +extern void +st_print_current(void); + + +#define DEBUG_PIPE 0x1 +#define DEBUG_TGSI 0x2 +#define DEBUG_TEX 0x4 +#define DEBUG_ASM 0x8 +#define DEBUG_SETUP 0x10 +#define DEBUG_RAST 0x20 +#define DEBUG_QUERY 0x40 +#define DEBUG_SCREEN 0x80 +#define DEBUG_JIT 0x100 + +#ifdef DEBUG +extern int LP_DEBUG; +#else +#define LP_DEBUG 0 +#endif + +void st_debug_init( void ); + +static INLINE void +LP_DBG( unsigned flag, const char *fmt, ... ) +{ + if (LP_DEBUG & flag) + { + va_list args; + + va_start( args, fmt ); + debug_vprintf( fmt, args ); + va_end( args ); + } +} + + +#endif /* LP_DEBUG_H */ diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 05189274589..87fddbd13f1 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -35,6 +35,24 @@ #include "lp_winsys.h" #include "lp_jit.h" #include "lp_screen.h" +#include "lp_debug.h" + +#ifdef DEBUG +int LP_DEBUG = 0; + +static const struct debug_named_value lp_debug_flags[] = { + { "pipe", DEBUG_PIPE }, + { "tgsi", DEBUG_TGSI }, + { "tex", DEBUG_TEX }, + { "asm", DEBUG_ASM }, + { "setup", DEBUG_SETUP }, + { "rast", DEBUG_RAST }, + { "query", DEBUG_QUERY }, + { "screen", DEBUG_SCREEN }, + { "jit", DEBUG_JIT }, + {NULL, 0} +}; +#endif static const char * @@ -213,6 +231,10 @@ llvmpipe_create_screen(struct llvmpipe_winsys *winsys) { struct llvmpipe_screen *screen = CALLOC_STRUCT(llvmpipe_screen); +#ifdef DEBUG + LP_DEBUG = debug_get_flags_option("LP_DEBUG", lp_debug_flags, 0 ); +#endif + if (!screen) return NULL; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 2297cbb76f8..45a1ca87a3a 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -85,6 +85,7 @@ #include "lp_buffer.h" #include "lp_state.h" #include "lp_tex_sample.h" +#include "lp_debug.h" static const unsigned char quad_offset_x[4] = {0, 1, 0, 1}; @@ -395,59 +396,58 @@ generate_fragment(struct llvmpipe_context *lp, unsigned i; unsigned chan; -#ifdef DEBUG - tgsi_dump(shader->base.tokens, 0); - if(key->depth.enabled) { - debug_printf("depth.format = %s\n", pf_name(key->zsbuf_format)); - debug_printf("depth.func = %s\n", debug_dump_func(key->depth.func, TRUE)); - debug_printf("depth.writemask = %u\n", key->depth.writemask); - } - if(key->alpha.enabled) { - debug_printf("alpha.func = %s\n", debug_dump_func(key->alpha.func, TRUE)); - debug_printf("alpha.ref_value = %f\n", key->alpha.ref_value); - } - if(key->blend.logicop_enable) { - debug_printf("blend.logicop_func = %u\n", key->blend.logicop_func); - } - else if(key->blend.blend_enable) { - debug_printf("blend.rgb_func = %s\n", debug_dump_blend_func (key->blend.rgb_func, TRUE)); - debug_printf("rgb_src_factor = %s\n", debug_dump_blend_factor(key->blend.rgb_src_factor, TRUE)); - debug_printf("rgb_dst_factor = %s\n", debug_dump_blend_factor(key->blend.rgb_dst_factor, TRUE)); - debug_printf("alpha_func = %s\n", debug_dump_blend_func (key->blend.alpha_func, TRUE)); - debug_printf("alpha_src_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_src_factor, TRUE)); - debug_printf("alpha_dst_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_dst_factor, TRUE)); - } - debug_printf("blend.colormask = 0x%x\n", key->blend.colormask); - for(i = 0; i < PIPE_MAX_SAMPLERS; ++i) { - if(key->sampler[i].format) { - debug_printf("sampler[%u] = \n", i); - debug_printf(" .format = %s\n", - pf_name(key->sampler[i].format)); - debug_printf(" .target = %s\n", - debug_dump_tex_target(key->sampler[i].target, TRUE)); - debug_printf(" .pot = %u %u %u\n", - key->sampler[i].pot_width, - key->sampler[i].pot_height, - key->sampler[i].pot_depth); - debug_printf(" .wrap = %s %s %s\n", - debug_dump_tex_wrap(key->sampler[i].wrap_s, TRUE), - debug_dump_tex_wrap(key->sampler[i].wrap_t, TRUE), - debug_dump_tex_wrap(key->sampler[i].wrap_r, TRUE)); - debug_printf(" .min_img_filter = %s\n", - debug_dump_tex_filter(key->sampler[i].min_img_filter, TRUE)); - debug_printf(" .min_mip_filter = %s\n", - debug_dump_tex_mipfilter(key->sampler[i].min_mip_filter, TRUE)); - debug_printf(" .mag_img_filter = %s\n", - debug_dump_tex_filter(key->sampler[i].mag_img_filter, TRUE)); - if(key->sampler[i].compare_mode) - debug_printf(" .compare_mode = %s\n", debug_dump_func(key->sampler[i].compare_func, TRUE)); - debug_printf(" .normalized_coords = %u\n", key->sampler[i].normalized_coords); - debug_printf(" .prefilter = %u\n", key->sampler[i].prefilter); + if (LP_DEBUG & DEBUG_JIT) { + tgsi_dump(shader->base.tokens, 0); + if(key->depth.enabled) { + debug_printf("depth.format = %s\n", pf_name(key->zsbuf_format)); + debug_printf("depth.func = %s\n", debug_dump_func(key->depth.func, TRUE)); + debug_printf("depth.writemask = %u\n", key->depth.writemask); + } + if(key->alpha.enabled) { + debug_printf("alpha.func = %s\n", debug_dump_func(key->alpha.func, TRUE)); + debug_printf("alpha.ref_value = %f\n", key->alpha.ref_value); + } + if(key->blend.logicop_enable) { + debug_printf("blend.logicop_func = %u\n", key->blend.logicop_func); + } + else if(key->blend.blend_enable) { + debug_printf("blend.rgb_func = %s\n", debug_dump_blend_func (key->blend.rgb_func, TRUE)); + debug_printf("rgb_src_factor = %s\n", debug_dump_blend_factor(key->blend.rgb_src_factor, TRUE)); + debug_printf("rgb_dst_factor = %s\n", debug_dump_blend_factor(key->blend.rgb_dst_factor, TRUE)); + debug_printf("alpha_func = %s\n", debug_dump_blend_func (key->blend.alpha_func, TRUE)); + debug_printf("alpha_src_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_src_factor, TRUE)); + debug_printf("alpha_dst_factor = %s\n", debug_dump_blend_factor(key->blend.alpha_dst_factor, TRUE)); + } + debug_printf("blend.colormask = 0x%x\n", key->blend.colormask); + for(i = 0; i < PIPE_MAX_SAMPLERS; ++i) { + if(key->sampler[i].format) { + debug_printf("sampler[%u] = \n", i); + debug_printf(" .format = %s\n", + pf_name(key->sampler[i].format)); + debug_printf(" .target = %s\n", + debug_dump_tex_target(key->sampler[i].target, TRUE)); + debug_printf(" .pot = %u %u %u\n", + key->sampler[i].pot_width, + key->sampler[i].pot_height, + key->sampler[i].pot_depth); + debug_printf(" .wrap = %s %s %s\n", + debug_dump_tex_wrap(key->sampler[i].wrap_s, TRUE), + debug_dump_tex_wrap(key->sampler[i].wrap_t, TRUE), + debug_dump_tex_wrap(key->sampler[i].wrap_r, TRUE)); + debug_printf(" .min_img_filter = %s\n", + debug_dump_tex_filter(key->sampler[i].min_img_filter, TRUE)); + debug_printf(" .min_mip_filter = %s\n", + debug_dump_tex_mipfilter(key->sampler[i].min_mip_filter, TRUE)); + debug_printf(" .mag_img_filter = %s\n", + debug_dump_tex_filter(key->sampler[i].mag_img_filter, TRUE)); + if(key->sampler[i].compare_mode) + debug_printf(" .compare_mode = %s\n", debug_dump_func(key->sampler[i].compare_func, TRUE)); + debug_printf(" .normalized_coords = %u\n", key->sampler[i].normalized_coords); + debug_printf(" .prefilter = %u\n", key->sampler[i].prefilter); + } } } -#endif - variant = CALLOC_STRUCT(lp_fragment_shader_variant); if(!variant) return NULL; @@ -586,8 +586,8 @@ generate_fragment(struct llvmpipe_context *lp, } lp_build_conv_mask(builder, fs_type, blend_type, - fs_mask, num_fs, - &blend_mask, 1); + fs_mask, num_fs, + &blend_mask, 1); /* * Blending. @@ -616,16 +616,15 @@ generate_fragment(struct llvmpipe_context *lp, LLVMRunFunctionPassManager(screen->pass, variant->function); -#ifdef DEBUG - LLVMDumpValue(variant->function); - debug_printf("\n"); -#endif + if (LP_DEBUG & DEBUG_JIT) { + LLVMDumpValue(variant->function); + debug_printf("\n"); + } variant->jit_function = (lp_jit_frag_func)LLVMGetPointerToGlobal(screen->engine, variant->function); -#ifdef DEBUG - lp_disassemble(variant->jit_function); -#endif + if (LP_DEBUG & DEBUG_ASM) + lp_disassemble(variant->jit_function); variant->next = shader->variants; shader->variants = variant; -- cgit v1.2.3 From 4e95983fa832cf0808ccab64e9fbfb0fcdde8049 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 26 Dec 2009 11:00:42 +0000 Subject: llvmpipe: Flush draw module before switching framebuffer. Otherwise geometry will end up in the wrong rendertarget. --- src/gallium/drivers/llvmpipe/lp_state_surface.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/llvmpipe/lp_state_surface.c b/src/gallium/drivers/llvmpipe/lp_state_surface.c index 9f745856742..4eb45970a4d 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_surface.c +++ b/src/gallium/drivers/llvmpipe/lp_state_surface.c @@ -48,6 +48,8 @@ llvmpipe_set_framebuffer_state(struct pipe_context *pipe, struct llvmpipe_context *lp = llvmpipe_context(pipe); uint i; + draw_flush(lp->draw); + for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { /* check if changing cbuf */ if (lp->framebuffer.cbufs[i] != fb->cbufs[i]) { -- cgit v1.2.3 From 31b3420688dbf7fc2282f0d1fe13e51fe9e1f9b6 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 26 Dec 2009 15:21:16 +0000 Subject: llvmpipe: Treat state changes systematically. That is: - check for no op - update/flush draw module - update bound state and mark it as dirty In particular flushing the draw module is important since it may contain unflushed primitives which would otherwise be draw with wrong state. --- src/gallium/drivers/llvmpipe/lp_state_blend.c | 18 +++++++++++++++++- src/gallium/drivers/llvmpipe/lp_state_fs.c | 10 +++++++--- src/gallium/drivers/llvmpipe/lp_state_rasterizer.c | 9 ++++++--- src/gallium/drivers/llvmpipe/lp_state_vs.c | 12 ++++++++---- 4 files changed, 38 insertions(+), 11 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_blend.c b/src/gallium/drivers/llvmpipe/lp_state_blend.c index b2e75d3b14e..a94cd05ef20 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_blend.c +++ b/src/gallium/drivers/llvmpipe/lp_state_blend.c @@ -34,6 +34,7 @@ #include "util/u_memory.h" #include "util/u_math.h" #include "util/u_debug_dump.h" +#include "draw/draw_context.h" #include "lp_screen.h" #include "lp_context.h" #include "lp_state.h" @@ -51,6 +52,11 @@ void llvmpipe_bind_blend_state( struct pipe_context *pipe, { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); + if (llvmpipe->blend == blend) + return; + + draw_flush(llvmpipe->draw); + llvmpipe->blend = blend; llvmpipe->dirty |= LP_NEW_BLEND; @@ -69,6 +75,11 @@ void llvmpipe_set_blend_color( struct pipe_context *pipe, struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); unsigned i, j; + if(memcmp(&llvmpipe->blend_color, blend_color, sizeof *blend_color) == 0) + return; + + draw_flush(llvmpipe->draw); + memcpy(&llvmpipe->blend_color, blend_color, sizeof *blend_color); if(!llvmpipe->jit_context.blend_color) @@ -99,7 +110,12 @@ llvmpipe_bind_depth_stencil_state(struct pipe_context *pipe, { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); - llvmpipe->depth_stencil = (const struct pipe_depth_stencil_alpha_state *)depth_stencil; + if (llvmpipe->depth_stencil == depth_stencil) + return; + + draw_flush(llvmpipe->draw); + + llvmpipe->depth_stencil = depth_stencil; if(llvmpipe->depth_stencil) llvmpipe->jit_context.alpha_ref_value = llvmpipe->depth_stencil->alpha.ref_value; diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 45a1ca87a3a..696657e65e6 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -658,7 +658,12 @@ llvmpipe_bind_fs_state(struct pipe_context *pipe, void *fs) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); - llvmpipe->fs = (struct lp_fragment_shader *) fs; + if (llvmpipe->fs == fs) + return; + + draw_flush(llvmpipe->draw); + + llvmpipe->fs = fs; llvmpipe->dirty |= LP_NEW_FS; } @@ -709,8 +714,7 @@ llvmpipe_set_constant_buffer(struct pipe_context *pipe, assert(shader < PIPE_SHADER_TYPES); assert(index == 0); - if(shader == PIPE_SHADER_VERTEX) - draw_flush(llvmpipe->draw); + draw_flush(llvmpipe->draw); /* note: reference counting */ pipe_buffer_reference(&llvmpipe->constants[shader].buffer, buffer); diff --git a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c index 4561c6b8456..aa3b5a3f91e 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c +++ b/src/gallium/drivers/llvmpipe/lp_state_rasterizer.c @@ -41,14 +41,17 @@ llvmpipe_create_rasterizer_state(struct pipe_context *pipe, } void llvmpipe_bind_rasterizer_state(struct pipe_context *pipe, - void *setup) + void *rasterizer) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); + if (llvmpipe->rasterizer == rasterizer) + return; + /* pass-through to draw module */ - draw_set_rasterizer_state(llvmpipe->draw, setup); + draw_set_rasterizer_state(llvmpipe->draw, rasterizer); - llvmpipe->rasterizer = (struct pipe_rasterizer_state *)setup; + llvmpipe->rasterizer = rasterizer; llvmpipe->dirty |= LP_NEW_RASTERIZER; } diff --git a/src/gallium/drivers/llvmpipe/lp_state_vs.c b/src/gallium/drivers/llvmpipe/lp_state_vs.c index 15c30296144..0e9bc1d5f8a 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_vs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_vs.c @@ -70,14 +70,18 @@ fail: void -llvmpipe_bind_vs_state(struct pipe_context *pipe, void *vs) +llvmpipe_bind_vs_state(struct pipe_context *pipe, void *_vs) { struct llvmpipe_context *llvmpipe = llvmpipe_context(pipe); + const struct lp_vertex_shader *vs = (const struct lp_vertex_shader *)_vs; - llvmpipe->vs = (const struct lp_vertex_shader *)vs; + if (llvmpipe->vs == vs) + return; - draw_bind_vertex_shader(llvmpipe->draw, - (llvmpipe->vs ? llvmpipe->vs->draw_data : NULL)); + draw_bind_vertex_shader(llvmpipe->draw, + vs ? vs->draw_data : NULL); + + llvmpipe->vs = vs; llvmpipe->dirty |= LP_NEW_VS; } -- cgit v1.2.3 From 88cf87bd5633c0e8155e4226fc49ab36f1abc335 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 28 Dec 2009 22:52:41 +0000 Subject: llvmpipe: Unmapping vertex/index buffers does NOT flush draw module anymore. Not since 6094e79f4e3350d123c7532b1c73faa60834a62d. Drivers now need to flush draw module explicitely (which explains why all those previous commits adding draw_flushes calls were necessary). This is a good thing, but it's tricky to get this right in face of user buffers (it's not even clear who has the responsibility to flush when a user buffer is seen -- statetracker or pipe driver), so just force flush (temporarily) since it's not a bottleneck now. --- src/gallium/drivers/llvmpipe/lp_draw_arrays.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c index a43e438064c..e539e713226 100644 --- a/src/gallium/drivers/llvmpipe/lp_draw_arrays.c +++ b/src/gallium/drivers/llvmpipe/lp_draw_arrays.c @@ -101,7 +101,7 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe, draw_arrays(draw, mode, start, count); /* - * unmap vertex/index buffers - will cause draw module to flush + * unmap vertex/index buffers */ for (i = 0; i < lp->num_vertex_buffers; i++) { draw_set_mapped_vertex_buffer(draw, i, NULL); @@ -110,6 +110,12 @@ llvmpipe_draw_range_elements(struct pipe_context *pipe, draw_set_mapped_element_buffer(draw, 0, NULL); } + /* + * TODO: Flush only when a user vertex/index buffer is present + * (or even better, modify draw module to do this + * internally when this condition is seen?) + */ + draw_flush(draw); /* Note: leave drawing surfaces mapped */ -- cgit v1.2.3 From 14dc02a1b2c52cf02b7f89885b61f42575834958 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 10 Nov 2009 17:51:06 -0800 Subject: llvmpipe: Be more conservative with the supported formats. We'll likely support much more formats, but doing this allows to run more testsuites without immediately hit assertion failures. --- src/gallium/drivers/llvmpipe/lp_screen.c | 58 ++++++++++++++++++++++++++++---- 1 file changed, 51 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_screen.c b/src/gallium/drivers/llvmpipe/lp_screen.c index 87fddbd13f1..190dad0f26a 100644 --- a/src/gallium/drivers/llvmpipe/lp_screen.c +++ b/src/gallium/drivers/llvmpipe/lp_screen.c @@ -27,6 +27,7 @@ #include "util/u_memory.h" +#include "util/u_format.h" #include "pipe/p_defines.h" #include "pipe/p_screen.h" @@ -149,17 +150,17 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, { struct llvmpipe_screen *screen = llvmpipe_screen(_screen); struct llvmpipe_winsys *winsys = screen->winsys; + const struct util_format_description *format_desc; + + format_desc = util_format_description(format); + if(!format_desc) + return FALSE; assert(target == PIPE_TEXTURE_1D || target == PIPE_TEXTURE_2D || target == PIPE_TEXTURE_3D || target == PIPE_TEXTURE_CUBE); - if(format == PIPE_FORMAT_Z16_UNORM) - return FALSE; - if(format == PIPE_FORMAT_S8_UNORM) - return FALSE; - switch(format) { case PIPE_FORMAT_DXT1_RGB: case PIPE_FORMAT_DXT1_RGBA: @@ -170,8 +171,51 @@ llvmpipe_is_format_supported( struct pipe_screen *_screen, break; } - if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) - return winsys->is_displaytarget_format_supported(winsys, format); + if(tex_usage & PIPE_TEXTURE_USAGE_RENDER_TARGET) { + if(format_desc->block.width != 1 || + format_desc->block.height != 1) + return FALSE; + + if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR && + format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && + format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) + return FALSE; + + if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB && + format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB) + return FALSE; + } + + if(tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) { + if(!winsys->is_displaytarget_format_supported(winsys, format)) + return FALSE; + } + + if(tex_usage & PIPE_TEXTURE_USAGE_DEPTH_STENCIL) { + if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) + return FALSE; + + /* FIXME: Temporary restriction. See lp_state_fs.c. */ + if(format_desc->block.bits != 32) + return FALSE; + } + + /* FIXME: Temporary restrictions. See lp_bld_sample_soa.c */ + if(tex_usage & PIPE_TEXTURE_USAGE_SAMPLER) { + if(format_desc->block.width != 1 || + format_desc->block.height != 1) + return FALSE; + + if(format_desc->layout != UTIL_FORMAT_LAYOUT_SCALAR && + format_desc->layout != UTIL_FORMAT_LAYOUT_ARITH && + format_desc->layout != UTIL_FORMAT_LAYOUT_ARRAY) + return FALSE; + + if(format_desc->colorspace != UTIL_FORMAT_COLORSPACE_RGB && + format_desc->colorspace != UTIL_FORMAT_COLORSPACE_SRGB && + format_desc->colorspace != UTIL_FORMAT_COLORSPACE_ZS) + return FALSE; + } return TRUE; } -- cgit v1.2.3 From 1acf7a09e762e6d8a26c8f0d919f5efa6df6e71f Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Tue, 10 Nov 2009 17:52:53 -0800 Subject: llvmpipe: Use the generic conversion routine for depths. This allows for z32f depth format to work correctly. --- src/gallium/drivers/llvmpipe/lp_state_fs.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 696657e65e6..48ec5e1b39f 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -147,6 +147,20 @@ generate_depth(LLVMBuilderRef builder, format_desc = util_format_description(key->zsbuf_format); assert(format_desc); + /* + * Depths are expected to be between 0 and 1, even if they are stored in + * floats. Setting these bits here will ensure that the lp_build_conv() call + * below won't try to unnecessarily clamp the incoming values. + */ + if(src_type.floating) { + src_type.sign = FALSE; + src_type.norm = TRUE; + } + else { + assert(!src_type.sign); + assert(src_type.norm); + } + /* Pick the depth type. */ dst_type = lp_depth_type(format_desc, src_type.width*src_type.length); @@ -154,14 +168,11 @@ generate_depth(LLVMBuilderRef builder, assert(dst_type.width == src_type.width); assert(dst_type.length == src_type.length); -#if 1 - src = lp_build_clamped_float_to_unsigned_norm(builder, - src_type, - dst_type.width, - src); -#else lp_build_conv(builder, src_type, dst_type, &src, 1, &src, 1); -#endif + + dst_ptr = LLVMBuildBitCast(builder, + dst_ptr, + LLVMPointerType(lp_build_vec_type(dst_type), 0), ""); lp_build_depth_test(builder, &key->depth, -- cgit v1.2.3 From a0907a645f7d832e7c53d14c2ed88080b456a1a5 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sun, 15 Nov 2009 06:46:48 -0800 Subject: llvmpipe: Fix memory leak. --- src/gallium/drivers/llvmpipe/lp_state_vs.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gallium/drivers/llvmpipe/lp_state_vs.c b/src/gallium/drivers/llvmpipe/lp_state_vs.c index 0e9bc1d5f8a..884e3878e62 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_vs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_vs.c @@ -96,5 +96,6 @@ llvmpipe_delete_vs_state(struct pipe_context *pipe, void *vs) (struct lp_vertex_shader *)vs; draw_delete_vertex_shader(llvmpipe->draw, state->draw_data); + FREE( (void *)state->shader.tokens ); FREE( state ); } -- cgit v1.2.3 From 12ba3559785fa276b3b4b6fa06cfe551b87aecc3 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 23 Nov 2009 11:21:11 +0000 Subject: llvmpipe: Use assert instead of abort. Only verify functions on debug builds. --- src/gallium/drivers/llvmpipe/lp_jit.c | 2 +- src/gallium/drivers/llvmpipe/lp_state_fs.c | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/llvmpipe/lp_jit.c b/src/gallium/drivers/llvmpipe/lp_jit.c index b5aa7d680f1..7e019d4eda2 100644 --- a/src/gallium/drivers/llvmpipe/lp_jit.c +++ b/src/gallium/drivers/llvmpipe/lp_jit.c @@ -166,7 +166,7 @@ lp_jit_screen_init(struct llvmpipe_screen *screen) if (LLVMCreateJITCompiler(&screen->engine, screen->provider, 1, &error)) { _debug_printf("%s\n", error); LLVMDisposeMessage(error); - abort(); + assert(0); } screen->target = LLVMGetExecutionEngineTargetData(screen->engine); diff --git a/src/gallium/drivers/llvmpipe/lp_state_fs.c b/src/gallium/drivers/llvmpipe/lp_state_fs.c index 48ec5e1b39f..2b6965deca8 100644 --- a/src/gallium/drivers/llvmpipe/lp_state_fs.c +++ b/src/gallium/drivers/llvmpipe/lp_state_fs.c @@ -620,10 +620,12 @@ generate_fragment(struct llvmpipe_context *lp, * Translate the LLVM IR into machine code. */ +#ifdef DEBUG if(LLVMVerifyFunction(variant->function, LLVMPrintMessageAction)) { LLVMDumpValue(variant->function); - abort(); + assert(0); } +#endif LLVMRunFunctionPassManager(screen->pass, variant->function); -- cgit v1.2.3 From 1befcd5a2ae8588f8d17d2ecea19dd4daccddb00 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 26 Dec 2009 11:01:05 +0000 Subject: softpipe: Flush draw module before switching framebuffer. Otherwise geometry might end up in the wrong rendertarget. --- src/gallium/drivers/softpipe/sp_state_surface.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c index 794a9225b86..d29b6aeb78b 100644 --- a/src/gallium/drivers/softpipe/sp_state_surface.c +++ b/src/gallium/drivers/softpipe/sp_state_surface.c @@ -48,6 +48,8 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe, struct softpipe_context *sp = softpipe_context(pipe); uint i; + draw_flush(sp->draw); + for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { /* check if changing cbuf */ if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) { -- cgit v1.2.3 From 6e68898b05dc957dc6cb92d2ff060589e5936650 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Sat, 26 Dec 2009 21:05:31 +0000 Subject: softpipe: Flush draw module when fragment pipeline state changes. --- src/gallium/drivers/softpipe/sp_state_blend.c | 5 +++++ src/gallium/drivers/softpipe/sp_state_fs.c | 11 ++++++++++- src/gallium/drivers/softpipe/sp_state_rasterizer.c | 9 ++++++--- 3 files changed, 21 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/softpipe/sp_state_blend.c b/src/gallium/drivers/softpipe/sp_state_blend.c index efed082f823..95ab3234337 100644 --- a/src/gallium/drivers/softpipe/sp_state_blend.c +++ b/src/gallium/drivers/softpipe/sp_state_blend.c @@ -29,6 +29,7 @@ */ #include "util/u_memory.h" +#include "draw/draw_context.h" #include "sp_context.h" #include "sp_state.h" @@ -45,6 +46,8 @@ void softpipe_bind_blend_state( struct pipe_context *pipe, { struct softpipe_context *softpipe = softpipe_context(pipe); + draw_flush(softpipe->draw); + softpipe->blend = (struct pipe_blend_state *)blend; softpipe->dirty |= SP_NEW_BLEND; @@ -62,6 +65,8 @@ void softpipe_set_blend_color( struct pipe_context *pipe, { struct softpipe_context *softpipe = softpipe_context(pipe); + draw_flush(softpipe->draw); + softpipe->blend_color = *blend_color; softpipe->dirty |= SP_NEW_BLEND; diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c index b41f7e8ab72..8ea48ed3aae 100644 --- a/src/gallium/drivers/softpipe/sp_state_fs.c +++ b/src/gallium/drivers/softpipe/sp_state_fs.c @@ -69,7 +69,14 @@ softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->fs = (struct sp_fragment_shader *) fs; + draw_flush(softpipe->draw); + + if (softpipe->fs == fs) + return; + + draw_flush(softpipe->draw); + + softpipe->fs = fs; softpipe->dirty |= SP_NEW_FS; } @@ -159,6 +166,8 @@ softpipe_set_constant_buffer(struct pipe_context *pipe, assert(shader < PIPE_SHADER_TYPES); assert(index == 0); + draw_flush(softpipe->draw); + /* note: reference counting */ pipe_buffer_reference(&softpipe->constants[shader].buffer, buf ? buf->buffer : NULL); diff --git a/src/gallium/drivers/softpipe/sp_state_rasterizer.c b/src/gallium/drivers/softpipe/sp_state_rasterizer.c index 87b72196838..a5b00336d44 100644 --- a/src/gallium/drivers/softpipe/sp_state_rasterizer.c +++ b/src/gallium/drivers/softpipe/sp_state_rasterizer.c @@ -41,14 +41,17 @@ softpipe_create_rasterizer_state(struct pipe_context *pipe, } void softpipe_bind_rasterizer_state(struct pipe_context *pipe, - void *setup) + void *rasterizer) { struct softpipe_context *softpipe = softpipe_context(pipe); + if (softpipe->rasterizer == rasterizer) + return; + /* pass-through to draw module */ - draw_set_rasterizer_state(softpipe->draw, setup); + draw_set_rasterizer_state(softpipe->draw, rasterizer); - softpipe->rasterizer = (struct pipe_rasterizer_state *)setup; + softpipe->rasterizer = rasterizer; softpipe->dirty |= SP_NEW_RASTERIZER; } -- cgit v1.2.3 From 23eda89ec89e2bd5bc26077bd56e8d6b5d4040d4 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 28 Jan 2010 13:02:40 -0700 Subject: mesa: do state validation in _mesa_valid_to_render() ...rather than checking/validating before all the calls to _mesa_valid_to_render() and valid_to_render(). The next patch will actually fix some bugs... --- src/mesa/main/api_validate.c | 9 --------- src/mesa/main/context.c | 4 ++++ 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/mesa/main/api_validate.c b/src/mesa/main/api_validate.c index e71e5a6ce86..013048bbc16 100644 --- a/src/mesa/main/api_validate.c +++ b/src/mesa/main/api_validate.c @@ -190,9 +190,6 @@ _mesa_validate_DrawElements(GLcontext *ctx, return GL_FALSE; } - if (ctx->NewState) - _mesa_update_state(ctx); - if (!check_valid_to_render(ctx, "glDrawElements")) return GL_FALSE; @@ -254,9 +251,6 @@ _mesa_validate_DrawRangeElements(GLcontext *ctx, GLenum mode, return GL_FALSE; } - if (ctx->NewState) - _mesa_update_state(ctx); - if (!check_valid_to_render(ctx, "glDrawRangeElements")) return GL_FALSE; @@ -304,9 +298,6 @@ _mesa_validate_DrawArrays(GLcontext *ctx, return GL_FALSE; } - if (ctx->NewState) - _mesa_update_state(ctx); - if (!check_valid_to_render(ctx, "glDrawArrays")) return GL_FALSE; diff --git a/src/mesa/main/context.c b/src/mesa/main/context.c index 87eae966392..f5d9a30efbc 100644 --- a/src/mesa/main/context.c +++ b/src/mesa/main/context.c @@ -1580,6 +1580,10 @@ _mesa_set_mvp_with_dp4( GLcontext *ctx, GLboolean _mesa_valid_to_render(GLcontext *ctx, const char *where) { + /* This depends on having up to date derived state (shaders) */ + if (ctx->NewState) + _mesa_update_state(ctx); + if (ctx->Shader.CurrentProgram) { /* using shaders */ if (!ctx->Shader.CurrentProgram->LinkStatus) { -- cgit v1.2.3 From 3cba779e16935f7c3a0bfd8af48bd5e015068e96 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 28 Jan 2010 13:04:16 -0700 Subject: vbo: fix missing state validation bugs Commit 2708ddfb06a36d8568e2aa130bf1f7d551fcd309 caused a few regressions. We need to check/validate state after calling bind_arrays() because it might set the _NEW_ARRAYS flag if the varying VP inputs change. The symptom of this problem was some attribute arrays being ignored (or interpreted as constant-valued) in glDrawRangeElements or glMultiDrawElements. A follow-on patch will add some additional asserts to try to catch this kind of thing in the future. --- src/mesa/vbo/vbo_exec_array.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/mesa/vbo/vbo_exec_array.c b/src/mesa/vbo/vbo_exec_array.c index fdd6b0259e3..d08976ca298 100644 --- a/src/mesa/vbo/vbo_exec_array.c +++ b/src/mesa/vbo/vbo_exec_array.c @@ -443,6 +443,13 @@ recalculate_input_bindings(GLcontext *ctx) } +/** + * Examine the enabled vertex arrays to set the exec->array.inputs[] values. + * These will point to the arrays to actually use for drawing. Some will + * be user-provided arrays, other will be zero-stride const-valued arrays. + * Note that this might set the _NEW_ARRAY dirty flag so state validation + * must be done after this call. + */ static void bind_arrays(GLcontext *ctx) { @@ -484,9 +491,6 @@ vbo_exec_DrawArrays(GLenum mode, GLint start, GLsizei count) FLUSH_CURRENT( ctx, 0 ); - if (ctx->NewState) - _mesa_update_state( ctx ); - if (!_mesa_valid_to_render(ctx, "glDrawArrays")) { return; } @@ -600,18 +604,16 @@ vbo_validated_drawrangeelements(GLcontext *ctx, GLenum mode, FLUSH_CURRENT( ctx, 0 ); - if (ctx->NewState) - _mesa_update_state( ctx ); - if (!_mesa_valid_to_render(ctx, "glDraw[Range]Elements")) { return; } + bind_arrays( ctx ); + + /* check for dirty state again */ if (ctx->NewState) _mesa_update_state( ctx ); - bind_arrays( ctx ); - ib.count = count; ib.type = type; ib.obj = ctx->Array.ElementArrayBufferObj; @@ -848,16 +850,10 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode, FLUSH_CURRENT( ctx, 0 ); - if (ctx->NewState) - _mesa_update_state( ctx ); - if (!_mesa_valid_to_render(ctx, "glMultiDrawElements")) { return; } - if (ctx->NewState) - _mesa_update_state( ctx ); - prim = _mesa_calloc(primcount * sizeof(*prim)); if (prim == NULL) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "glMultiDrawElements"); @@ -869,6 +865,10 @@ vbo_validated_multidrawelements(GLcontext *ctx, GLenum mode, */ bind_arrays( ctx ); + /* check for dirty state again */ + if (ctx->NewState) + _mesa_update_state( ctx ); + switch (type) { case GL_UNSIGNED_INT: index_type_size = 4; -- cgit v1.2.3 From 4d1234e22242529c8d85f5ef0cf826af41a91570 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 28 Jan 2010 13:05:23 -0700 Subject: st/mesa: check that state is validated before drawing --- src/mesa/state_tracker/st_draw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/state_tracker/st_draw.c b/src/mesa/state_tracker/st_draw.c index 5c6af1125a3..d3b22db121c 100644 --- a/src/mesa/state_tracker/st_draw.c +++ b/src/mesa/state_tracker/st_draw.c @@ -569,6 +569,9 @@ st_draw_vbo(GLcontext *ctx, /* sanity check for pointer arithmetic below */ assert(sizeof(arrays[0]->Ptr[0]) == 1); + /* Mesa core state should have been validated already */ + assert(ctx->NewState == 0x0); + st_validate_state(ctx->st); /* must get these after state validation! */ -- cgit v1.2.3 From 9fd3c74724e557bc6ecc851d8552615ab3becfe2 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 28 Jan 2010 13:05:36 -0700 Subject: tnl: check that state is validated before drawing --- src/mesa/tnl/t_draw.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/mesa/tnl/t_draw.c b/src/mesa/tnl/t_draw.c index 9a888ce19f4..b0e31c06a9f 100644 --- a/src/mesa/tnl/t_draw.c +++ b/src/mesa/tnl/t_draw.c @@ -394,6 +394,9 @@ void _tnl_draw_prims( GLcontext *ctx, GLuint max_basevertex = prim->basevertex; GLuint i; + /* Mesa core state should have been validated already */ + assert(ctx->NewState == 0x0); + for (i = 1; i < nr_prims; i++) max_basevertex = MAX2(max_basevertex, prim[i].basevertex); -- cgit v1.2.3 From cb5447f79ca03d29407e8db84166f5bddd8d4c59 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Fri, 29 Jan 2010 08:26:23 -0700 Subject: glsl: fix preprocessor bug involving //-style comments in macro definitions See comments for details. --- src/mesa/shader/slang/slang_preprocess.c | 32 +++++++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/src/mesa/shader/slang/slang_preprocess.c b/src/mesa/shader/slang/slang_preprocess.c index e9a24cc009a..ba40bad446e 100644 --- a/src/mesa/shader/slang/slang_preprocess.c +++ b/src/mesa/shader/slang/slang_preprocess.c @@ -914,6 +914,35 @@ parse_if (slang_string *output, const byte *prod, GLuint *pi, GLint *result, pp_ #define PRAGMA_PARAM 1 +/** + * Return the length of the given string, stopping at any C++-style comments. + * This step fixes bugs with macro definitions such as: + * #define PI 3.14159 // this is pi + * The preprocessor includes the comment in the definition of PI so + * when we plug in PI somewhere, we get the comment too. + * This function effectively strips of the // comment from the given string. + * It might also be possible to fix this in the preprocessor grammar. + * This bug is not present in the new Mesa 7.8 preprocessor. + */ +static int +strlen_without_comments(const char *s) +{ + char pred = 0; + int len = 0; + while (*s) { + if (*s == '/' && pred == '/') { + return len - 1; + } + pred = *s; + s++; + len++; + } + return len; +} + + + + static GLboolean preprocess_source (slang_string *output, const char *source, grammar pid, grammar eid, @@ -1055,11 +1084,12 @@ preprocess_source (slang_string *output, const char *source, if (state.cond.top->effective) { slang_string replacement; expand_state es; + int idlen2 = strlen_without_comments((char*)id); pp_annotate (output, ") %s", id); slang_string_init(&replacement); - slang_string_pushs(&replacement, id, idlen); + slang_string_pushs(&replacement, id, idlen2); /* Expand macro replacement. */ es.output = &symbol->replacement; -- cgit v1.2.3 From ddedfe12d41808c3caa77649e3a9a6c4c6253d69 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Thu, 28 Jan 2010 20:51:52 +0000 Subject: svga: Actually call fence_reference in texture downloads. --- src/gallium/drivers/svga/svga_screen_texture.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gallium/drivers/svga/svga_screen_texture.c b/src/gallium/drivers/svga/svga_screen_texture.c index 9ad4edafef2..c3819882b41 100644 --- a/src/gallium/drivers/svga/svga_screen_texture.c +++ b/src/gallium/drivers/svga/svga_screen_texture.c @@ -203,7 +203,7 @@ svga_transfer_dma(struct svga_transfer *st, if(transfer == SVGA3D_READ_HOST_VRAM) { svga_screen_flush(screen, &fence); sws->fence_finish(sws, fence, 0); - //sws->fence_reference(sws, &fence, NULL); + sws->fence_reference(sws, &fence, NULL); } } else { @@ -232,7 +232,7 @@ svga_transfer_dma(struct svga_transfer *st, if(y) { svga_screen_flush(screen, &fence); sws->fence_finish(sws, fence, 0); - //sws->fence_reference(sws, &fence, NULL); + sws->fence_reference(sws, &fence, NULL); } hw = sws->buffer_map(sws, st->hwbuf, PIPE_BUFFER_USAGE_CPU_WRITE); -- cgit v1.2.3 From f5145a6ec3e9086988ab8ec004276f845fecc3d9 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 29 Jan 2010 17:11:36 +0100 Subject: vmware/core: Remove old ioctl structs not used Leftover that was never used in this driver --- src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h | 43 ------------------------- 1 file changed, 43 deletions(-) diff --git a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h index 2be7e1249b6..681d6b5f996 100644 --- a/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h +++ b/src/gallium/winsys/drm/vmware/core/vmwgfx_drm.h @@ -85,49 +85,6 @@ struct drm_vmw_getparam_arg { uint32_t pad64; }; -/*************************************************************************/ -/** - * DRM_VMW_EXTENSION - Query device extensions. - */ - -/** - * struct drm_vmw_extension_rep - * - * @exists: The queried extension exists. - * @driver_ioctl_offset: Ioctl number of the first ioctl in the extension. - * @driver_sarea_offset: Offset to any space in the DRI SAREA - * used by the extension. - * @major: Major version number of the extension. - * @minor: Minor version number of the extension. - * @pl: Patch level version number of the extension. - * - * Output argument to the DRM_VMW_EXTENSION Ioctl. - */ - -struct drm_vmw_extension_rep { - int32_t exists; - uint32_t driver_ioctl_offset; - uint32_t driver_sarea_offset; - uint32_t major; - uint32_t minor; - uint32_t pl; - uint32_t pad64; -}; - -/** - * union drm_vmw_extension_arg - * - * @extension - Ascii name of the extension to be queried. //In - * @rep - Reply as defined above. //Out - * - * Argument to the DRM_VMW_EXTENSION Ioctl. - */ - -union drm_vmw_extension_arg { - char extension[DRM_VMW_EXT_NAME_LEN]; - struct drm_vmw_extension_rep rep; -}; - /*************************************************************************/ /** * DRM_VMW_CREATE_CONTEXT - Create a host context. -- cgit v1.2.3