lima: implement alpha test
As [1] suggests, 3 lower bits in rsw->multi_sample is alpha test compare func and bits 16-23 are reference value - uint8, 0.0 is 0, 0.5 is 0x80, 1.0 is 0xff. Just as on Panfrost, enabled alpha test needs early-Z and pixel kill to be disabled. [1] http://web.archive.org/web/20171026123213/http://limadriver.org/Render_State/ Reviewed-by: Erico Nunes <nunes.erico@gmail.com> Reviewed-by: Alyssa Rosenzweig <alyssa@collabora.com> Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/10879>
This commit is contained in:
parent
726cb2d6f6
commit
d6eab2cc77
|
@ -681,11 +681,7 @@ lima_pack_render_state(struct lima_context *ctx, const struct pipe_draw_info *in
|
|||
(stencil[1].valuemask << 24);
|
||||
render->stencil_test = (stencil[0].writemask & 0xff) | (stencil[1].writemask & 0xff) << 8;
|
||||
}
|
||||
/* TODO: Find out, what (render->stecil_test & 0xffff0000) is.
|
||||
* 0x00ff0000 is probably (float_to_ubyte(alpha->ref_value) << 16)
|
||||
* (render->multi_sample & 0x00000007 is probably the compare function
|
||||
* of glAlphaFunc then.
|
||||
*/
|
||||
/* TODO: Find out, what (render->stecil_test & 0xff000000) is */
|
||||
}
|
||||
else {
|
||||
/* Default values, when stencil is disabled:
|
||||
|
@ -700,14 +696,23 @@ lima_pack_render_state(struct lima_context *ctx, const struct pipe_draw_info *in
|
|||
|
||||
/* need more investigation */
|
||||
if (info->mode == PIPE_PRIM_POINTS)
|
||||
render->multi_sample = 0x0000F007;
|
||||
render->multi_sample = 0x0000F000;
|
||||
else if (info->mode < PIPE_PRIM_TRIANGLES)
|
||||
render->multi_sample = 0x0000F407;
|
||||
render->multi_sample = 0x0000F400;
|
||||
else
|
||||
render->multi_sample = 0x0000F807;
|
||||
render->multi_sample = 0x0000F800;
|
||||
if (ctx->framebuffer.base.samples)
|
||||
render->multi_sample |= 0x68;
|
||||
|
||||
/* alpha test */
|
||||
if (ctx->zsa->base.alpha_enabled) {
|
||||
render->multi_sample |= ctx->zsa->base.alpha_func;
|
||||
render->stencil_test |= float_to_ubyte(ctx->zsa->base.alpha_ref_value) << 16;
|
||||
} else {
|
||||
/* func = PIPE_FUNC_ALWAYS */
|
||||
render->multi_sample |= 0x7;
|
||||
}
|
||||
|
||||
render->shader_address =
|
||||
ctx->fs->bo->va | (((uint32_t *)ctx->fs->bo->map)[0] & 0x1F);
|
||||
|
||||
|
@ -721,7 +726,8 @@ lima_pack_render_state(struct lima_context *ctx, const struct pipe_draw_info *in
|
|||
if (ctx->blend->base.dither)
|
||||
render->aux1 |= 0x00002000;
|
||||
|
||||
if (fs->state.uses_discard) {
|
||||
if (fs->state.uses_discard ||
|
||||
ctx->zsa->base.alpha_enabled) {
|
||||
early_z = false;
|
||||
pixel_kill = false;
|
||||
}
|
||||
|
|
|
@ -537,8 +537,10 @@ parse_rsw(FILE *fp, uint32_t *value, int i, uint32_t *helper)
|
|||
(*value & 0x0000ff00) >> 8); /* back writemask */
|
||||
/* add a few tabs for alignment */
|
||||
fprintf(fp, "\t\t\t\t\t\t/* %s(2)", render_state_infos[i].info);
|
||||
fprintf(fp, ": unknown (bits 16-31) 0x%04x */\n",
|
||||
(*value & 0xffff0000) >> 16); /* unknown, alpha ref_value? */
|
||||
fprintf(fp, ": alpha_ref_value: 0x%02x */\n", (*value & 0x00ff0000) >> 16);
|
||||
fprintf(fp, "\t\t\t\t\t\t/* %s(3)", render_state_infos[i].info);
|
||||
fprintf(fp, ": unknown (bits 24-31) 0x%02x */\n",
|
||||
(*value & 0xff000000) >> 24); /* unknown */
|
||||
break;
|
||||
case 8: /* MULTI SAMPLE */
|
||||
if ((*value & 0x00000f00) == 0x00000000)
|
||||
|
@ -556,6 +558,10 @@ parse_rsw(FILE *fp, uint32_t *value, int i, uint32_t *helper)
|
|||
fprintf(fp, " */\n");
|
||||
else
|
||||
fprintf(fp, ", UNKNOWN\n");
|
||||
fprintf(fp, "\t\t\t\t\t\t/* %s(2)", render_state_infos[i].info);
|
||||
fprintf(fp, ": alpha_test_func: %d (%s) */\n",
|
||||
(*value & 0x00000007),
|
||||
lima_get_compare_func_string((*value & 0x00000007))); /* alpha_test_func */
|
||||
break;
|
||||
case 9: /* SHADER ADDRESS */
|
||||
fprintf(fp, ": fs shader @ 0x%08x, first instr length %d */\n",
|
||||
|
|
|
@ -149,6 +149,8 @@ lima_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param)
|
|||
return 0;
|
||||
|
||||
case PIPE_CAP_ALPHA_TEST:
|
||||
return 1;
|
||||
|
||||
case PIPE_CAP_FLATSHADE:
|
||||
case PIPE_CAP_TWO_SIDED_COLOR:
|
||||
case PIPE_CAP_CLIP_PLANES:
|
||||
|
|
Loading…
Reference in New Issue