Enable SSE2 for fragment shaders.

This commit is contained in:
michal 2007-10-27 14:05:13 +01:00
parent 31b4b26108
commit 1ab8f6e696
4 changed files with 29 additions and 17 deletions

View file

@ -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;

View file

@ -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 );
}

View file

@ -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 *,

View file

@ -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