util: Reorder format tests -- group by format.
[mesa.git] / src / gallium / auxiliary / util / u_simple_shaders.c
index 8172ead0201e836548178033f762dabbfa2ef680..019dda767d0e0f9d96be6aab508b40c7773f3785 100644 (file)
 #include "pipe/p_context.h"
 #include "pipe/p_shader_tokens.h"
 #include "util/u_simple_shaders.h"
+#include "util/u_debug.h"
 #include "tgsi/tgsi_ureg.h"
 
 
 
 /**
  * Make simple vertex pass-through shader.
+ * \param num_attribs  number of attributes to pass through
+ * \param semantic_names  array of semantic names for each attribute
+ * \param semantic_indexes  array of semantic indexes for each attribute
  */
 void *
 util_make_vertex_passthrough_shader(struct pipe_context *pipe,
                                     uint num_attribs,
                                     const uint *semantic_names,
                                     const uint *semantic_indexes)
-                                    
 {
    struct ureg_program *ureg;
    uint i;
@@ -78,8 +81,6 @@ util_make_vertex_passthrough_shader(struct pipe_context *pipe,
 }
 
 
-
-
 /**
  * Make simple fragment texture shader:
  *  IMM {0,0,0,1}                         // (if writemask != 0xf)
@@ -125,6 +126,12 @@ util_make_fragment_tex_shader_writemask(struct pipe_context *pipe,
    return ureg_create_shader_and_destroy( ureg, pipe );
 }
 
+
+/**
+ * Make a simple fragment shader that sets the output color to a color
+ * taken from a texture.
+ * \param tex_target  one of PIPE_TEXTURE_x
+ */
 void *
 util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target )
 {
@@ -133,6 +140,7 @@ util_make_fragment_tex_shader(struct pipe_context *pipe, unsigned tex_target )
                                                    TGSI_WRITEMASK_XYZW );
 }
 
+
 /**
  * Make a simple fragment texture shader which reads an X component from
  * a texture and writes it as depth.
@@ -177,6 +185,7 @@ util_make_fragment_tex_shader_writedepth(struct pipe_context *pipe,
    return ureg_create_shader_and_destroy( ureg, pipe );
 }
 
+
 /**
  * Make simple fragment color pass-through shader.
  */
@@ -186,15 +195,19 @@ util_make_fragment_passthrough_shader(struct pipe_context *pipe)
    return util_make_fragment_clonecolor_shader(pipe, 1);
 }
 
+
+/**
+ * Make a fragment shader that copies the input color to N output colors.
+ */
 void *
 util_make_fragment_clonecolor_shader(struct pipe_context *pipe, int num_cbufs)
 {
    struct ureg_program *ureg;
    struct ureg_src src;
-   struct ureg_dst dst[8];
+   struct ureg_dst dst[PIPE_MAX_COLOR_BUFS];
    int i;
 
-   assert(num_cbufs <= 8);
+   assert(num_cbufs <= PIPE_MAX_COLOR_BUFS);
 
    ureg = ureg_create( TGSI_PROCESSOR_FRAGMENT );
    if (ureg == NULL)