summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorErik Faye-Lund <erik.faye-lund@collabora.com>2018-07-16 12:37:31 +0200
committerDave Airlie <airlied@redhat.com>2018-07-17 13:59:47 +1000
commitb5db3aa6e8173600037b68e7ec4351bd2c1aade4 (patch)
treec8ce360074097b1bbb9dc5b5dda2f21979bd22f3
parentba1b41b504b9e3867cf4589a55fb69ab4441f041 (diff)
virgl: implement set_min_samples
This allows us to implement glMinSampleShading correctly, which up until now just got ignored. Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com> Reviewed-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--src/gallium/drivers/virgl/virgl_context.c12
-rw-r--r--src/gallium/drivers/virgl/virgl_encode.c7
-rw-r--r--src/gallium/drivers/virgl/virgl_encode.h3
-rw-r--r--src/gallium/drivers/virgl/virgl_hw.h1
-rw-r--r--src/gallium/drivers/virgl/virgl_protocol.h5
5 files changed, 28 insertions, 0 deletions
diff --git a/src/gallium/drivers/virgl/virgl_context.c b/src/gallium/drivers/virgl/virgl_context.c
index f5e3832d99f..ee28680b8fc 100644
--- a/src/gallium/drivers/virgl/virgl_context.c
+++ b/src/gallium/drivers/virgl/virgl_context.c
@@ -844,6 +844,17 @@ static void virgl_set_sample_mask(struct pipe_context *ctx,
virgl_encoder_set_sample_mask(vctx, sample_mask);
}
+static void virgl_set_min_samples(struct pipe_context *ctx,
+ unsigned min_samples)
+{
+ struct virgl_context *vctx = virgl_context(ctx);
+ struct virgl_screen *rs = virgl_screen(ctx->screen);
+
+ if (!(rs->caps.caps.v2.capability_bits & VIRGL_CAP_SET_MIN_SAMPLES))
+ return;
+ virgl_encoder_set_min_samples(vctx, min_samples);
+}
+
static void virgl_set_clip_state(struct pipe_context *ctx,
const struct pipe_clip_state *clip)
{
@@ -1025,6 +1036,7 @@ struct pipe_context *virgl_context_create(struct pipe_screen *pscreen,
vctx->base.set_polygon_stipple = virgl_set_polygon_stipple;
vctx->base.set_scissor_states = virgl_set_scissor_states;
vctx->base.set_sample_mask = virgl_set_sample_mask;
+ vctx->base.set_min_samples = virgl_set_min_samples;
vctx->base.set_stencil_ref = virgl_set_stencil_ref;
vctx->base.set_clip_state = virgl_set_clip_state;
diff --git a/src/gallium/drivers/virgl/virgl_encode.c b/src/gallium/drivers/virgl/virgl_encode.c
index 6b800d3d077..c7c6b1e7d34 100644
--- a/src/gallium/drivers/virgl/virgl_encode.c
+++ b/src/gallium/drivers/virgl/virgl_encode.c
@@ -726,6 +726,13 @@ void virgl_encoder_set_sample_mask(struct virgl_context *ctx,
virgl_encoder_write_dword(ctx->cbuf, sample_mask);
}
+void virgl_encoder_set_min_samples(struct virgl_context *ctx,
+ unsigned min_samples)
+{
+ virgl_encoder_write_cmd_dword(ctx, VIRGL_CMD0(VIRGL_CCMD_SET_MIN_SAMPLES, 0, VIRGL_SET_MIN_SAMPLES_SIZE));
+ virgl_encoder_write_dword(ctx->cbuf, min_samples);
+}
+
void virgl_encoder_set_clip_state(struct virgl_context *ctx,
const struct pipe_clip_state *clip)
{
diff --git a/src/gallium/drivers/virgl/virgl_encode.h b/src/gallium/drivers/virgl/virgl_encode.h
index 837075ea483..21c506eb56f 100644
--- a/src/gallium/drivers/virgl/virgl_encode.h
+++ b/src/gallium/drivers/virgl/virgl_encode.h
@@ -211,6 +211,9 @@ void virgl_encoder_set_polygon_stipple(struct virgl_context *ctx,
void virgl_encoder_set_sample_mask(struct virgl_context *ctx,
unsigned sample_mask);
+void virgl_encoder_set_min_samples(struct virgl_context *ctx,
+ unsigned min_samples);
+
void virgl_encoder_set_clip_state(struct virgl_context *ctx,
const struct pipe_clip_state *clip);
diff --git a/src/gallium/drivers/virgl/virgl_hw.h b/src/gallium/drivers/virgl/virgl_hw.h
index 157267558ac..118249e6950 100644
--- a/src/gallium/drivers/virgl/virgl_hw.h
+++ b/src/gallium/drivers/virgl/virgl_hw.h
@@ -201,6 +201,7 @@ enum virgl_formats {
#define VIRGL_CAP_NONE 0
#define VIRGL_CAP_TGSI_INVARIANT (1 << 0)
#define VIRGL_CAP_TEXTURE_VIEW (1 << 1)
+#define VIRGL_CAP_SET_MIN_SAMPLES (1 << 2)
#define VIRGL_BIND_DEPTH_STENCIL (1 << 0)
#define VIRGL_BIND_RENDER_TARGET (1 << 1)
diff --git a/src/gallium/drivers/virgl/virgl_protocol.h b/src/gallium/drivers/virgl/virgl_protocol.h
index bd5a8b40434..53493d5c156 100644
--- a/src/gallium/drivers/virgl/virgl_protocol.h
+++ b/src/gallium/drivers/virgl/virgl_protocol.h
@@ -85,6 +85,7 @@ enum virgl_context_cmd {
VIRGL_CCMD_BIND_SHADER,
VIRGL_CCMD_SET_TESS_STATE,
+ VIRGL_CCMD_SET_MIN_SAMPLES,
};
/*
@@ -486,4 +487,8 @@ enum virgl_context_cmd {
/* tess state */
#define VIRGL_TESS_STATE_SIZE 6
+/* set min samples */
+#define VIRGL_SET_MIN_SAMPLES_SIZE 1
+#define VIRGL_SET_MIN_SAMPLES_MASK 1
+
#endif