From fc43ff62a5b5a56ee6095cb82ffe748f8518d96b Mon Sep 17 00:00:00 2001 From: Lepton Wu Date: Tue, 11 Feb 2020 13:22:31 -0800 Subject: [PATCH] vrend: Don't crash when no feat_dual_src_blend When there is no feat_dual_src_blend, avoid calling glBindFragDataLocationIndexed. Otherwise epoxy could crash the whole process when this function is not available. Signed-off-by: Lepton Wu Reviewed-by: Gurchetan Singh --- src/virgl_hw.h | 3 ++- src/vrend_renderer.c | 14 ++++++++++---- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/src/virgl_hw.h b/src/virgl_hw.h index 44ec63d..582c8e4 100644 --- a/src/virgl_hw.h +++ b/src/virgl_hw.h @@ -555,7 +555,8 @@ enum virgl_ctx_errors { VIRGL_ERROR_GL_ANY_SAMPLES_PASSED, VIRGL_ERROR_CTX_ILLEGAL_FORMAT, VIRGL_ERROR_CTX_ILLEGAL_SAMPLER_VIEW_TARGET, - VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS + VIRGL_ERROR_CTX_TRANSFER_IOV_BOUNDS, + VIRGL_ERROR_CTX_ILLEGAL_DUAL_SRC_BLEND }; #define VIRGL_RESOURCE_Y_0_TOP (1 << 0) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index 30b4f2d..ad7a351 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -1525,12 +1525,18 @@ static struct vrend_linked_shader_program *add_shader_program(struct vrend_conte if (fs->sel->sinfo.num_outputs > 1) { if (util_blend_state_is_dual(&ctx->sub->blend_state, 0)) { - glBindFragDataLocationIndexed(prog_id, 0, 0, "fsout_c0"); - glBindFragDataLocationIndexed(prog_id, 0, 1, "fsout_c1"); + if (has_feature(feat_dual_src_blend)) { + glBindFragDataLocationIndexed(prog_id, 0, 0, "fsout_c0"); + glBindFragDataLocationIndexed(prog_id, 0, 1, "fsout_c1"); + } else { + report_context_error(ctx, VIRGL_ERROR_CTX_ILLEGAL_DUAL_SRC_BLEND, 0); + } sprog->dual_src_linked = true; } else { - glBindFragDataLocationIndexed(prog_id, 0, 0, "fsout_c0"); - glBindFragDataLocationIndexed(prog_id, 1, 0, "fsout_c1"); + if (has_feature(feat_dual_src_blend)) { + glBindFragDataLocationIndexed(prog_id, 0, 0, "fsout_c0"); + glBindFragDataLocationIndexed(prog_id, 1, 0, "fsout_c1"); + } sprog->dual_src_linked = false; } } else