diff --git a/src/virgl_hw.h b/src/virgl_hw.h index 44c7108..5260f62 100644 --- a/src/virgl_hw.h +++ b/src/virgl_hw.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; diff --git a/src/virgl_protocol.h b/src/virgl_protocol.h index d0e6c49..a0b6984 100644 --- a/src/virgl_protocol.h +++ b/src/virgl_protocol.h @@ -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 diff --git a/src/vrend_decode.c b/src/vrend_decode.c index d50f385..111fc90 100644 --- a/src/vrend_decode.c +++ b/src/vrend_decode.c @@ -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; diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index cc99087..30f0bab 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -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; diff --git a/src/vrend_renderer.h b/src/vrend_renderer.h index f59d45f..eda09e4 100644 --- a/src/vrend_renderer.h +++ b/src/vrend_renderer.h @@ -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,