implement VIRGL_CCMD_SET_MIN_SAMPLES

This is required to implement glMinSampleShading().

Sadly, we've been setting has_sample_shading for a while, even
though this is needed. So we need to set a capability so mesa will
know that it's safe to emit this command.

Signed-off-by: Erik Faye-Lund <erik.faye-lund@collabora.com>
Reviewed-by: Dave Airlie <airlied@redhat.com>
macos/master
Erik Faye-Lund 7 years ago committed by Dave Airlie
parent 36fe024ab8
commit d24ac12d7b
  1. 1
      src/virgl_hw.h
  2. 5
      src/virgl_protocol.h
  3. 14
      src/vrend_decode.c
  4. 14
      src/vrend_renderer.c
  5. 1
      src/vrend_renderer.h

@ -215,6 +215,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)
struct virgl_caps_bool_set1 {
unsigned indep_blend_enable:1;

@ -84,6 +84,7 @@ enum virgl_context_cmd {
VIRGL_CCMD_DESTROY_SUB_CTX,
VIRGL_CCMD_BIND_SHADER,
VIRGL_CCMD_SET_TESS_STATE,
VIRGL_CCMD_SET_MIN_SAMPLES,
};
/*
@ -485,4 +486,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

@ -865,6 +865,17 @@ static int vrend_decode_set_sample_mask(struct vrend_decode_ctx *ctx, int length
return 0;
}
static int vrend_decode_set_min_samples(struct vrend_decode_ctx *ctx, int length)
{
unsigned min_samples;
if (length != VIRGL_SET_MIN_SAMPLES_SIZE)
return EINVAL;
min_samples = get_buf_entry(ctx, VIRGL_SET_MIN_SAMPLES_MASK);
vrend_set_min_samples(ctx->grctx, min_samples);
return 0;
}
static int vrend_decode_resource_copy_region(struct vrend_decode_ctx *ctx, int length)
{
struct pipe_box box;
@ -1267,6 +1278,9 @@ int vrend_decode_block(uint32_t ctx_id, uint32_t *block, int ndw)
case VIRGL_CCMD_SET_SAMPLE_MASK:
ret = vrend_decode_set_sample_mask(gdctx, len);
break;
case VIRGL_CCMD_SET_MIN_SAMPLES:
ret = vrend_decode_set_min_samples(gdctx, len);
break;
case VIRGL_CCMD_SET_STREAMOUT_TARGETS:
ret = vrend_decode_set_streamout_targets(gdctx, len);
break;

@ -6086,6 +6086,18 @@ void vrend_set_sample_mask(UNUSED struct vrend_context *ctx, unsigned sample_mas
glSampleMaski(0, sample_mask);
}
void vrend_set_min_samples(struct vrend_context *ctx, unsigned min_samples)
{
float min_sample_shading = (float)min_samples;
if (ctx->sub->nr_cbufs > 0 && ctx->sub->surf[0]) {
assert(ctx->sub->surf[0]->texture);
min_sample_shading /= MAX2(1, ctx->sub->surf[0]->texture->base.nr_samples);
}
if (vrend_state.have_sample_shading)
glMinSampleShading(min_sample_shading);
}
void vrend_set_tess_state(UNUSED struct vrend_context *ctx, const float tess_factors[6])
{
if (vrend_state.have_tessellation) {
@ -7550,7 +7562,7 @@ void vrend_renderer_fill_caps(uint32_t set, uint32_t version,
caps->v1.max_samples = vrend_renderer_query_multisample_caps(max, &caps->v2);
caps->v2.capability_bits |= VIRGL_CAP_TGSI_INVARIANT;
caps->v2.capability_bits |= VIRGL_CAP_TGSI_INVARIANT | VIRGL_CAP_SET_MIN_SAMPLES;
if (gl_ver >= 43 || epoxy_has_gl_extension("GL_ARB_texture_view"))
caps->v2.capability_bits |= VIRGL_CAP_TEXTURE_VIEW;

@ -272,6 +272,7 @@ void vrend_set_polygon_stipple(struct vrend_context *ctx, struct pipe_poly_stipp
void vrend_set_clip_state(struct vrend_context *ctx, struct pipe_clip_state *ucp);
void vrend_set_sample_mask(struct vrend_context *ctx, unsigned sample_mask);
void vrend_set_min_samples(struct vrend_context *ctx, unsigned min_samples);
void vrend_set_constants(struct vrend_context *ctx,
uint32_t shader,

Loading…
Cancel
Save