lima: define set_clip_state implementation
authorErico Nunes <nunes.erico@gmail.com>
Fri, 25 Sep 2020 20:21:54 +0000 (22:21 +0200)
committerMarge Bot <eric+marge@anholt.net>
Sun, 15 Nov 2020 21:14:01 +0000 (21:14 +0000)
In applications using clip planes, set_clip_state is expected to be
implemented in the backend. If it is not defined, it may cause the
application to segfault.

glClipPlane it is not part of GLES 2, so it is not trivial to reverse
engineer if something needs to be done in lima.
Other drivers just define a placeholder implementation for
set_clip_state, so for now let's just define one for lima too.

Signed-off-by: Erico Nunes <nunes.erico@gmail.com>
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/7088>

src/gallium/drivers/lima/lima_context.h
src/gallium/drivers/lima/lima_state.c

index c8f4cf6..8ed9db9 100644 (file)
@@ -177,6 +177,7 @@ struct lima_context {
       LIMA_CONTEXT_DIRTY_STENCIL_REF  = (1 << 12),
       LIMA_CONTEXT_DIRTY_CONST_BUFF   = (1 << 13),
       LIMA_CONTEXT_DIRTY_TEXTURES     = (1 << 14),
+      LIMA_CONTEXT_DIRTY_CLIP         = (1 << 15),
    } dirty;
 
    struct u_upload_mgr *uploader;
@@ -197,6 +198,7 @@ struct lima_context {
    struct pipe_blend_color blend_color;
    struct lima_blend_state *blend;
    struct pipe_stencil_ref stencil_ref;
+   struct pipe_clip_state clip;
    struct lima_context_constant_buffer const_buffer[PIPE_SHADER_TYPES];
    struct lima_texture_stateobj tex_stateobj;
    struct lima_pp_stream_state pp_stream;
index 727b200..74a1a27 100644 (file)
@@ -255,6 +255,16 @@ lima_set_stencil_ref(struct pipe_context *pctx,
 }
 
 static void
+lima_set_clip_state(struct pipe_context *pctx,
+                    const struct pipe_clip_state *clip)
+{
+   struct lima_context *ctx = lima_context(pctx);
+   ctx->clip = *clip;
+
+   ctx->dirty |= LIMA_CONTEXT_DIRTY_CLIP;
+}
+
+static void
 lima_set_constant_buffer(struct pipe_context *pctx,
                          enum pipe_shader_type shader, uint index,
                          const struct pipe_constant_buffer *cb)
@@ -396,6 +406,7 @@ lima_state_init(struct lima_context *ctx)
    ctx->base.set_scissor_states = lima_set_scissor_states;
    ctx->base.set_blend_color = lima_set_blend_color;
    ctx->base.set_stencil_ref = lima_set_stencil_ref;
+   ctx->base.set_clip_state = lima_set_clip_state;
 
    ctx->base.set_vertex_buffers = lima_set_vertex_buffers;
    ctx->base.set_constant_buffer = lima_set_constant_buffer;