gallium: pipe/p_inlines.h -> util/u_inlines.h
[mesa.git] / src / gallium / drivers / svga / svga_state_fs.c
index 1902b0106bafcc93678aa3f56b3787459d094ed5..adc7120217b400df007cbb4d75aff4c18759de1d 100644 (file)
@@ -23,7 +23,7 @@
  *
  **********************************************************/
 
-#include "pipe/p_inlines.h"
+#include "util/u_inlines.h"
 #include "pipe/p_defines.h"
 #include "util/u_math.h"
 #include "util/u_bitmask.h"
 static INLINE int compare_fs_keys( const struct svga_fs_compile_key *a,
                                    const struct svga_fs_compile_key *b )
 {
-   unsigned keysize = svga_fs_key_size( a );
-   return memcmp( a, b, keysize );
+   unsigned keysize_a = svga_fs_key_size( a );
+   unsigned keysize_b = svga_fs_key_size( b );
+
+   if (keysize_a != keysize_b) {
+      return (int)(keysize_a - keysize_b);
+   }
+   return memcmp( a, b, keysize_a );
 }
 
 
@@ -67,7 +72,7 @@ static enum pipe_error compile_fs( struct svga_context *svga,
                                    struct svga_shader_result **out_result )
 {
    struct svga_shader_result *result;
-   enum pipe_error ret;
+   enum pipe_error ret = PIPE_ERROR;
 
    result = svga_translate_fragment_program( fs, key );
    if (result == NULL) {
@@ -76,8 +81,10 @@ static enum pipe_error compile_fs( struct svga_context *svga,
    }
 
    result->id = util_bitmask_add(svga->fs_bm);
-   if(result->id == UTIL_BITMASK_INVALID_INDEX)
+   if(result->id == UTIL_BITMASK_INVALID_INDEX) {
+      ret = PIPE_ERROR_OUT_OF_MEMORY;
       goto fail;
+   }
 
    ret = SVGA3D_DefineShader(svga->swc, 
                              result->id,
@@ -268,16 +275,13 @@ static int emit_hw_fs( struct svga_context *svga,
    assert(id != SVGA3D_INVALID_ID);
 
    if (result != svga->state.hw_draw.fs) {
-      if (id != svga->state.hw_draw.shader_id[PIPE_SHADER_FRAGMENT]) {
-         ret = SVGA3D_SetShader(svga->swc,
-                                SVGA3D_SHADERTYPE_PS,
-                                id );
-         if (ret)
-            return ret;
-      }
+      ret = SVGA3D_SetShader(svga->swc,
+                             SVGA3D_SHADERTYPE_PS,
+                             id );
+      if (ret)
+         return ret;
 
       svga->dirty |= SVGA_NEW_FS_RESULT;
-      svga->state.hw_draw.shader_id[PIPE_SHADER_FRAGMENT] = id;
       svga->state.hw_draw.fs = result;      
    }