summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormichal <michal@michal-laptop.(none)>2007-08-24 17:51:12 +0100
committermichal <michal@michal-laptop.(none)>2007-08-24 17:51:12 +0100
commit4fd7bc00f06a98e1db2ad886a13566f19895e3c0 (patch)
tree1bc1703dd3d8cc5ea14aa6e5605619e266d8361f
parent2c7b74725bfbd0a022ebfada4736d6cb8ac28047 (diff)
Hook-up SSE2 to VS.
-rw-r--r--src/mesa/pipe/draw/draw_prim.c31
-rw-r--r--src/mesa/pipe/p_state.h1
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_exec.c29
-rw-r--r--src/mesa/pipe/tgsi/exec/tgsi_exec.h7
-rwxr-xr-xsrc/mesa/pipe/tgsi/exec/tgsi_sse2.c4
-rw-r--r--src/mesa/state_tracker/st_atom_vs.c12
-rw-r--r--src/mesa/state_tracker/st_cb_program.c14
-rw-r--r--src/mesa/state_tracker/st_program.h6
8 files changed, 65 insertions, 39 deletions
diff --git a/src/mesa/pipe/draw/draw_prim.c b/src/mesa/pipe/draw/draw_prim.c
index 2d613754e8..09616cf315 100644
--- a/src/mesa/pipe/draw/draw_prim.c
+++ b/src/mesa/pipe/draw/draw_prim.c
@@ -113,6 +113,21 @@ fetch_attrib4(const void *ptr, unsigned format, float attrib[4])
}
}
+#if !defined(XSTDCALL)
+#if defined(WIN32)
+#define XSTDCALL __stdcall
+#else
+#define XSTDCALL
+#endif
+#endif
+
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+typedef void (XSTDCALL *sse2_function)(
+ const struct tgsi_exec_vector *input,
+ struct tgsi_exec_vector *output,
+ float (*constant)[4],
+ struct tgsi_exec_vector *temporary );
+#endif
/**
* Transform vertices with the current vertex program/shader
@@ -224,7 +239,21 @@ run_vertex_program(struct draw_context *draw,
#endif
/* run shader */
- tgsi_exec_machine_run( &machine );
+ if( draw->vertex_shader.executable != NULL ) {
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ sse2_function func = (sse2_function) draw->vertex_shader.executable;
+ func(
+ machine.Inputs,
+ machine.Outputs,
+ machine.Consts,
+ machine.Temps );
+#else
+ assert( 0 );
+#endif
+ }
+ else {
+ tgsi_exec_machine_run( &machine );
+ }
#if 0
for (i = 0; i < 4; i++) {
diff --git a/src/mesa/pipe/p_state.h b/src/mesa/pipe/p_state.h
index e562a8d058..25e5861e1e 100644
--- a/src/mesa/pipe/p_state.h
+++ b/src/mesa/pipe/p_state.h
@@ -128,6 +128,7 @@ struct pipe_shader_state {
unsigned inputs_read; /**< TGSI_ATTRIB_ bits */
unsigned outputs_written; /**< TGSI_ATTRIB_ bits */
const struct tgsi_token *tokens;
+ void *executable;
};
struct pipe_depth_state
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.c b/src/mesa/pipe/tgsi/exec/tgsi_exec.c
index a1f46712b4..793f8bc0f6 100644
--- a/src/mesa/pipe/tgsi/exec/tgsi_exec.c
+++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.c
@@ -85,11 +85,6 @@ tgsi_exec_machine_init(
mach->Temps = (struct tgsi_exec_vector *) tgsi_align_128bit( mach->_Temps);
mach->Addrs = &mach->Temps[TGSI_EXEC_NUM_TEMPS];
-#if XXX_SSE
- tgsi_emit_sse (tokens,
- &mach->Function);
-#endif
-
/* Setup constants. */
for( i = 0; i < 4; i++ ) {
mach->Temps[TEMP_0_I].xyzw[TEMP_0_C].u[i] = 0x00000000;
@@ -967,6 +962,7 @@ store_dest(
default:
assert( 0 );
+ return;
}
switch (inst->Instruction.Saturate)
@@ -2226,20 +2222,6 @@ exec_instruction(
}
}
-
-#if !defined(XSTDCALL)
-#if defined(WIN32)
-#define XSTDCALL __stdcall
-#else
-#define XSTDCALL
-#endif
-#endif
-
-typedef void (XSTDCALL *fp_function) (const struct tgsi_exec_vector *input,
- struct tgsi_exec_vector *output,
- GLfloat (*constant)[4],
- struct tgsi_exec_vector *temporary);
-
void
tgsi_exec_machine_run2(
struct tgsi_exec_machine *mach,
@@ -2251,16 +2233,7 @@ tgsi_exec_machine_run2(
#endif
#if XXX_SSE
- fp_function function;
-
mach->Temps[TEMP_KILMASK_I].xyzw[TEMP_KILMASK_C].u[0] = 0;
-
- function = (fp_function) x86_get_func (&mach->Function);
-
- function (mach->Inputs,
- mach->Outputs,
- mach->Consts,
- mach->Temps);
#else
struct tgsi_parse_context parse;
GLuint k;
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_exec.h b/src/mesa/pipe/tgsi/exec/tgsi_exec.h
index e5e8c3608e..d50f786029 100644
--- a/src/mesa/pipe/tgsi/exec/tgsi_exec.h
+++ b/src/mesa/pipe/tgsi/exec/tgsi_exec.h
@@ -3,10 +3,6 @@
#include "pipe/p_compiler.h"
-#if 0
-#include "x86/rtasm/x86sse.h"
-#endif
-
#if defined __cplusplus
extern "C" {
#endif // defined __cplusplus
@@ -157,9 +153,6 @@ struct tgsi_exec_machine
const struct tgsi_interp_coef *InterpCoefs;
struct tgsi_exec_cond_stack CondStack;
-#if XXX_SSE
- struct x86_function Function;
-#endif
};
void
diff --git a/src/mesa/pipe/tgsi/exec/tgsi_sse2.c b/src/mesa/pipe/tgsi/exec/tgsi_sse2.c
index 359775fdfb..d89bb19970 100755
--- a/src/mesa/pipe/tgsi/exec/tgsi_sse2.c
+++ b/src/mesa/pipe/tgsi/exec/tgsi_sse2.c
@@ -1659,13 +1659,13 @@ emit_instruction(
}
unsigned
-tgsi_emit_sse(
+tgsi_emit_sse2(
struct tgsi_token *tokens,
struct x86_function *func )
{
struct tgsi_parse_context parse;
- x86_init_func( func );
+ func->csr = func->store;
x86_mov(
func,
diff --git a/src/mesa/state_tracker/st_atom_vs.c b/src/mesa/state_tracker/st_atom_vs.c
index 7420a49520..a326c12608 100644
--- a/src/mesa/state_tracker/st_atom_vs.c
+++ b/src/mesa/state_tracker/st_atom_vs.c
@@ -38,7 +38,7 @@
#include "pipe/p_defines.h"
#include "pipe/p_winsys.h"
#include "pipe/tgsi/mesa/mesa_to_tgsi.h"
-#include "pipe/tgsi/exec/tgsi_dump.h"
+#include "pipe/tgsi/exec/tgsi_core.h"
#include "st_context.h"
#include "st_atom.h"
@@ -56,6 +56,12 @@ static void compile_vs( struct st_context *st,
if (TGSI_DEBUG)
tgsi_dump( vs->tokens, TGSI_DUMP_VERBOSE );
+
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ tgsi_emit_sse2(
+ vs->tokens,
+ &vs->sse2_program );
+#endif
}
@@ -121,6 +127,10 @@ static void update_vs( struct st_context *st )
= tgsi_mesa_translate_vertex_output_mask(vp->Base.Base.OutputsWritten);
vs.tokens = &vp->tokens[0];
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ vs.executable = (void *) x86_get_func( &vp->sse2_program );
+#endif
+
if (memcmp(&vs, &st->state.vs, sizeof(vs)) != 0 ||
vp->dirty)
{
diff --git a/src/mesa/state_tracker/st_cb_program.c b/src/mesa/state_tracker/st_cb_program.c
index d0344efa0c..25da720d86 100644
--- a/src/mesa/state_tracker/st_cb_program.c
+++ b/src/mesa/state_tracker/st_cb_program.c
@@ -77,6 +77,10 @@ static struct gl_program *st_new_program( GLcontext *ctx,
prog->id = program_id++;
prog->dirty = 1;
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ x86_init_func( &prog->sse2_program );
+#endif
+
return _mesa_init_vertex_program( ctx,
&prog->Base,
target,
@@ -105,6 +109,16 @@ static struct gl_program *st_new_program( GLcontext *ctx,
static void st_delete_program( GLcontext *ctx,
struct gl_program *prog )
{
+ switch( prog->Target ) {
+ case GL_VERTEX_PROGRAM_ARB:
+ {
+ struct st_vertex_program *p = (struct st_vertex_program *) prog;
+
+ x86_release_func( &p->sse2_program );
+ break;
+ }
+
+ }
_mesa_delete_program( ctx, prog );
}
diff --git a/src/mesa/state_tracker/st_program.h b/src/mesa/state_tracker/st_program.h
index e7eb7a8e3f..883953399c 100644
--- a/src/mesa/state_tracker/st_program.h
+++ b/src/mesa/state_tracker/st_program.h
@@ -36,6 +36,7 @@
#include "mtypes.h"
#include "pipe/tgsi/exec/tgsi_token.h"
+#include "x86/rtasm/x86sse.h"
#define ST_FP_MAX_TOKENS 1024
@@ -83,6 +84,11 @@ struct st_vertex_program
struct tgsi_token tokens[ST_FP_MAX_TOKENS];
GLboolean dirty;
+
+#if defined(USE_X86_ASM) || defined(SLANG_X86)
+ struct x86_function sse2_program;
+#endif
+
#if 0
struct pipe_constant_buffer constants;
#endif