draw: Add EMIT_4UB_BGRA format
Needed for i915g, also fixed swizzle in draw_vs_aos_io.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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");
|
||||
|
||||
@@ -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] ),
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user