Просмотр исходного кода

freedreno/a6xx: Handle srgb blits on the blitter

Reviewed-by: Eric Anholt <eric@anholt.net>
Signed-off-by: Kristian H. Kristensen <hoegsberg@google.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/merge_requests/2848>
master
Kristian H. Kristensen 7 лет назад
Родитель
Сommit
183d482f7f
1 измененных файлов: 20 добавлений и 10 удалений
  1. 20
    10
      src/gallium/drivers/freedreno/a6xx/fd6_blitter.c

+ 20
- 10
src/gallium/drivers/freedreno/a6xx/fd6_blitter.c Просмотреть файл



fail_if(info->window_rectangle_include); fail_if(info->window_rectangle_include);


fail_if(util_format_is_srgb(info->src.format));
fail_if(util_format_is_srgb(info->dst.format));

const struct util_format_description *src_desc = const struct util_format_description *src_desc =
util_format_description(info->src.format); util_format_description(info->src.format);
const struct util_format_description *dst_desc = const struct util_format_description *dst_desc =
} }


static uint32_t static uint32_t
blit_control(enum a6xx_color_fmt fmt)
blit_control(enum a6xx_color_fmt fmt, bool is_srgb)
{ {
unsigned blit_cntl = 0xf00000;
blit_cntl |= A6XX_RB_2D_BLIT_CNTL_COLOR_FORMAT(fmt);
blit_cntl |= A6XX_RB_2D_BLIT_CNTL_IFMT(fd6_ifmt(fmt));
return blit_cntl;
enum a6xx_2d_ifmt ifmt = fd6_ifmt(fmt);

if (is_srgb) {
assert(ifmt == R2D_UNORM8);
ifmt = R2D_UNORM8_SRGB;
}

return A6XX_RB_2D_BLIT_CNTL_MASK(0xf) |
A6XX_RB_2D_BLIT_CNTL_COLOR_FORMAT(fmt) |
A6XX_RB_2D_BLIT_CNTL_IFMT(ifmt);
} }


