gallivm: fix indirect addressing of temps in soa mode
[mesa.git] / src / gallium / auxiliary / draw / draw_vertex.h
index 8c3c7befbc76795d3030637092e35df99245ec41..c87c3d84ce2a91b3199777c47db3478760f2baeb 100644 (file)
@@ -42,6 +42,7 @@
 #include "pipe/p_compiler.h"
 #include "pipe/p_state.h"
 #include "util/u_debug.h"
+#include "util/u_memory.h"
 
 
 /**
@@ -54,7 +55,8 @@ enum attrib_emit {
    EMIT_2F,
    EMIT_3F,
    EMIT_4F,
-   EMIT_4UB  /**< XXX may need variations for RGBA vs BGRA, etc */
+   EMIT_4UB, /**< is RGBA like the rest */
+   EMIT_4UB_BGRA
 };
 
 
@@ -86,7 +88,7 @@ struct vertex_info
       unsigned interp_mode:4;      /**< INTERP_x */
       unsigned emit:4;             /**< EMIT_x */
       unsigned src_index:8;          /**< map to post-xform attribs */
-   } attrib[PIPE_MAX_SHADER_INPUTS];
+   } attrib[PIPE_MAX_SHADER_OUTPUTS];
 };
 
 static INLINE size_t
@@ -126,7 +128,7 @@ draw_emit_vertex_attr(struct vertex_info *vinfo,
                       uint src_index)
 {
    const uint n = vinfo->num_attribs;
-   assert(n < PIPE_MAX_SHADER_INPUTS);
+   assert(n < Elements(vinfo->attrib));
    vinfo->attrib[n].emit = emit;
    vinfo->attrib[n].interp_mode = interp;
    vinfo->attrib[n].src_index = src_index;
@@ -141,9 +143,11 @@ void draw_dump_emitted_vertex(const struct vertex_info *vinfo,
                               const uint8_t *data);
 
 
-static INLINE unsigned draw_translate_vinfo_format(unsigned format )
+static INLINE enum pipe_format draw_translate_vinfo_format(enum attrib_emit emit)
 {
-   switch (format) {
+   switch (emit) {
+   case EMIT_OMIT:
+      return PIPE_FORMAT_NONE;
    case EMIT_1F:
    case EMIT_1F_PSIZE:
       return PIPE_FORMAT_R32_FLOAT;
@@ -155,10 +159,36 @@ static INLINE unsigned draw_translate_vinfo_format(unsigned format )
       return PIPE_FORMAT_R32G32B32A32_FLOAT;
    case EMIT_4UB:
       return PIPE_FORMAT_R8G8B8A8_UNORM;
+   case EMIT_4UB_BGRA:
+      return PIPE_FORMAT_B8G8R8A8_UNORM;
    default:
+      assert(!"unexpected format");
       return PIPE_FORMAT_NONE;
    }
 }
 
+static INLINE unsigned draw_translate_vinfo_size(enum attrib_emit emit)
+{
+   switch (emit) {
+   case EMIT_OMIT:
+      return 0;
+   case EMIT_1F:
+   case EMIT_1F_PSIZE:
+      return 1 * sizeof(float);
+   case EMIT_2F:
+      return 2 * sizeof(float);
+   case EMIT_3F:
+      return 3 * sizeof(float);
+   case EMIT_4F:
+      return 4 * sizeof(float);
+   case EMIT_4UB:
+      return 4 * sizeof(unsigned char);
+   case EMIT_4UB_BGRA:
+      return 4 * sizeof(unsigned char);
+   default:
+      assert(!"unexpected format");
+      return 0;
+   }
+}
 
 #endif /* DRAW_VERTEX_H */