draw: Add EMIT_4UB_BGRA format
authorJakob Bornecrantz <wallbraker@gmail.com>
Thu, 25 Mar 2010 12:45:42 +0000 (13:45 +0100)
committerJakob Bornecrantz <wallbraker@gmail.com>
Fri, 26 Mar 2010 00:21:52 +0000 (01:21 +0100)
Needed for i915g, also fixed swizzle in draw_vs_aos_io.

src/gallium/auxiliary/draw/draw_vertex.c
src/gallium/auxiliary/draw/draw_vertex.h
src/gallium/auxiliary/draw/draw_vs_aos_io.c
src/gallium/drivers/i915/i915_prim_emit.c
src/gallium/drivers/i915/i915_state_derived.c
src/gallium/drivers/nvfx/nvfx_draw.c

index 18921ad71793a31bd6d3e1d5ea6f2a93e971d990..a4f5e882c0a9137f5c5b467becfaab798cf16e54 100644 (file)
@@ -102,6 +102,13 @@ draw_dump_emitted_vertex(const struct vertex_info *vinfo, const uint8_t *data)
          debug_printf("%u ", *data++);
          debug_printf("%u ", *data++);
          break;
+      case EMIT_4UB_BGRA:
+         debug_printf("EMIT_4UB_BGRA:\t");
+         debug_printf("%u ", *data++);
+         debug_printf("%u ", *data++);
+         debug_printf("%u ", *data++);
+         debug_printf("%u ", *data++);
+         break;
       default:
          assert(0);
       }
index 24c5a48b2ef4642bb9e6d12f38689c16ffdf2838..ca272371267a957aab5f23dbd11892ca03c1515a 100644 (file)
@@ -54,7 +54,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
 };
 
 
@@ -157,6 +158,8 @@ static INLINE unsigned draw_translate_vinfo_format(enum attrib_emit emit)
       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;
@@ -179,6 +182,8 @@ static INLINE unsigned draw_translate_vinfo_size(enum attrib_emit emit)
       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;
index ece1ddde0cbadcc88ec9e10fe2aa49a88263c7b2..8f8bbe7cb88265c46e7be26786085856cce1d86b 100644 (file)
@@ -401,13 +401,11 @@ static boolean emit_output( struct aos_compilation *cp,
       emit_store_R32G32B32A32(cp, ptr, dataXMM);
       break;
    case EMIT_4UB:
-      if (1) {
-         emit_swizzle(cp, dataXMM, dataXMM, SHUF(Z,Y,X,W));
-         emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
-      }
-      else {
-         emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
-      }
+      emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
+      break;
+   case EMIT_4UB_BGRA:
+      emit_swizzle(cp, dataXMM, dataXMM, SHUF(Z,Y,X,W));
+      emit_store_R8G8B8A8_UNORM(cp, ptr, dataXMM);
       break;
    default:
       AOS_ERROR(cp, "unhandled output format");
index d9a5c40ab9785fd900e56e3b5d81ccde67a27a1f..dd997e2cf482905cfeccc49eb9e978436e2078d2 100644 (file)
@@ -102,6 +102,13 @@ emit_hw_vertex( struct i915_context *i915,
          count += 4;
          break;
       case EMIT_4UB:
+         OUT_BATCH( pack_ub4(float_to_ubyte( attrib[0] ),
+                             float_to_ubyte( attrib[1] ),
+                             float_to_ubyte( attrib[2] ),
+                             float_to_ubyte( attrib[3] )) );
+         count += 1;
+         break;
+      case EMIT_4UB_BGRA:
          OUT_BATCH( pack_ub4(float_to_ubyte( attrib[2] ),
                              float_to_ubyte( attrib[1] ),
                              float_to_ubyte( attrib[0] ),
index 0eb1e3f91a44fbc555aa4bc7ae36041d469bfe60..4da46772b5d8e049b806214b37e3b58c54474a97 100644 (file)
@@ -101,14 +101,14 @@ static void calculate_vertex_layout( struct i915_context *i915 )
    /* primary color */
    if (colors[0]) {
       src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 0);
-      draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src);
+      draw_emit_vertex_attr(&vinfo, EMIT_4UB_BGRA, colorInterp, src);
       vinfo.hwfmt[0] |= S4_VFMT_COLOR;
    }
 
    /* secondary color */
    if (colors[1]) {
       src = draw_find_shader_output(i915->draw, TGSI_SEMANTIC_COLOR, 1);
-      draw_emit_vertex_attr(&vinfo, EMIT_4UB, colorInterp, src);
+      draw_emit_vertex_attr(&vinfo, EMIT_4UB_BGRA, colorInterp, src);
       vinfo.hwfmt[0] |= S4_VFMT_SPEC_FOG;
    }
 
index 5379b29efd11db676089b6b54a385fb3c5f40d4e..68e50a36479dec593cf3718b7c23254fbcc5d0ef 100644 (file)
@@ -79,6 +79,12 @@ nvfx_render_vertex(struct nvfx_context *nvfx, const struct vertex_header *v)
                                            float_to_ubyte(v->data[idx][1]),
                                            float_to_ubyte(v->data[idx][2]),
                                            float_to_ubyte(v->data[idx][3])));
+               case EMIT_4UB_BGRA:
+                       BEGIN_RING(chan, eng3d, NV34TCL_VTX_ATTR_4UB(hw), 1);
+                       OUT_RING  (chan, pack_ub4(float_to_ubyte(v->data[idx][2]),
+                                           float_to_ubyte(v->data[idx][1]),
+                                           float_to_ubyte(v->data[idx][0]),
+                                           float_to_ubyte(v->data[idx][3])));
                        break;
                default:
                        assert(0);