etnaviv: separate PE and RS formats, use only RS only for tiling
There are PE formats not supported by RS, so we can't have a single to translate both. Use RS only for same formats until we have a translate_rs_format and test the possible different format blits. Signed-off-by: Jonathan Marek <jonathan@marek.ca> Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
This commit is contained in:
committed by
Christian Gmeiner
parent
e1a86bd634
commit
d819d4b344
@@ -123,7 +123,7 @@ etna_update_blend(struct etna_context *ctx)
|
||||
uint32_t colormask;
|
||||
|
||||
if (pfb->cbufs[0] &&
|
||||
translate_rs_format_rb_swap(pfb->cbufs[0]->format)) {
|
||||
translate_pe_format_rb_swap(pfb->cbufs[0]->format)) {
|
||||
colormask = rt0->colormask & (PIPE_MASK_A | PIPE_MASK_G);
|
||||
if (rt0->colormask & PIPE_MASK_R)
|
||||
colormask |= PIPE_MASK_B;
|
||||
@@ -164,7 +164,7 @@ etna_update_blend_color(struct etna_context *ctx)
|
||||
{
|
||||
struct pipe_framebuffer_state *pfb = &ctx->framebuffer_s;
|
||||
struct compiled_blend_color *cs = &ctx->blend_color;
|
||||
bool rb_swap = (pfb->cbufs[0] && translate_rs_format_rb_swap(pfb->cbufs[0]->format));
|
||||
bool rb_swap = (pfb->cbufs[0] && translate_pe_format_rb_swap(pfb->cbufs[0]->format));
|
||||
|
||||
cs->PE_ALPHA_BLEND_COLOR =
|
||||
VIVS_PE_ALPHA_BLEND_COLOR_R(etna_cfloat_to_uint8(cs->color[rb_swap ? 2 : 0])) |
|
||||
|
||||
@@ -255,7 +255,7 @@ etna_draw_vbo(struct pipe_context *pctx, const struct pipe_draw_info *info)
|
||||
};
|
||||
|
||||
if (pfb->cbufs[0])
|
||||
key.frag_rb_swap = !!translate_rs_format_rb_swap(pfb->cbufs[0]->format);
|
||||
key.frag_rb_swap = !!translate_pe_format_rb_swap(pfb->cbufs[0]->format);
|
||||
|
||||
if (!etna_get_vs(ctx, key) || !etna_get_fs(ctx, key)) {
|
||||
BUG("compiled shaders are not okay");
|
||||
|
||||
@@ -39,19 +39,19 @@
|
||||
struct etna_format {
|
||||
unsigned vtx;
|
||||
unsigned tex;
|
||||
unsigned rs;
|
||||
unsigned pe;
|
||||
bool present;
|
||||
const unsigned char tex_swiz[4];
|
||||
};
|
||||
|
||||
#define RS_FORMAT_NONE ~0
|
||||
#define PE_FORMAT_NONE ~0
|
||||
|
||||
#define RS_FORMAT_MASK 0xf
|
||||
#define RS_FORMAT(x) ((x) & RS_FORMAT_MASK)
|
||||
#define RS_FORMAT_RB_SWAP 0x10
|
||||
#define PE_FORMAT_MASK 0x7f
|
||||
#define PE_FORMAT(x) ((x) & PE_FORMAT_MASK)
|
||||
#define PE_FORMAT_RB_SWAP 0x80
|
||||
|
||||
#define RS_FORMAT_X8B8G8R8 (RS_FORMAT_X8R8G8B8 | RS_FORMAT_RB_SWAP)
|
||||
#define RS_FORMAT_A8B8G8R8 (RS_FORMAT_A8R8G8B8 | RS_FORMAT_RB_SWAP)
|
||||
#define PE_FORMAT_X8B8G8R8 (PE_FORMAT_X8R8G8B8 | PE_FORMAT_RB_SWAP)
|
||||
#define PE_FORMAT_A8B8G8R8 (PE_FORMAT_A8R8G8B8 | PE_FORMAT_RB_SWAP)
|
||||
|
||||
#define TS_SAMPLER_FORMAT_NONE ETNA_NO_MATCH
|
||||
|
||||
@@ -67,7 +67,7 @@ struct etna_format {
|
||||
[PIPE_FORMAT_##pipe] = { \
|
||||
.vtx = FE_DATA_TYPE_##vtxfmt, \
|
||||
.tex = TEXTURE_FORMAT_##texfmt, \
|
||||
.rs = RS_FORMAT_##rsfmt, \
|
||||
.pe = PE_FORMAT_##rsfmt, \
|
||||
.present = 1, \
|
||||
.tex_swiz = texswiz, \
|
||||
}
|
||||
@@ -77,7 +77,7 @@ struct etna_format {
|
||||
[PIPE_FORMAT_##pipe] = { \
|
||||
.vtx = ETNA_NO_MATCH, \
|
||||
.tex = TEXTURE_FORMAT_##fmt, \
|
||||
.rs = RS_FORMAT_##rsfmt, \
|
||||
.pe = PE_FORMAT_##rsfmt, \
|
||||
.present = 1, \
|
||||
.tex_swiz = swiz, \
|
||||
}
|
||||
@@ -87,7 +87,7 @@ struct etna_format {
|
||||
[PIPE_FORMAT_##pipe] = { \
|
||||
.vtx = FE_DATA_TYPE_##fmt, \
|
||||
.tex = ETNA_NO_MATCH, \
|
||||
.rs = RS_FORMAT_##rsfmt, \
|
||||
.pe = PE_FORMAT_##rsfmt, \
|
||||
.present = 1, \
|
||||
}
|
||||
|
||||
@@ -118,7 +118,7 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
|
||||
|
||||
_T(L8A8_UNORM, A8L8, SWIZ(X, Y, Z, W), NONE),
|
||||
|
||||
_T(Z16_UNORM, D16, SWIZ(X, Y, Z, W), A4R4G4B4),
|
||||
_T(Z16_UNORM, D16, SWIZ(X, Y, Z, W), NONE),
|
||||
_T(B5G6R5_UNORM, R5G6B5, SWIZ(X, Y, Z, W), R5G6B5),
|
||||
_T(B5G5R5A1_UNORM, A1R5G5B5, SWIZ(X, Y, Z, W), A1R5G5B5),
|
||||
_T(B5G5R5X1_UNORM, X1R5G5B5, SWIZ(X, Y, Z, W), X1R5G5B5),
|
||||
@@ -176,8 +176,8 @@ static struct etna_format formats[PIPE_FORMAT_COUNT] = {
|
||||
V_(R10G10B10A2_USCALED, UNSIGNED_INT_10_10_10_2, NONE),
|
||||
V_(R10G10B10A2_SSCALED, INT_10_10_10_2, NONE),
|
||||
|
||||
_T(X8Z24_UNORM, D24X8, SWIZ(X, Y, Z, W), A8R8G8B8),
|
||||
_T(S8_UINT_Z24_UNORM, D24X8, SWIZ(X, Y, Z, W), A8R8G8B8),
|
||||
_T(X8Z24_UNORM, D24X8, SWIZ(X, Y, Z, W), NONE),
|
||||
_T(S8_UINT_Z24_UNORM, D24X8, SWIZ(X, Y, Z, W), NONE),
|
||||
|
||||
/* 48-bit */
|
||||
V_(R16G16B16_UNORM, UNSIGNED_SHORT, NONE),
|
||||
@@ -330,23 +330,23 @@ get_texture_swiz(enum pipe_format fmt, unsigned swizzle_r,
|
||||
}
|
||||
|
||||
uint32_t
|
||||
translate_rs_format(enum pipe_format fmt)
|
||||
translate_pe_format(enum pipe_format fmt)
|
||||
{
|
||||
if (!formats[fmt].present)
|
||||
return ETNA_NO_MATCH;
|
||||
|
||||
if (formats[fmt].rs == ETNA_NO_MATCH)
|
||||
if (formats[fmt].pe == ETNA_NO_MATCH)
|
||||
return ETNA_NO_MATCH;
|
||||
|
||||
return RS_FORMAT(formats[fmt].rs);
|
||||
return PE_FORMAT(formats[fmt].pe);
|
||||
}
|
||||
|
||||
int
|
||||
translate_rs_format_rb_swap(enum pipe_format fmt)
|
||||
translate_pe_format_rb_swap(enum pipe_format fmt)
|
||||
{
|
||||
assert(formats[fmt].present);
|
||||
|
||||
return formats[fmt].rs & RS_FORMAT_RB_SWAP;
|
||||
return formats[fmt].pe & PE_FORMAT_RB_SWAP;
|
||||
}
|
||||
|
||||
/* Return type flags for vertex element format */
|
||||
|
||||
@@ -45,10 +45,10 @@ get_texture_swiz(enum pipe_format fmt, unsigned swizzle_r,
|
||||
unsigned swizzle_g, unsigned swizzle_b, unsigned swizzle_a);
|
||||
|
||||
uint32_t
|
||||
translate_rs_format(enum pipe_format fmt);
|
||||
translate_pe_format(enum pipe_format fmt);
|
||||
|
||||
int
|
||||
translate_rs_format_rb_swap(enum pipe_format fmt);
|
||||
translate_pe_format_rb_swap(enum pipe_format fmt);
|
||||
|
||||
uint32_t
|
||||
translate_vertex_format_type(enum pipe_format fmt);
|
||||
|
||||
@@ -50,6 +50,21 @@
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/* return a RS "compatible" format for use when copying */
|
||||
static uint32_t
|
||||
etna_compatible_rs_format(enum pipe_format fmt)
|
||||
{
|
||||
/* YUYV and UYVY are blocksize 4, but 2 bytes per pixel */
|
||||
if (fmt == PIPE_FORMAT_YUYV || fmt == PIPE_FORMAT_UYVY)
|
||||
return RS_FORMAT_A4R4G4B4;
|
||||
|
||||
switch (util_format_get_blocksize(fmt)) {
|
||||
case 2: return RS_FORMAT_A4R4G4B4;
|
||||
case 4: return RS_FORMAT_A8R8G8B8;
|
||||
default: return ETNA_NO_MATCH;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
etna_compile_rs_state(struct etna_context *ctx, struct compiled_rs_state *cs,
|
||||
const struct rs_state *rs)
|
||||
@@ -602,18 +617,19 @@ etna_try_rs_blit(struct pipe_context *pctx,
|
||||
return false;
|
||||
}
|
||||
|
||||
unsigned src_format = blit_info->src.format;
|
||||
unsigned dst_format = blit_info->dst.format;
|
||||
/* Only support same format (used tiling/detiling) blits for now.
|
||||
* TODO: figure out which different-format blits are possible and test them
|
||||
* - fail if swizzle needed
|
||||
* - avoid trying to convert between float/int formats?
|
||||
*/
|
||||
if (blit_info->src.format != blit_info->dst.format)
|
||||
return false;
|
||||
|
||||
/* for a copy with same dst/src format, we can use a different format */
|
||||
if (translate_rs_format(src_format) == ETNA_NO_MATCH &&
|
||||
src_format == dst_format) {
|
||||
src_format = dst_format = etna_compatible_rs_format(src_format);
|
||||
}
|
||||
uint32_t format = etna_compatible_rs_format(blit_info->dst.format);
|
||||
if (format == ETNA_NO_MATCH)
|
||||
return false;
|
||||
|
||||
if (translate_rs_format(src_format) == ETNA_NO_MATCH ||
|
||||
translate_rs_format(dst_format) == ETNA_NO_MATCH ||
|
||||
blit_info->scissor_enable ||
|
||||
if (blit_info->scissor_enable ||
|
||||
blit_info->dst.box.depth != blit_info->src.box.depth ||
|
||||
blit_info->dst.box.depth != 1) {
|
||||
return false;
|
||||
@@ -740,7 +756,7 @@ etna_try_rs_blit(struct pipe_context *pctx,
|
||||
|
||||
/* Kick off RS here */
|
||||
etna_compile_rs_state(ctx, ©_to_screen, &(struct rs_state) {
|
||||
.source_format = translate_rs_format(src_format),
|
||||
.source_format = format,
|
||||
.source_tiling = src->layout,
|
||||
.source = src->bo,
|
||||
.source_offset = src_offset,
|
||||
@@ -749,7 +765,7 @@ etna_try_rs_blit(struct pipe_context *pctx,
|
||||
.source_padded_height = src_lev->padded_height,
|
||||
.source_ts_valid = source_ts_valid,
|
||||
.source_ts_compressed = src_lev->ts_compress_fmt >= 0,
|
||||
.dest_format = translate_rs_format(dst_format),
|
||||
.dest_format = format,
|
||||
.dest_tiling = dst->layout,
|
||||
.dest = dst->bo,
|
||||
.dest_offset = dst_offset,
|
||||
|
||||
@@ -431,7 +431,7 @@ etna_screen_is_format_supported(struct pipe_screen *pscreen,
|
||||
|
||||
if (usage & PIPE_BIND_RENDER_TARGET) {
|
||||
/* if render target, must be RS-supported format */
|
||||
if (translate_rs_format(format) != ETNA_NO_MATCH) {
|
||||
if (translate_pe_format(format) != ETNA_NO_MATCH) {
|
||||
/* Validate MSAA; number of samples must be allowed, and render target
|
||||
* must have MSAA'able format. */
|
||||
if (sample_count > 1) {
|
||||
|
||||
@@ -146,7 +146,7 @@ etna_set_framebuffer_state(struct pipe_context *pctx,
|
||||
etna_update_render_resource(pctx, etna_resource(cbuf->prsc));
|
||||
|
||||
cs->PE_COLOR_FORMAT =
|
||||
VIVS_PE_COLOR_FORMAT_FORMAT(translate_rs_format(cbuf->base.format)) |
|
||||
VIVS_PE_COLOR_FORMAT_FORMAT(translate_pe_format(cbuf->base.format)) |
|
||||
VIVS_PE_COLOR_FORMAT_COMPONENTS__MASK |
|
||||
VIVS_PE_COLOR_FORMAT_OVERWRITE |
|
||||
COND(color_supertiled, VIVS_PE_COLOR_FORMAT_SUPER_TILED) |
|
||||
|
||||
@@ -234,28 +234,10 @@ translate_texture_filter(unsigned filter)
|
||||
}
|
||||
}
|
||||
|
||||
/* return a RS "compatible" format for use when copying */
|
||||
static inline enum pipe_format
|
||||
etna_compatible_rs_format(enum pipe_format fmt)
|
||||
{
|
||||
/* YUYV and UYVY are blocksize 4, but 2 bytes per pixel */
|
||||
if (fmt == PIPE_FORMAT_YUYV || fmt == PIPE_FORMAT_UYVY)
|
||||
return PIPE_FORMAT_B4G4R4A4_UNORM;
|
||||
|
||||
switch (util_format_get_blocksize(fmt)) {
|
||||
case 2:
|
||||
return PIPE_FORMAT_B4G4R4A4_UNORM;
|
||||
case 4:
|
||||
return PIPE_FORMAT_B8G8R8A8_UNORM;
|
||||
default:
|
||||
return fmt;
|
||||
}
|
||||
}
|
||||
|
||||
static inline int
|
||||
translate_rb_src_dst_swap(enum pipe_format src, enum pipe_format dst)
|
||||
{
|
||||
return translate_rs_format_rb_swap(src) ^ translate_rs_format_rb_swap(dst);
|
||||
return translate_pe_format_rb_swap(src) ^ translate_pe_format_rb_swap(dst);
|
||||
}
|
||||
|
||||
static inline uint32_t
|
||||
|
||||
Reference in New Issue
Block a user