From 685fd2c035e284db2447ede0f6da278adaa70a0d Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 26 Nov 2008 12:56:23 +0100 Subject: tgsi: Implement OPCODE_ROUND for SSE2 backend. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 4d59106dbfa..151d2b1c379 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -842,6 +842,29 @@ emit_rcp ( make_xmm( xmm_src ) ); } +static void PIPE_CDECL +rnd4f( + float *store ) +{ + store[0] = floorf( store[0] + 0.5f ); + store[1] = floorf( store[1] + 0.5f ); + store[2] = floorf( store[2] + 0.5f ); + store[3] = floorf( store[3] + 0.5f ); +} + +static void +emit_rnd( + struct x86_function *func, + unsigned xmm_save, + unsigned xmm_dst ) +{ + emit_func_call_dst( + func, + xmm_save, + xmm_dst, + rnd4f ); +} + static void emit_rsqrt( struct x86_function *func, @@ -1639,7 +1662,11 @@ emit_instruction( break; case TGSI_OPCODE_ROUND: - return 0; + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + FETCH( func, *inst, 0, 0, chan_index ); + emit_rnd( func, 0, 0 ); + STORE( func, *inst, 0, 0, chan_index ); + } break; case TGSI_OPCODE_EXPBASE2: -- cgit v1.2.3 From eee3d216049f21507a3ff6908f1d506c683efad0 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 26 Nov 2008 13:17:25 +0100 Subject: tgsi: Implement OPCODE_ARR. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 5 +---- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 7 ++++++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 41dffc3dbaf..7114119fe29 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -2067,6 +2067,7 @@ exec_instruction( break; case TGSI_OPCODE_ROUND: + case TGSI_OPCODE_ARR: FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { FETCH( &r[0], 0, chan_index ); micro_rnd( &r[0], &r[0] ); @@ -2367,10 +2368,6 @@ exec_instruction( assert (0); break; - case TGSI_OPCODE_ARR: - assert (0); - break; - case TGSI_OPCODE_BRA: assert (0); break; diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 151d2b1c379..752c7c3c315 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1906,7 +1906,12 @@ emit_instruction( break; case TGSI_OPCODE_ARR: - return 0; + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + FETCH( func, *inst, 0, 0, chan_index ); + emit_rnd( func, 0, 0 ); + emit_f2it( func, 0 ); + STORE( func, *inst, 0, 0, chan_index ); + } break; case TGSI_OPCODE_BRA: -- cgit v1.2.3 From 281055987a535d7fa226cfbd9e1acb7777b2b3dd Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 26 Nov 2008 07:06:14 -0700 Subject: gallium: replace 2 with PIPE_SHADER_TYPES --- src/mesa/state_tracker/st_context.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mesa/state_tracker/st_context.h b/src/mesa/state_tracker/st_context.h index 1d1aca3111b..5bcb87ce208 100644 --- a/src/mesa/state_tracker/st_context.h +++ b/src/mesa/state_tracker/st_context.h @@ -102,7 +102,7 @@ struct st_context } state; struct { - struct st_tracked_state tracked_state[2]; + struct st_tracked_state tracked_state[PIPE_SHADER_TYPES]; } constants; /* XXX unused: */ -- cgit v1.2.3 From 277089b81ae498f598efdc74fafda9873864ee54 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 26 Nov 2008 07:06:26 -0700 Subject: gallium: fix glBitmap color bug By time we get around to rendering the cached bitmap, the current color may have changed. Need to make sure we load the constant slot with the cached color. --- src/mesa/state_tracker/st_cb_bitmap.c | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/src/mesa/state_tracker/st_cb_bitmap.c b/src/mesa/state_tracker/st_cb_bitmap.c index 694104f9cfb..73645201cc6 100644 --- a/src/mesa/state_tracker/st_cb_bitmap.c +++ b/src/mesa/state_tracker/st_cb_bitmap.c @@ -219,11 +219,6 @@ combined_bitmap_fragment_program(GLcontext *ctx) st_translate_fragment_program(st, stfp->bitmap_program, NULL); } - /* Ideally we'd have updated the pipe constants during the normal - * st/atom mechanism. But we can't since this is specific to glBitmap. - */ - st_upload_constants(st, stfp->Base.Base.Parameters, PIPE_SHADER_FRAGMENT); - return stfp->bitmap_program; } @@ -442,6 +437,22 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, stfp = combined_bitmap_fragment_program(ctx); + /* As an optimization, Mesa's fragment programs will sometimes get the + * primary color from a statevar/constant rather than a varying variable. + * when that's the case, we need to ensure that we use the 'color' + * parameter and not the current attribute color (which may have changed + * through glRasterPos and state validation. + * So, we force the proper color here. Not elegant, but it works. + */ + { + GLfloat colorSave[4]; + COPY_4V(colorSave, ctx->Current.Attrib[VERT_ATTRIB_COLOR0]); + COPY_4V(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], color); + st_upload_constants(st, stfp->Base.Base.Parameters, PIPE_SHADER_FRAGMENT); + COPY_4V(ctx->Current.Attrib[VERT_ATTRIB_COLOR0], colorSave); + } + + /* limit checks */ /* XXX if the bitmap is larger than the max texture size, break * it up into chunks. @@ -476,7 +487,8 @@ draw_bitmap_quad(GLcontext *ctx, GLint x, GLint y, GLfloat z, samplers[i] = &st->state.samplers[i]; } samplers[stfp->bitmap_sampler] = &st->bitmap.sampler; - cso_set_samplers(cso, num, (const struct pipe_sampler_state **) samplers); } + cso_set_samplers(cso, num, (const struct pipe_sampler_state **) samplers); + } /* user textures, plus the bitmap texture */ { -- cgit v1.2.3 From 6e96bd70e56f6ba4ff444c584376475a136bca26 Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 26 Nov 2008 07:38:31 -0700 Subject: Revert "tgsi: Implement OPCODE_ROUND for SSE2 backend." This reverts commit 685fd2c035e284db2447ede0f6da278adaa70a0d. Does not compile since emit_rnd() is trying to pass 4 params to emit_func_call_dst() which takes 3 params. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 29 +---------------------------- 1 file changed, 1 insertion(+), 28 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 752c7c3c315..4bda756dbc1 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -842,29 +842,6 @@ emit_rcp ( make_xmm( xmm_src ) ); } -static void PIPE_CDECL -rnd4f( - float *store ) -{ - store[0] = floorf( store[0] + 0.5f ); - store[1] = floorf( store[1] + 0.5f ); - store[2] = floorf( store[2] + 0.5f ); - store[3] = floorf( store[3] + 0.5f ); -} - -static void -emit_rnd( - struct x86_function *func, - unsigned xmm_save, - unsigned xmm_dst ) -{ - emit_func_call_dst( - func, - xmm_save, - xmm_dst, - rnd4f ); -} - static void emit_rsqrt( struct x86_function *func, @@ -1662,11 +1639,7 @@ emit_instruction( break; case TGSI_OPCODE_ROUND: - FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { - FETCH( func, *inst, 0, 0, chan_index ); - emit_rnd( func, 0, 0 ); - STORE( func, *inst, 0, 0, chan_index ); - } + return 0; break; case TGSI_OPCODE_EXPBASE2: -- cgit v1.2.3 From 1250526e3012f6958679c5dcdcb990387b53479b Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 26 Nov 2008 07:41:19 -0700 Subject: gallium: disable TGSI_OPCODE_ARR case until emit_rnd() is redone. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 4bda756dbc1..29442b4ec4f 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1878,6 +1878,7 @@ emit_instruction( return 0; break; +#if 0 case TGSI_OPCODE_ARR: FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { FETCH( func, *inst, 0, 0, chan_index ); @@ -1886,7 +1887,7 @@ emit_instruction( STORE( func, *inst, 0, 0, chan_index ); } break; - +#endif case TGSI_OPCODE_BRA: return 0; break; -- cgit v1.2.3 From 1347439a87a26f261ab07c914ea4e69965703ee2 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 26 Nov 2008 13:54:28 +0100 Subject: tgsi: Implement OPCODE_SSG/SGN. --- src/gallium/auxiliary/tgsi/tgsi_exec.c | 18 +++++++++++++++++- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 30 +++++++++++++++++++++++++++++- 2 files changed, 46 insertions(+), 2 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_exec.c b/src/gallium/auxiliary/tgsi/tgsi_exec.c index 7114119fe29..65a0f39fdb4 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_exec.c +++ b/src/gallium/auxiliary/tgsi/tgsi_exec.c @@ -839,6 +839,17 @@ micro_rnd( dst->f[3] = floorf( src->f[3] + 0.5f ); } +static void +micro_sgn( + union tgsi_exec_channel *dst, + const union tgsi_exec_channel *src ) +{ + dst->f[0] = src->f[0] < 0.0f ? -1.0f : src->f[0] > 0.0f ? 1.0f : 0.0f; + dst->f[1] = src->f[1] < 0.0f ? -1.0f : src->f[1] > 0.0f ? 1.0f : 0.0f; + dst->f[2] = src->f[2] < 0.0f ? -1.0f : src->f[2] > 0.0f ? 1.0f : 0.0f; + dst->f[3] = src->f[3] < 0.0f ? -1.0f : src->f[3] > 0.0f ? 1.0f : 0.0f; +} + static void micro_shl( union tgsi_exec_channel *dst, @@ -2423,7 +2434,12 @@ exec_instruction( break; case TGSI_OPCODE_SSG: - assert (0); + /* TGSI_OPCODE_SGN */ + FOR_EACH_ENABLED_CHANNEL( *inst, chan_index ) { + FETCH( &r[0], 0, chan_index ); + micro_sgn( &r[0], &r[0] ); + STORE( &r[0], 0, chan_index ); + } break; case TGSI_OPCODE_CMP: diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 29442b4ec4f..499d8655421 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -901,6 +901,29 @@ emit_setsign( TGSI_EXEC_TEMP_80000000_C ) ); } +static void PIPE_CDECL +sgn4f( + float *store ) +{ + store[0] = store[0] < 0.0f ? -1.0f : store[0] > 0.0f ? 1.0f : 0.0f; + store[1] = store[1] < 0.0f ? -1.0f : store[1] > 0.0f ? 1.0f : 0.0f; + store[2] = store[2] < 0.0f ? -1.0f : store[2] > 0.0f ? 1.0f : 0.0f; + store[3] = store[3] < 0.0f ? -1.0f : store[3] > 0.0f ? 1.0f : 0.0f; +} + +static void +emit_sgn( + struct x86_function *func, + unsigned xmm_save, + unsigned xmm_dst ) +{ + emit_func_call_dst( + func, + xmm_save, + xmm_dst, + sgn4f ); +} + static void PIPE_CDECL sin4f( float *store ) @@ -1904,7 +1927,12 @@ emit_instruction( break; case TGSI_OPCODE_SSG: - return 0; + /* TGSI_OPCODE_SGN */ + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + FETCH( func, *inst, 0, 0, chan_index ); + emit_sgn( func, 0, 0 ); + STORE( func, *inst, 0, 0, chan_index ); + } break; case TGSI_OPCODE_CMP: -- cgit v1.2.3 From 972922b1bf28346568bedfadc2198ed93230f5d7 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 26 Nov 2008 12:56:23 +0100 Subject: tgsi: Implement OPCODE_ROUND for SSE2 backend. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 499d8655421..31480c40da0 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -842,6 +842,29 @@ emit_rcp ( make_xmm( xmm_src ) ); } +static void PIPE_CDECL +rnd4f( + float *store ) +{ + store[0] = floorf( store[0] + 0.5f ); + store[1] = floorf( store[1] + 0.5f ); + store[2] = floorf( store[2] + 0.5f ); + store[3] = floorf( store[3] + 0.5f ); +} + +static void +emit_rnd( + struct x86_function *func, + unsigned xmm_save, + unsigned xmm_dst ) +{ + emit_func_call_dst( + func, + xmm_save, + xmm_dst, + rnd4f ); +} + static void emit_rsqrt( struct x86_function *func, @@ -1662,7 +1685,11 @@ emit_instruction( break; case TGSI_OPCODE_ROUND: - return 0; + FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { + FETCH( func, *inst, 0, 0, chan_index ); + emit_rnd( func, 0, 0 ); + STORE( func, *inst, 0, 0, chan_index ); + } break; case TGSI_OPCODE_EXPBASE2: -- cgit v1.2.3 From 527e76a7ec7f330bd321fe9632a0fadedbab1d41 Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 26 Nov 2008 17:20:07 +0100 Subject: tgsi: Fix build. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 31480c40da0..68f5510351f 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -855,12 +855,10 @@ rnd4f( static void emit_rnd( struct x86_function *func, - unsigned xmm_save, unsigned xmm_dst ) { emit_func_call_dst( func, - xmm_save, xmm_dst, rnd4f ); } @@ -937,12 +935,10 @@ sgn4f( static void emit_sgn( struct x86_function *func, - unsigned xmm_save, unsigned xmm_dst ) { emit_func_call_dst( func, - xmm_save, xmm_dst, sgn4f ); } @@ -1687,7 +1683,7 @@ emit_instruction( case TGSI_OPCODE_ROUND: FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { FETCH( func, *inst, 0, 0, chan_index ); - emit_rnd( func, 0, 0 ); + emit_rnd( func, 0 ); STORE( func, *inst, 0, 0, chan_index ); } break; @@ -1957,7 +1953,7 @@ emit_instruction( /* TGSI_OPCODE_SGN */ FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { FETCH( func, *inst, 0, 0, chan_index ); - emit_sgn( func, 0, 0 ); + emit_sgn( func, 0 ); STORE( func, *inst, 0, 0, chan_index ); } break; -- cgit v1.2.3 From 158a5f75d8436facfe8163845a942979899213fe Mon Sep 17 00:00:00 2001 From: Michal Krol Date: Wed, 26 Nov 2008 22:29:49 +0100 Subject: tgsi: Reenable OPCODE_ARR. --- src/gallium/auxiliary/tgsi/tgsi_sse2.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gallium/auxiliary/tgsi/tgsi_sse2.c b/src/gallium/auxiliary/tgsi/tgsi_sse2.c index 68f5510351f..ff869c8312f 100644 --- a/src/gallium/auxiliary/tgsi/tgsi_sse2.c +++ b/src/gallium/auxiliary/tgsi/tgsi_sse2.c @@ -1924,16 +1924,15 @@ emit_instruction( return 0; break; -#if 0 case TGSI_OPCODE_ARR: FOR_EACH_DST0_ENABLED_CHANNEL( *inst, chan_index ) { FETCH( func, *inst, 0, 0, chan_index ); - emit_rnd( func, 0, 0 ); + emit_rnd( func, 0 ); emit_f2it( func, 0 ); STORE( func, *inst, 0, 0, chan_index ); } break; -#endif + case TGSI_OPCODE_BRA: return 0; break; -- cgit v1.2.3