/* buffers need to be handled specially since x/width can exceed the bounds /* buffers need to be handled specially since x/width can exceed the bounds
OUT_PKT7(ring, CP_SET_MARKER, 1); OUT_PKT7(ring, CP_SET_MARKER, 1);
OUT_RING(ring, A6XX_CP_SET_MARKER_0_MODE(RM6_BLIT2DSCALE)); OUT_RING(ring, A6XX_CP_SET_MARKER_0_MODE(RM6_BLIT2DSCALE));


uint32_t blit_cntl = blit_control(RB6_R8_UNORM) | 0x20000000;
uint32_t blit_cntl = blit_control(RB6_R8_UNORM, false) | 0x20000000;
OUT_PKT4(ring, REG_A6XX_RB_2D_BLIT_CNTL, 1); OUT_PKT4(ring, REG_A6XX_RB_2D_BLIT_CNTL, 1);
OUT_RING(ring, blit_cntl); OUT_RING(ring, blit_cntl);


OUT_PKT7(ring, CP_SET_MARKER, 1); OUT_PKT7(ring, CP_SET_MARKER, 1);
OUT_RING(ring, A6XX_CP_SET_MARKER_0_MODE(RM6_BLIT2DSCALE)); OUT_RING(ring, A6XX_CP_SET_MARKER_0_MODE(RM6_BLIT2DSCALE));


uint32_t blit_cntl = blit_control(dfmt);
uint32_t blit_cntl = blit_control(dfmt, util_format_is_srgb(info->dst.format));


if (color) { if (color) {
blit_cntl |= A6XX_RB_2D_BLIT_CNTL_SOLID_COLOR; blit_cntl |= A6XX_RB_2D_BLIT_CNTL_SOLID_COLOR;
COND(samples > MSAA_ONE && (info->mask & PIPE_MASK_RGBA), COND(samples > MSAA_ONE && (info->mask & PIPE_MASK_RGBA),
A6XX_SP_PS_2D_SRC_INFO_SAMPLES_AVERAGE) | A6XX_SP_PS_2D_SRC_INFO_SAMPLES_AVERAGE) |
COND(subwc_enabled, A6XX_SP_PS_2D_SRC_INFO_FLAGS) | COND(subwc_enabled, A6XX_SP_PS_2D_SRC_INFO_FLAGS) |
COND(util_format_is_srgb(info->src.format), A6XX_SP_PS_2D_SRC_INFO_SRGB) |
0x500000 | filter); 0x500000 | filter);
OUT_RING(ring, A6XX_SP_PS_2D_SRC_SIZE_WIDTH(width) | OUT_RING(ring, A6XX_SP_PS_2D_SRC_SIZE_WIDTH(width) |
A6XX_SP_PS_2D_SRC_SIZE_HEIGHT(height)); /* SP_PS_2D_SRC_SIZE */ A6XX_SP_PS_2D_SRC_SIZE_HEIGHT(height)); /* SP_PS_2D_SRC_SIZE */
OUT_RING(ring, A6XX_RB_2D_DST_INFO_COLOR_FORMAT(dfmt) | OUT_RING(ring, A6XX_RB_2D_DST_INFO_COLOR_FORMAT(dfmt) |
A6XX_RB_2D_DST_INFO_TILE_MODE(dtile) | A6XX_RB_2D_DST_INFO_TILE_MODE(dtile) |
A6XX_RB_2D_DST_INFO_COLOR_SWAP(dswap) | A6XX_RB_2D_DST_INFO_COLOR_SWAP(dswap) |
COND(util_format_is_srgb(info->dst.format), A6XX_RB_2D_DST_INFO_SRGB) |
COND(dubwc_enabled, A6XX_RB_2D_DST_INFO_FLAGS)); COND(dubwc_enabled, A6XX_RB_2D_DST_INFO_FLAGS));
OUT_RELOCW(ring, dst->bo, doff, 0, 0); /* RB_2D_DST_LO/HI */ OUT_RELOCW(ring, dst->bo, doff, 0, 0); /* RB_2D_DST_LO/HI */
OUT_RING(ring, A6XX_RB_2D_DST_SIZE_PITCH(dpitch)); OUT_RING(ring, A6XX_RB_2D_DST_SIZE_PITCH(dpitch));
if (dfmt == RB6_R10G10B10A2_UNORM) if (dfmt == RB6_R10G10B10A2_UNORM)
sfmt = RB6_R16G16B16A16_FLOAT; sfmt = RB6_R16G16B16A16_FLOAT;


/* This register is probably badly named... it seems that it's
* controlling the internal/accumulator format or something like
* that. It's certainly not tied to only the src format.
*/
OUT_PKT4(ring, REG_A6XX_SP_2D_SRC_FORMAT, 1); OUT_PKT4(ring, REG_A6XX_SP_2D_SRC_FORMAT, 1);
OUT_RING(ring, A6XX_SP_2D_SRC_FORMAT_COLOR_FORMAT(sfmt) | OUT_RING(ring, A6XX_SP_2D_SRC_FORMAT_COLOR_FORMAT(sfmt) |
COND(util_format_is_pure_sint(info->src.format), COND(util_format_is_pure_sint(info->src.format),
// TODO sometimes blob uses UINT+NORM but dEQP seems unhappy about that // TODO sometimes blob uses UINT+NORM but dEQP seems unhappy about that
// A6XX_SP_2D_SRC_FORMAT_UINT | // A6XX_SP_2D_SRC_FORMAT_UINT |
A6XX_SP_2D_SRC_FORMAT_NORM) | A6XX_SP_2D_SRC_FORMAT_NORM) |
COND(util_format_is_srgb(info->dst.format), A6XX_SP_2D_SRC_FORMAT_SRGB) |
A6XX_SP_2D_SRC_FORMAT_MASK(0xf)); A6XX_SP_2D_SRC_FORMAT_MASK(0xf));


OUT_PKT4(ring, REG_A6XX_RB_UNKNOWN_8E04, 1); OUT_PKT4(ring, REG_A6XX_RB_UNKNOWN_8E04, 1);

Загрузка…
Отмена
Сохранить