From: michal Date: Sat, 27 Oct 2007 13:05:13 +0000 (+0100) Subject: Enable SSE2 for fragment shaders. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=1ab8f6e69615c4f39110cf9202ae4b52238c0bf2;p=mesa.git Enable SSE2 for fragment shaders. --- diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h index e51e81c7b83..548151b378e 100644 --- a/src/mesa/pipe/softpipe/sp_context.h +++ b/src/mesa/pipe/softpipe/sp_context.h @@ -79,7 +79,7 @@ struct softpipe_context { const struct pipe_sampler_state *sampler[PIPE_MAX_SAMPLERS]; const struct pipe_depth_stencil_state *depth_stencil; const struct pipe_rasterizer_state *rasterizer; - const struct pipe_shader_state *fs; + const struct sp_fragment_shader_state *fs; const struct sp_vertex_shader_state *vs; struct pipe_blend_color blend_color; diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c index dc8d6e0e230..f079ab9583b 100644 --- a/src/mesa/pipe/softpipe/sp_quad_fs.c +++ b/src/mesa/pipe/softpipe/sp_quad_fs.c @@ -37,7 +37,10 @@ #include "pipe/llvm/llvmtgsi.h" +#include "x86/rtasm/x86sse.h" + #include "sp_context.h" +#include "sp_state.h" #include "sp_headers.h" #include "sp_quad.h" #include "sp_tex_sample.h" @@ -100,8 +103,8 @@ shade_quad( /* run shader */ /* XXX: Generated code effectively unusable until it handles quad->mask */ - if( !quad->mask && softpipe->fs->executable != NULL ) { - codegen_function func = (codegen_function) softpipe->fs->executable; + if( !quad->mask ) { + codegen_function func = (codegen_function) x86_get_func( &softpipe->fs->sse2_program ); func( machine->Inputs, machine->Outputs, @@ -119,7 +122,7 @@ shade_quad( /* store result color */ if (qss->colorOutSlot >= 0) { /* XXX need to handle multiple color outputs someday */ - assert(qss->stage.softpipe->fs->output_semantic_name[qss->colorOutSlot] + assert(qss->stage.softpipe->fs->shader.output_semantic_name[qss->colorOutSlot] == TGSI_SEMANTIC_COLOR); memcpy( quad->outputs.color, @@ -167,15 +170,15 @@ static void shade_begin(struct quad_stage *qs) /* XXX only do this if the fragment shader changes... */ tgsi_exec_machine_init(&qss->machine, - softpipe->fs->tokens, + softpipe->fs->shader.tokens, PIPE_MAX_SAMPLERS, qss->samplers ); /* find output slots for depth, color */ qss->colorOutSlot = -1; qss->depthOutSlot = -1; - for (i = 0; i < qss->stage.softpipe->fs->num_outputs; i++) { - switch (qss->stage.softpipe->fs->output_semantic_name[i]) { + for (i = 0; i < qss->stage.softpipe->fs->shader.num_outputs; i++) { + switch (qss->stage.softpipe->fs->shader.output_semantic_name[i]) { case TGSI_SEMANTIC_POSITION: qss->depthOutSlot = i; break; @@ -190,9 +193,9 @@ static void shade_begin(struct quad_stage *qs) } -static void shade_destroy(struct quad_stage *qs) -{ - free( qs ); +static void shade_destroy(struct quad_stage *qs) +{ + free( qs ); } diff --git a/src/mesa/pipe/softpipe/sp_state.h b/src/mesa/pipe/softpipe/sp_state.h index 61532bcdebb..676ad06bfc5 100644 --- a/src/mesa/pipe/softpipe/sp_state.h +++ b/src/mesa/pipe/softpipe/sp_state.h @@ -33,6 +33,17 @@ #include "pipe/p_state.h" +#include "x86/rtasm/x86sse.h" + +/** + * Softpipe fs state is derived from pipe_shader_state. + */ +struct sp_fragment_shader_state { + struct pipe_shader_state shader; +#if defined(__i386__) || defined(__386__) + struct x86_function sse2_program; +#endif +}; void * softpipe_create_alpha_test_state(struct pipe_context *, diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c index 5547c849ac9..86aa80c0fca 100644 --- a/src/mesa/pipe/softpipe/sp_state_fs.c +++ b/src/mesa/pipe/softpipe/sp_state_fs.c @@ -43,16 +43,14 @@ void * softpipe_create_fs_state(struct pipe_context *pipe, * that now. */ - struct pipe_shader_state *state = malloc(sizeof(struct pipe_shader_state)); - memcpy(state, templ, sizeof(struct pipe_shader_state)); + struct sp_fragment_shader_state *state = malloc(sizeof(struct sp_fragment_shader_state)); + state->shader = *templ; #if defined(__i386__) || defined(__386__) if (softpipe->use_sse) { x86_init_func( &state->sse2_program ); - tgsi_emit_sse2_fs( state->tokens, &state->sse2_program ); - - state->executable = (void *)x86_get_func( &state->sse2_program ); + tgsi_emit_sse2_fs( state->shader.tokens, &state->sse2_program ); } #endif @@ -63,7 +61,7 @@ void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs) { struct softpipe_context *softpipe = softpipe_context(pipe); - softpipe->fs = (struct pipe_shader_state *)fs; + softpipe->fs = (struct sp_fragment_shader_state *) fs; softpipe->dirty |= SP_NEW_FS; } @@ -72,7 +70,7 @@ void softpipe_delete_fs_state(struct pipe_context *pipe, void *shader) { #if defined(__i386__) || defined(__386__) - struct pipe_shader_state *state = shader; + struct sp_fragment_shader_state *state = shader; x86_release_func( &state->sse2_program ); #endif