From 883cda5713adbf9017bbb0a0b82a31f943805446 Mon Sep 17 00:00:00 2001 From: Jakob Bornecrantz Date: Fri, 22 Dec 2017 18:57:52 +0000 Subject: [PATCH] vrend: Warn on depth range out of bounds OpenGL ES glDepthRange clamps the values, warn if the range is out of bounds. We can't do much more then then this, during normal guest side Desktop OpenGL operation this does not seem to happen. Signed-off-by: Jakob Bornecrantz Signed-off-by: Dave Airlie --- src/vrend_renderer.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/vrend_renderer.c b/src/vrend_renderer.c index a5b8da0..4095831 100644 --- a/src/vrend_renderer.c +++ b/src/vrend_renderer.c @@ -500,8 +500,9 @@ static void __report_core_warn(const char *fname, struct vrend_context *ctx, enu #define GLES_WARN_NONE 0 #define GLES_WARN_STIPPLE 1 #define GLES_WARN_POLYGON_MODE 2 +#define GLES_WARN_DEPTH_RANGE 3 -static const char *vrend_gles_warn_strings[] = { "None", "Stipple", "Polygon Mode" }; +static const char *vrend_gles_warn_strings[] = { "None", "Stipple", "Polygon Mode", "Depth Range" }; static void __report_gles_warn(const char *fname, struct vrend_context *ctx, enum virgl_ctx_errors error, uint32_t value) { @@ -1658,7 +1659,16 @@ void vrend_set_viewport_states(struct vrend_context *ctx, ctx->sub->vps[idx].far_val != far_val) { ctx->sub->vps[idx].near_val = near_val; ctx->sub->vps[idx].far_val = far_val; - if (idx) + + if (vrend_state.use_gles) { + if (near_val < 0.0f || far_val < 0.0f || + near_val > 1.0f || far_val > 1.0f || idx) { + report_gles_warn(ctx, GLES_WARN_DEPTH_RANGE, 0); + } + + /* Best effort despite the warning, gles will clamp. */ + glDepthRangef(ctx->sub->vps[idx].near_val, ctx->sub->vps[idx].far_val); + } else if (idx) glDepthRangeIndexed(idx, ctx->sub->vps[idx].near_val, ctx->sub->vps[idx].far_val); else glDepthRange(ctx->sub->vps[idx].near_val, ctx->sub->vps[idx].far_val);