Merge commit 'origin/master' into gallium-0.2
[mesa.git] / src / gallium / auxiliary / translate / translate_sse.c
index e587e5afece9e636bbe13939267bbeb4c6ab50be..7955186e168e803b6cd1611cfdaa0eb8ccd34245 100644 (file)
  */
 
 
+#include "pipe/p_config.h"
 #include "pipe/p_compiler.h"
-#include "pipe/p_util.h"
+#include "util/u_memory.h"
 #include "util/u_simple_list.h"
 
 #include "translate.h"
 
 
-#if defined(__i386__) || defined(__386__) || defined(i386)
+#if defined(PIPE_ARCH_X86)
 
 #include "rtasm/rtasm_cpu.h"
 #include "rtasm/rtasm_x86sse.h"
 #define W    3
 
 
-#ifdef WIN32
-#define RTASM __cdecl
-#else
-#define RTASM
-#endif
-
-typedef void (RTASM *run_func)( struct translate *translate,
-                                unsigned start,
-                                unsigned count,
-                                void *output_buffer );
-
-typedef void (RTASM *run_elts_func)( struct translate *translate,
-                                     const unsigned *elts,
+typedef void (PIPE_CDECL *run_func)( struct translate *translate,
+                                     unsigned start,
                                      unsigned count,
                                      void *output_buffer );
 
+typedef void (PIPE_CDECL *run_elts_func)( struct translate *translate,
+                                          const unsigned *elts,
+                                          unsigned count,
+                                          void *output_buffer );
+
 
 
 struct translate_sse {
@@ -315,7 +310,7 @@ static void get_src_ptr( struct translate_sse *p,
 static void emit_swizzle( struct translate_sse *p,
                          struct x86_reg dest,
                          struct x86_reg src,
-                         unsigned shuffle )
+                         unsigned char shuffle )
 {
    sse_shufps(p->func, dest, src, shuffle);
 }
@@ -404,7 +399,7 @@ static boolean build_vertex_emit( struct translate_sse *p,
    struct x86_reg srcEAX       = x86_make_reg(file_REG32, reg_CX);
    struct x86_reg countEBP     = x86_make_reg(file_REG32, reg_BP);
    struct x86_reg translateESI = x86_make_reg(file_REG32, reg_SI);
-   uint8_t *fixup, *label;
+   int fixup, label;
    unsigned j;
 
    p->func = func;
@@ -472,13 +467,7 @@ static boolean build_vertex_emit( struct translate_sse *p,
    x86_lea(p->func, vertexECX, x86_make_disp(vertexECX, p->translate.key.output_stride));
 
    /* Incr index
-    */   /* Emit code for each of the attributes.  Currently routes
-    * everything through SSE registers, even when it might be more
-    * efficient to stick with regular old x86.  No optimization or
-    * other tricks - enough new ground to cover here just getting
-    * things working.
-    */
-
+    */ 
    if (linear) {
       x86_inc(p->func, idxEBX);
    } 
@@ -546,7 +535,7 @@ static void translate_sse_release( struct translate *translate )
    FREE(p);
 }
 
-static void translate_sse_run_elts( struct translate *translate,
+static void PIPE_CDECL translate_sse_run_elts( struct translate *translate,
                              const unsigned *elts,
                              unsigned count,
                              void *output_buffer )
@@ -559,7 +548,7 @@ static void translate_sse_run_elts( struct translate *translate,
                    output_buffer );
 }
 
-static void translate_sse_run( struct translate *translate,
+static void PIPE_CDECL translate_sse_run( struct translate *translate,
                         unsigned start,
                         unsigned count,
                         void *output_buffer )
@@ -597,7 +586,12 @@ struct translate *translate_sse2_create( const struct translate_key *key )
       goto fail;
 
    p->gen_run = (run_func)x86_get_func(&p->linear_func);
+   if (p->gen_run == NULL)
+      goto fail;
+
    p->gen_run_elts = (run_elts_func)x86_get_func(&p->elt_func);
+   if (p->gen_run_elts == NULL)
+      goto fail;
 
    return &p->translate;
 
@@ -612,7 +606,7 @@ struct translate *translate_sse2_create( const struct translate_key *key )
 
 #else
 
-void translate_create_sse( const struct translate_key *key )
+struct translate *translate_sse2_create( const struct translate_key *key )
 {
    return NULL;
 }