summaryrefslogtreecommitdiff
path: root/src/mesa/pipe
diff options
context:
space:
mode:
Diffstat (limited to 'src/mesa/pipe')
-rw-r--r--src/mesa/pipe/draw/draw_private.h3
-rw-r--r--src/mesa/pipe/draw/draw_vertex_shader.c16
-rw-r--r--src/mesa/pipe/p_state.h5
-rw-r--r--src/mesa/pipe/softpipe/sp_context.c6
-rw-r--r--src/mesa/pipe/softpipe/sp_context.h2
-rwxr-xr-xsrc/mesa/pipe/softpipe/sp_quad_fs.c3
-rw-r--r--src/mesa/pipe/softpipe/sp_state_fs.c20
7 files changed, 45 insertions, 10 deletions
diff --git a/src/mesa/pipe/draw/draw_private.h b/src/mesa/pipe/draw/draw_private.h
index b3f1c4d23e..79b2176c59 100644
--- a/src/mesa/pipe/draw/draw_private.h
+++ b/src/mesa/pipe/draw/draw_private.h
@@ -124,9 +124,6 @@ struct draw_stage
*/
struct draw_vertex_shader {
const struct pipe_shader_state *state;
-#if defined(__i386__) || defined(__386__)
- struct x86_function sse2_program;
-#endif
};
/**
diff --git a/src/mesa/pipe/draw/draw_vertex_shader.c b/src/mesa/pipe/draw/draw_vertex_shader.c
index 49ff3b32ff..e99537f16c 100644
--- a/src/mesa/pipe/draw/draw_vertex_shader.c
+++ b/src/mesa/pipe/draw/draw_vertex_shader.c
@@ -214,12 +214,13 @@ draw_create_vertex_shader(struct draw_context *draw,
vs->state = shader;
#if defined(__i386__) || defined(__386__)
- x86_init_func(&vs->sse2_program);
-
if (draw->use_sse) {
- tgsi_emit_sse2(shader->tokens, &vs->sse2_program);
- ((struct pipe_shader_state*)(vs->state))->executable =
- x86_get_func(&vs->sse2_program);
+ x86_init_func( &shader->sse2_program );
+
+ tgsi_emit_sse2( shader->tokens, &shader->sse2_program );
+
+ ((struct pipe_shader_state *)shader)->executable = (void *)
+ x86_get_func( &shader->sse2_program );
}
#endif
@@ -243,9 +244,12 @@ void draw_delete_vertex_shader(struct draw_context *draw,
void *vcso)
{
struct draw_vertex_shader *vs = (struct draw_vertex_shader*)(vcso);
+
#if defined(__i386__) || defined(__386__)
- x86_release_func(&vs->sse2_program);
+ x86_release_func(&vs->state->sse2_program);
#endif
+
+ free(vs->state);
free(vcso);
}
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index b4fc01bfc5..ac9d7009cc 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -40,6 +40,8 @@
#include "p_compiler.h"
+#include "x86/rtasm/x86sse.h"
+
/**
* Implementation limits
*/
@@ -143,6 +145,9 @@ struct pipe_constant_buffer {
struct pipe_shader_state {
const struct tgsi_token *tokens;
+#if defined(__i386__) || defined(__386__)
+ struct x86_function sse2_program;
+#endif
void *executable;
/** These fields somewhat constitute the shader "signature" */
diff --git a/src/mesa/pipe/softpipe/sp_context.c b/src/mesa/pipe/softpipe/sp_context.c
index 610e7ad689..daccc8fe23 100644
--- a/src/mesa/pipe/softpipe/sp_context.c
+++ b/src/mesa/pipe/softpipe/sp_context.c
@@ -249,6 +249,12 @@ struct pipe_context *softpipe_create( struct pipe_winsys *pipe_winsys,
{
struct softpipe_context *softpipe = CALLOC_STRUCT(softpipe_context);
+#if defined(__i386__) || defined(__386__)
+ softpipe->use_sse = getenv("GALLIUM_SSE") != NULL;
+#else
+ softpipe->use_sse = false;
+#endif
+
softpipe->pipe.winsys = pipe_winsys;
softpipe->pipe.destroy = softpipe_destroy;
diff --git a/src/mesa/pipe/softpipe/sp_context.h b/src/mesa/pipe/softpipe/sp_context.h
index ccf29b5683..4f429e8139 100644
--- a/src/mesa/pipe/softpipe/sp_context.h
+++ b/src/mesa/pipe/softpipe/sp_context.h
@@ -154,6 +154,8 @@ struct softpipe_context {
struct draw_stage *vbuf;
struct pipe_surface *cbuf; /**< current color buffer (one of cbufs) */
+
+ int use_sse : 1;
};
diff --git a/src/mesa/pipe/softpipe/sp_quad_fs.c b/src/mesa/pipe/softpipe/sp_quad_fs.c
index f394c587dc..a8c25c4868 100755
--- a/src/mesa/pipe/softpipe/sp_quad_fs.c
+++ b/src/mesa/pipe/softpipe/sp_quad_fs.c
@@ -103,7 +103,8 @@ shade_quad(
machine->Inputs[0].xyzw[1].f[3] = fy + 1.0f;
/* run shader */
- if( softpipe->fs->executable != NULL ) {
+ /* 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;
func(
machine->Inputs,
diff --git a/src/mesa/pipe/softpipe/sp_state_fs.c b/src/mesa/pipe/softpipe/sp_state_fs.c
index 88d9bd9716..5547c849ac 100644
--- a/src/mesa/pipe/softpipe/sp_state_fs.c
+++ b/src/mesa/pipe/softpipe/sp_state_fs.c
@@ -31,17 +31,31 @@
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
#include "pipe/draw/draw_context.h"
+#include "pipe/tgsi/exec/tgsi_core.h"
void * softpipe_create_fs_state(struct pipe_context *pipe,
const struct pipe_shader_state *templ)
{
+ struct softpipe_context *softpipe = softpipe_context(pipe);
+
/* Decide whether we'll be codegenerating this shader and if so do
* that now.
*/
struct pipe_shader_state *state = malloc(sizeof(struct pipe_shader_state));
memcpy(state, templ, sizeof(struct pipe_shader_state));
+
+#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 );
+ }
+#endif
+
return state;
}
@@ -57,6 +71,12 @@ void softpipe_bind_fs_state(struct pipe_context *pipe, void *fs)
void softpipe_delete_fs_state(struct pipe_context *pipe,
void *shader)
{
+#if defined(__i386__) || defined(__386__)
+ struct pipe_shader_state *state = shader;
+
+ x86_release_func( &state->sse2_program );
+#endif
+
free(shader);
}