Module: Mesa Branch: main Commit: d1798ad1b53c55abee4e21cb533f80629253c173 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=d1798ad1b53c55abee4e21cb533f80629253c173
Author: Andreas Baierl <[email protected]> Date: Fri Sep 10 14:33:55 2021 +0200 lima: Expose GL_EXT_clip_control Reviewed-by: Erico Nunes <[email protected]> Signed-off-by: Andreas Baierl <[email protected]> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12804> --- docs/features.txt | 2 +- src/gallium/drivers/lima/lima_draw.c | 8 ++++++-- src/gallium/drivers/lima/lima_parser.c | 6 +++++- src/gallium/drivers/lima/lima_screen.c | 1 + src/gallium/drivers/lima/lima_state.c | 9 +++++---- 5 files changed, 18 insertions(+), 8 deletions(-) diff --git a/docs/features.txt b/docs/features.txt index a12f6dcf247..2fa03dc36df 100644 --- a/docs/features.txt +++ b/docs/features.txt @@ -213,7 +213,7 @@ GL 4.4, GLSL 4.40 -- all DONE: i965/gen8+, nvc0, r600, radeonsi, llvmpipe, zink GL 4.5, GLSL 4.50 -- all DONE: nvc0, r600, radeonsi, llvmpipe, zink GL_ARB_ES3_1_compatibility DONE (i965/hsw+, softpipe, virgl) - GL_ARB_clip_control DONE (freedreno, i965, nv50, softpipe, swr, virgl) + GL_ARB_clip_control DONE (freedreno, i965, nv50, softpipe, swr, virgl, lima) GL_ARB_conditional_render_inverted DONE (freedreno, i965, nv50, softpipe, swr, virgl, panfrost) GL_ARB_cull_distance DONE (freedreno/a6xx, i965, nv50, softpipe, swr, virgl) GL_ARB_derivative_control DONE (i965, nv50, softpipe, virgl) diff --git a/src/gallium/drivers/lima/lima_draw.c b/src/gallium/drivers/lima/lima_draw.c index 161fc7288a5..c0a0ba6dd70 100644 --- a/src/gallium/drivers/lima/lima_draw.c +++ b/src/gallium/drivers/lima/lima_draw.c @@ -600,8 +600,7 @@ lima_calculate_depth_test(struct pipe_depth_stencil_alpha_state *depth, return (depth->depth_enabled && depth->depth_writemask) | ((int)func << 1) | (offset_scale << 16) | - (offset_units << 24) | - 0x30; /* find out what is this */ + (offset_units << 24); } static void @@ -647,6 +646,11 @@ lima_pack_render_state(struct lima_context *ctx, const struct pipe_draw_info *in struct pipe_rasterizer_state *rst = &ctx->rasterizer->base; render->depth_test = lima_calculate_depth_test(&ctx->zsa->base, rst); + if (!rst->depth_clip_near || ctx->viewport.near == 0.0f) + render->depth_test |= 0x10; /* don't clip depth near */ + if (!rst->depth_clip_far || ctx->viewport.far == 1.0f) + render->depth_test |= 0x20; /* don't clip depth far */ + ushort far, near; near = float_to_ushort(ctx->viewport.near); diff --git a/src/gallium/drivers/lima/lima_parser.c b/src/gallium/drivers/lima/lima_parser.c index b0a6c86a9e5..3f98069be43 100644 --- a/src/gallium/drivers/lima/lima_parser.c +++ b/src/gallium/drivers/lima/lima_parser.c @@ -489,7 +489,11 @@ parse_rsw(FILE *fp, uint32_t *value, int i, uint32_t *helper) if (*value & 0x1000) fprintf(fp, ", shader writes stencil"); fprintf(fp, " */\n\t\t\t\t\t\t/* %s(3)", render_state_infos[i].info); - fprintf(fp, ": unknown bits 4-9: 0x%08x", *value & 0x000003f0); + if ((*value & 0x00000010) == 0x00000010) + fprintf(fp, ": ignore depth clip near"); + if ((*value & 0x00000020) == 0x00000020) + fprintf(fp, ", ignore depth clip far"); + fprintf(fp, ", unknown bits 6-9: 0x%08x", *value & 0x000003c0); fprintf(fp, ", unknown bits 13-15: 0x%08x */\n", *value & 0x00000e000); break; case 4: /* DEPTH RANGE */ diff --git a/src/gallium/drivers/lima/lima_screen.c b/src/gallium/drivers/lima/lima_screen.c index 9c52f30de7d..adeb3b9c840 100644 --- a/src/gallium/drivers/lima/lima_screen.c +++ b/src/gallium/drivers/lima/lima_screen.c @@ -101,6 +101,7 @@ lima_screen_get_param(struct pipe_screen *pscreen, enum pipe_cap param) case PIPE_CAP_BLEND_EQUATION_SEPARATE: case PIPE_CAP_ACCELERATED: case PIPE_CAP_UMA: + case PIPE_CAP_CLIP_HALFZ: case PIPE_CAP_NATIVE_FENCE_FD: case PIPE_CAP_FRAGMENT_SHADER_TEXTURE_LOD: case PIPE_CAP_TEXTURE_SWIZZLE: diff --git a/src/gallium/drivers/lima/lima_state.c b/src/gallium/drivers/lima/lima_state.c index eafe772554e..778c793fece 100644 --- a/src/gallium/drivers/lima/lima_state.c +++ b/src/gallium/drivers/lima/lima_state.c @@ -29,6 +29,7 @@ #include "util/u_helpers.h" #include "util/u_debug.h" #include "util/u_framebuffer.h" +#include "util/u_viewport.h" #include "pipe/p_state.h" @@ -218,11 +219,11 @@ lima_set_viewport_states(struct pipe_context *pctx, /* reverse calculate the parameter of glDepthRange */ float near, far; - near = viewport->translate[2] - viewport->scale[2]; - far = viewport->translate[2] + viewport->scale[2]; + bool halfz = ctx->rasterizer && ctx->rasterizer->base.clip_halfz; + util_viewport_zmin_zmax(viewport, halfz, &near, &far); - ctx->viewport.near = MIN2(near, far); - ctx->viewport.far = MAX2(near, far); + ctx->viewport.near = ctx->rasterizer && ctx->rasterizer->base.depth_clip_near ? near : 0.0f; + ctx->viewport.far = ctx->rasterizer && ctx->rasterizer->base.depth_clip_far ? far : 1.0f; ctx->viewport.transform = *viewport; ctx->dirty |= LIMA_CONTEXT_DIRTY_VIEWPORT;
